datacube.utils.geometry.assign_crs#

datacube.utils.geometry.assign_crs(xx, crs=None, crs_coord_name='spatial_ref')[source]#

Assign CRS for a non-georegistered array or dataset.

Returns a new object with CRS information populated.

Can also be called without crs argument on data that already has CRS information but not in the format used by datacube, in this case CRS metadata will be restructured into a shape used by datacube. This format allows for better propagation of CRS information through various computations.

xx = datacube.utils.geometry.assign_crs(xr.open_rasterio("some-file.tif"))
print(xx.geobox)
print(xx.astype('float32').geobox)
Parameters
  • xx (Union[DataArray, Dataset]) – Dataset or DataArray

  • crs (Union[str, CRS, CRS, Dict[str, Any], None]) – CRS to assign, if omitted try to guess from attributes

  • crs_coord_name (str) – how to name crs corodinate (defaults to spatial_ref)

Return type

Union[Dataset, DataArray]