xugrid.Ugrid2d.write_grid_mapping#
- Ugrid2d.write_grid_mapping(dataset, grid_mapping_name: str = None)#
Use the CRS of the topology, if set, to write the CF grid_mapping attributes to a newly created mapping variable.
The grid mapping variable is stamped onto all data variables that share dimensions with this topology via the
grid_mappingattribute, following CF conventions. Additionally, coordinate variables are also stamped, which is not strictly CF-compliant but is required for compatibility for e.g. QGIS-MDAL, which readsgrid_mappingfrom coordinates rather than data variables.- Parameters:
dataset (xr.Dataset)
grid_mapping_name (str, optional) – Name of the CF grid mapping variable. If not provided (or None), defaults to
f"{self.name}_crs"for this topology.
- Returns:
dataset – Modified dataset with CF compliant CRS information.
- Return type:
xr.Dataset