geoutils.Raster.reproject

geoutils.Raster.reproject#

Raster.reproject(ref=None, crs=None, res=None, grid_size=None, bounds=None, nodata=None, dtype=None, resampling=Resampling.bilinear, force_source_nodata=None, inplace=False, silent=False, n_threads=0, memory_limit=64, multiproc_config=None)[source]#

Reproject raster to a different geotransform (resolution, bounds) and/or coordinate reference system (CRS).

Match-reference: a reference raster can be passed to match resolution, bounds and CRS during reprojection.

Alternatively, the destination resolution, bounds and CRS can be passed individually.

Any resampling algorithm implemented in Rasterio can be passed as a string.

The reprojection can be computed out-of-memory in multiprocessing by passing a MultiprocConfig object. The reprojected raster is written to disk under the path specified in the configuration

Parameters:
  • ref (Union[TypeVar(RasterType, bound= Raster), str, None]) – Reference raster to match resolution, bounds and CRS.

  • crs (CRS | str | int | None) – Destination coordinate reference system as a string or EPSG. If ref not set, defaults to this raster’s CRS.

  • res (float | Iterable[float] | None) – Destination resolution (pixel size) in units of destination CRS. Single value or (xres, yres). Do not use with grid_size.

  • grid_size (tuple[int, int] | None) – Destination grid size as (x, y). Do not use with res.

  • bounds (dict[str, float] | BoundingBox | None) – Destination bounds as a Rasterio bounding box, or a dictionary containing left, bottom, right, top bounds in the destination CRS.

  • nodata (int | float | None) – Destination nodata value. If set to None, will use the same as source. If source does not exist, will use GDAL’s default.

  • dtype (Union[dtype[Any], None, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, SupportsIndex | Sequence[SupportsIndex]], list[Any], _DTypeDict, tuple[Any, Any]]) – Destination data type of array.

  • resampling (Resampling | str) – A Rasterio resampling method, can be passed as a string. See https://rasterio.readthedocs.io/en/stable/api/rasterio.enums.html#rasterio.enums.Resampling for the full list.

  • inplace (bool) – Whether to update the raster in-place.

  • force_source_nodata (int | float | None) – Force a source nodata value (read from the metadata by default).

  • silent (bool) – Whether to print warning statements.

  • n_threads (int) – Number of threads. Defaults to (os.cpu_count() - 1).

  • memory_limit (int) – Memory limit in MB for warp operations. Larger values may perform better.

  • multiproc_config (MultiprocConfig | None) – Configuration object containing chunk size, output file path, and an optional cluster.

Return type:

Optional[TypeVar(RasterType, bound= Raster)]

Returns:

Reprojected raster (or None if inplace or computed out-of-memory).