xarray.DataArray.proj.assign_crs

xarray.DataArray.proj.assign_crs#

DataArray.proj.assign_crs(spatial_ref_crs=None, allow_override=False, **spatial_ref_crs_kwargs)#

Assign one or more spatial reference coordinate variables, each with a given coordinate reference system (CRS).

Doesn’t trigger any coordinate transformation or data resampling.

Parameters:
  • spatial_ref_crs (dict-like or None, optional) – A dict where the keys are the names of the (scalar) coordinate variables and values target CRS in any format accepted by pyproj.CRS.from_user_input() such as an authority string (e.g. "EPSG:4326"), EPSG code (e.g. 4326) or a WKT string. If the coordinate(s) doesn’t exist it will be created.

  • allow_override (bool, default False) – Allow to replace the index if the coordinates already have an index.

  • **spatial_ref_crs_kwargs (optional) – The keyword arguments form of spatial_ref_crs. One of spatial_ref_crs or spatial_ref_crs_kwargs must be provided.

Returns:

Dataset or DataArray – A new Dataset or DataArray object with new or updated spatial reference coordinate variables.