diff --git a/xvec/accessor.py b/xvec/accessor.py index 128a4b0..4ba31c9 100644 --- a/xvec/accessor.py +++ b/xvec/accessor.py @@ -1259,7 +1259,19 @@ def extract_points( return result def encode_cf(self) -> xr.Dataset: - """Encode geometry variables and associated CRS with CF conventions""" + """ + Encode all geometry variables and associated CRS with CF conventions. + + Use this method prior to writing an Xarray dataset to any array format + (e.g. netCDF or Zarr). + + The following invariant is satisfied: + `assert ds.xvec.encode_cf().xvec.decode_cf().identical(ds) is True` + + Returns + ------- + Dataset + """ import cf_xarray as cfxr ds = self._obj.copy() @@ -1308,6 +1320,16 @@ def encode_cf(self) -> xr.Dataset: return encoded def decode_cf(self) -> xr.Dataset: + """ + Decode geometries stored as CF-compliant arrays to shapely geometries. + + The following invariant is satisfied: + `assert ds.xvec.encode_cf().xvec.decode_cf().identical(ds) is True` + + Returns + ------- + Dataset + """ import cf_xarray as cfxr decoded = cfxr.geometry.decode_geometries(self._obj.copy())