collocate#

collocate(reference: Union[Dataset, DataArray], other: Union[Dataset, DataArray], resampling: Resampling = Resampling.nearest) Union[Dataset, DataArray][source]#

Collocate two georeferenced arrays: forces the other raster to be exactly georeferenced onto the reference raster by reprojection.

>>> reference_path = "path/to/reference.tif"
>>> other_path = "path/to/other.tif"
>>> col_path = "path/to/collocated.tif"

>>> # Collocate the other to the reference
>>> col_xds = collocate(read(reference_path), read(other_path), Resampling.bilinear)

>>> # Write it
>>> write(col_xds, col_path)
Parameters:
  • reference (XDS_TYPE) – Reference xarray

  • other (XDS_TYPE) – Other xarray

  • resampling (Resampling) – Resampling method

Returns:

Collocated xarray

Return type:

XDS_TYPE