Skip to content

Commit c88ea9c

Browse files
committed
Add docstring
1 parent 0d40b44 commit c88ea9c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

xvec/accessor.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,19 @@ def extract_points(
12591259
return result
12601260

12611261
def encode_cf(self) -> xr.Dataset:
1262-
"""Encode geometry variables and associated CRS with CF conventions"""
1262+
"""
1263+
Encode all geometry variables and associated CRS with CF conventions.
1264+
1265+
Use this method prior to writing an Xarray dataset to any array format
1266+
(e.g. netCDF or Zarr).
1267+
1268+
The following invariant is satisfied:
1269+
`assert ds.xvec.encode_cf().xvec.decode_cf().identical(ds) is True`
1270+
1271+
Returns
1272+
-------
1273+
Dataset
1274+
"""
12631275
import cf_xarray as cfxr
12641276

12651277
ds = self._obj.copy()
@@ -1308,6 +1320,16 @@ def encode_cf(self) -> xr.Dataset:
13081320
return encoded
13091321

13101322
def decode_cf(self) -> xr.Dataset:
1323+
"""
1324+
Decode geometries stored as CF-compliant arrays to shapely geometries.
1325+
1326+
The following invariant is satisfied:
1327+
`assert ds.xvec.encode_cf().xvec.decode_cf().identical(ds) is True`
1328+
1329+
Returns
1330+
-------
1331+
Dataset
1332+
"""
13111333
import cf_xarray as cfxr
13121334

13131335
decoded = cfxr.geometry.decode_geometries(self._obj.copy())

0 commit comments

Comments
 (0)