Raster.reproject() or ds.rst.reproject()#
- RasterBase.reproject(ref=None, crs=None, res=None, grid_size=None, bounds=None, nodata=None, dtype=None, resampling=None, force_source_nodata=None, silent=False, inplace=False, n_threads=0, memory_limit=64, mp_config=None, nodata_propagation=None, overlap_backend='auto', error_structure=None, window=None, window_shape=None, coverage=None, area_weighting='diagonal_bounds')[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
MultiprocConfigobject. The reprojected raster is written to disk under the path specified in the configuration- Parameters:
ref (
TypeVar(RasterType, bound= RasterBase) |str|None) – Reference raster to match resolution, bounds and CRS.crs (
CRS|str|int|None) – Destination coordinate reference system as a string or EPSG. Ifrefnot 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.resampling (
Resampling|str|Interpolator|Reducer) – A Rasterio resampling method or a custom Interpolator or Reducer. Existing methods can be passed as strings and continue to use Rasterio. By default, a Reducer weights source cells by their covered area. With GridNeighbours, it uses a fixed window around the transformed destination center. Defaults to bilinear. Can be configured with the global setting geoutils.config[“reprojection_method”]. See https://rasterio.readthedocs.io/en/stable/api/rasterio.enums.html#rasterio.enums.Resampling for the full list.force_source_nodata (
int|float|None) – Force a source nodata value (read from the metadata by default).inplace (
bool) – (DEPRECATED. Use rast = rast.reproject() instead) Whether to reproject in-place or not.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.mp_config (
MultiprocConfig|None) – Configuration object containing chunk size, output file path, and an optional cluster.nodata_propagation (
Literal['nearest','ignore','propagate'] |None) – How invalid source values affect a custom Interpolator or Reducer. By default, an Interpolator excludes invalid neighbors and masks a destination whose nearest source cell is invalid; a Reducer excludes invalid source cells and returns nodata if none are valid.ignoreexcludes invalid values without the nearest-cell mask;propagatereturns nodata if any contributing value is invalid.nearestexplicitly requests the default Interpolator rule.overlap_backend (
Literal['auto','numba','exactextract','shapely']) – Method used to calculate a Reducer’s cell overlap.autouses Numba for small unaligned grids when installed, then ExactExtract when installed, or Shapely.numba,exactextractandshapelyselect one explicitly. Aligned grids use direct overlap lengths.error_structure (
ErrorStructure|None) – Optional observation error model used for weighting and fitting. Use geoutils.uncertainty.propagate() to calculate output uncertainty.window (
int|None) – Odd source window size for a Reducer, overriding its configured neighborhood.window_shape (
Literal['square','circular'] |None) – Square or circular source window for a Reducer.coverage (
Literal['center','all_touched','fractional'] |None) – Select cells by center, include all touched cells, or weight by covered area. Without a fixed neighborhood, the default isfractional.area_weighting (
Literal['diagonal_bounds','intersection']) – For fractional reductions,diagonal_boundsweights the rectangle between two transformed diagonal corners. At the source boundary, its outer row or column also receives weight for the area extending beyond the raster.intersectionweights only the overlap of each source cell with the transformed four-corner destination polygon. Sums use the polygon in either mode.
- Return type:
- Returns:
Reprojected raster.