cf_xarray.shapely_to_cf#
- cf_xarray.shapely_to_cf(geometries, grid_mapping=None)[source]#
Convert a DataArray with shapely geometry objects into a CF-compliant dataset.
Warning
Only point geometries are currently implemented.
- 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”.
Warning
Only the longitude_latitude grid mapping is currently implemented.
- 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. Absent if all instances are Points.
‘geometry_container’ : Empty variable with attributes describing the geometry type.
Other variables are not implemented as only Points are currently understood.
References
Please refer to the CF conventions document: http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#geometries