lair.geo.write_rio_crs#
- lair.geo.write_rio_crs(data, crs)[source]#
Write the CRS and coordinate system to the rioxarray accessor.
- Parameters:
data (DataArray | Dataset) – The data to write the CRS to.
crs (Any) – The CRS to write to the data.
- Returns:
DataArray | Dataset – The data with the CRS written to the rioxarray accessor.
- Return type:
_XarrayT
See also
CRSThe CRS it takes.
gridcell_areaNeeds the CRS it writes.
Examples
>>> import numpy as np >>> import xarray as xr >>> from lair.geo import write_rio_crs >>> data = xr.DataArray( ... np.zeros((2, 2)), ... coords={"lat": [40.65, 40.75], "lon": [-111.95, -111.85]}, ... dims=("lat", "lon"), ... ).rio.set_spatial_dims(x_dim="lon", y_dim="lat") >>> write_rio_crs(data, "EPSG:4326").rio.crs.to_epsg() 4326