cf_xarray.geometry.shapely_to_cf¶
- cf_xarray.geometry.shapely_to_cf(geometries, grid_mapping=None, *, suffix='')[source]¶
Convert a DataArray with shapely geometry objects into a CF-compliant dataset.
- Parameters:
- geometriessequence of shapely geometries or xarray.DataArray
A sequence of geometry objects or a Dataset with a “geometry” variable storing such geometries. All geometries must be of the same base type : Point, Line or Polygon, but multipart geometries are accepted.
- grid_mappingstr, optional
A CF grid mapping name. When given, coordinates and attributes are named and set accordingly. Defaults to None, in which case the coordinates are simply names “crd_x” and “crd_y”.
- container_name: str, optional
Name for the “geometry container” scalar variable in the encoded Dataset
- Returns:
- xr.Dataset
- A dataset with shapely geometry objects translated into CF-compliant variables :
‘x’, ‘y’ : the node coordinates
‘crd_x’, ‘crd_y’ : the feature coordinates (might have different names if grid_mapping is available).
‘node_count’ : The number of nodes per feature. Always present for Lines and Polygons. For Points: only present if there are multipart geometries.
‘part_node_count’ : The number of nodes per individual geometry. Only for Lines with multipart geometries and for Polygons with multipart geometries or holes.
‘interior_ring’ : Integer boolean indicating whether rings are interior or exterior. Only for Polygons with holes.
container_name : Empty variable with attributes describing the geometry type.
References
Please refer to the CF conventions document: http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#geometries