save_rasters(fn_base_raster, fn_raster_list, data, spatial_win=None, dtype=None, nodata=None, fit_in_dtype=False, n_jobs=4, verbose=False)[source]

Save a 3D array in multiple raster files using as reference one base raster. The last dimension is used to split the data in different rasters. GeoTIFF is the only output format supported. It always replaces the np.nan value by the specified nodata.

  • fn_base_raster (str) – The base raster path used to retrieve the parameters (height, width, n_bands, crs, dtype, transform) for the new rasters.

  • fn_raster_list (List) – A list containing the paths for the new raster. It creates the folder hierarchy if not exists.

  • data (array) – 3D data array.

  • spatial_win (Optional[Window]) – Save the data considering a spatial window, even if the fn_base_rasters refers to a bigger area. For example, it’s possible to have a base raster covering the whole Europe and save the data using a window that cover just part of Wageningen. By default is None saving the raster data in position 0, 0 of the raster grid.

  • dtype (Optional[str]) – Convert the data to a specific dtype before save it. By default is None using the same dtype from the base raster.

  • nodata – Use the specified value as nodata for the new rasters. By default is None using the same nodata from the base raster.

  • fit_in_dtype (bool) – If True the values outside of dtype range are truncated to the minimum and maximum representation. It’s also change the minimum and maximum data values, if they exist, to avoid overlap with nodata (see the _fit_in_dtype function). For example, if dtype='uint8' and nodata=0, all data values equal to 0 are re-scaled to 1 in the new rasters.

  • n_jobs (int) – Number of parallel jobs used to save the raster files.

  • verbose (bool) – Use True to print the saving progress.


A list containing the path for new rasters.

Return type



>>> import rasterio
>>> from eumap.raster import read_rasters, save_rasters
>>> # EUMAP COG layers - NDVI seasons for 2019
>>> raster_files = [
>>>     '', # winter
>>>     '', # spring
>>>     '', # summer
>>>     ''  # fall
>>> ]
>>> # Transform for the EPSG:3035
>>> eu_transform =[0]).transform
>>> # Bounding box window over Wageningen, NL
>>> window =, bottom=3213544, right=4023659, top=3216544, transform=eu_transform)
>>> data, _ = read_rasters(raster_files=raster_files, spatial_win=window, verbose=True)
>>> # Save in the current execution folder
>>> fn_raster_list = [
>>>     './lcv_ndvi_landsat.glad.ard_p50_30m_0..0cm_201903_wageningen_epsg3035_v1.0.tif',
>>>     './lcv_ndvi_landsat.glad.ard_p50_30m_0..0cm_201906_wageningen_epsg3035_v1.0.tif',
>>>     './lcv_ndvi_landsat.glad.ard_p50_30m_0..0cm_201909_wageningen_epsg3035_v1.0.tif',
>>>     './lcv_ndvi_landsat.glad.ard_p50_30m_0..0cm_201912_wageningen_epsg3035_v1.0.tif'
>>> ]
>>> save_rasters(raster_files[0], fn_raster_list, data, spatial_win=window, verbose=True)