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)[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.
- 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. Ifref
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 withgrid_size
.grid_size (
tuple
[int
,int
] |None
) – Destination grid size as (x, y). Do not use withres
.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 toNone
, 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
,Union
[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.
- Return type:
- Returns:
Reprojected raster (or None if inplace).