odc.geo.xr.ODCExtensionDa.reproject

ODCExtensionDa.reproject(how: SomeCRS | GeoBox, *, resampling: str | int = 'nearest', dst_nodata: float | None = None, resolution: SomeResolution | Literal['auto', 'fit', 'same'] = 'auto', shape: SomeShape | int | None = None, tight: bool = False, anchor: GeoboxAnchor = 'default', tol: float = 0.01, round_resolution: None | bool | Callable[[float, str], float] = None, **kw) XrT

Reproject raster to different projection/resolution.

Parameters:
  • src (TypeVar(XrT, DataArray, Dataset)) – Dataset or DataArray to reproject.

  • how (Union[str, int, CRS, CRS, Dict[str, Any], GeoBox]) – How to reproject the raster. Can be a GeoBox or a CRS (e.g. CRS object or an “ESPG:XXXX” string/integer). If a CRS is provided, the output pixel grid can be customised further via resolution, shape, tight, anchor, tol, round_resolution.

  • resampling (Union[str, int]) – Resampling method to use when reprojecting the raster. Defaults to “nearest”, also supports “average”, “bilinear”, “cubic”, “cubic_spline”, “lanczos”, “mode”, “gauss”, “max”, “min”, “med”, “q1”, “q3”.

  • dst_nodata (Optional[float]) – Set a custom nodata value for the output resampled raster.

  • resolution (Union[float, int, Resolution, Literal['auto', 'fit', 'same']]) –

    • “same” use exactly the same resolution as src

    • ”fit” use center pixel to determine scale change between the two

    • ”auto” is to use the same resolution on the output if CRS units are
      the same between the source and destination and otherwise use “fit”
    • Ignored if shape= is supplied

    • Else resolution in the units of the output crs

  • shape (Union[Tuple[int, int], XY[int], Shape2d, Index2d, int, None]) – Span that many pixels, if it’s a single number then span that many pixels along the longest dimension, other dimension will be computed to maintain roughly square pixels. Takes precedence over resolution= parameter.

  • tight (bool) – By default output pixel grid is adjusted to align pixel edges to X/Y axis, suppling tight=True produces unaligned geobox on the output.

  • anchor (Union[AnchorEnum, XY[float], float, Literal['center'], Literal['centre'], Literal['edge'], Literal['floating'], Literal['default']]) – Control pixel snapping, default is to snap pixel edge to X=0,Y=0. Ignored when tight=True is supplied.

  • tol (float) – Fraction of the output pixel that can be ignored, defaults to 1/100. Bounding box of the output geobox is allowed to be smaller by that amount than transformed footprint of the original.

  • round_resolution (Union[None, bool, Callable[[float, str], float]]) – round_resolution(res: float, units: str) -> float

Return type:

TypeVar(XrT, DataArray, Dataset)

This method uses rasterio.