⚠️ Our 0.1 release refactored several early-development functions for long-term stability, to update your code see here. ⚠️
Future changes will come with deprecation warnings! 🙂




geoutils.raster.stack_rasters(rasters, reference=0, resampling_method='bilinear', use_ref_bounds=False, diff=False, progress=True)[source]#

Stack a list of rasters on their maximum extent into a multi-band raster.

The input rasters can have any transform or CRS, and will be reprojected to the reference raster’s CRS and resolution. The output multi-band raster has an extent that is the union of all raster extents, except if use_ref_bounds is used, and the number of band equal to the number of input rasters.

Use diff=True to return directly the difference to the reference raster.

Note that all rasters will be loaded once in memory. The data is only loaded for reprojection then deleted to optimize memory usage.

  • rasters (list[TypeVar(RasterType, bound= Raster)]) – List of rasters to be stacked.

  • reference (int | Raster) – Index of reference raster in the list or separate reference raster. Defaults to the first raster in the list.

  • resampling_method (str | Resampling) – Resampling method for reprojection.

  • use_ref_bounds (bool) – If True, will use reference bounds, otherwise will use maximum bounds of all rasters.

  • diff (bool) – If True, will return the difference to the reference raster.

  • progress (bool) – If True, will display a progress bar. Default is True.

Return type:



The merged raster with same CRS and resolution (and optionally bounds) as the reference.