Commit c17bc4d 1 parent f21cecd commit c17bc4d Copy full SHA for c17bc4d
File tree 3 files changed +37
-2
lines changed
3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 9
9
from .options import set_options # noqa
10
10
from .utils import _get_version
11
11
12
+ from . import geometry # noqa
13
+
12
14
__version__ = _get_version ()
Original file line number Diff line number Diff line change @@ -17,6 +17,16 @@ Top-level API
17
17
encode_multi_index_as_compress
18
18
decode_compress_to_multi_index
19
19
20
+ Geometries
21
+ ----------
22
+ .. autosummary ::
23
+ :toctree: generated/
24
+
25
+ geometry.decode_geometries
26
+ geometry.encode_geometries
27
+ geometry.shapely_to_cf
28
+ geometry.cf_to_shapely
29
+
20
30
.. currentmodule :: xarray
21
31
22
32
DataArray
Original file line number Diff line number Diff line change @@ -50,7 +50,30 @@ da = xr.DataArray(
50
50
geometries of the same type.
51
51
```
52
52
53
- Now we can take that ` xr.DataArray ` containing shapely geometries and convert it to cf:
53
+ ## Encode / Decode
54
+
55
+ ` cf-xarray ` provides {py: func }` geometry.encode_geometries ` and {py: func }` geometry.decode_geometries ` to
56
+ encode and decode xarray Datasets to/from a CF-compliant form that can be written to any array storage format.
57
+
58
+ For example:
59
+
60
+ ``` {code-cell}
61
+ ds = da.to_dataset()
62
+ encoded = cfxr.geometry.encode_geometries(ds)
63
+ encoded
64
+ ```
65
+
66
+ This dataset can then be written to any format supported by Xarray.
67
+ To decode, reverse the process using {py: func }` geometry.decode_geometries `
68
+
69
+ ``` {code-cell}
70
+ decoded = cfxr.geometry.decode_geometries(encoded)
71
+ ds.identical(decoded)
72
+ ```
73
+
74
+ ## Lower-level conversions
75
+
76
+ Encoding a single DataArray is possible using {py: func }` cf_xarray.geometry.shapely_to_cf ` .
54
77
55
78
``` {code-cell}
56
79
ds_cf = cfxr.shapely_to_cf(da)
@@ -94,6 +117,6 @@ By default these are called `crd_x` and `crd_y` unless `grid_mapping` is specifi
94
117
95
118
For MultiPolygons with holes the CF notation is slightly ambiguous on which hole is associated
96
119
with which polygon. This is problematic because shapely stores holes within the polygon
97
- object that they are associated with. ` cf_xarray ` assumes that the the shapes are interleaved
120
+ object that they are associated with. ` cf_xarray ` assumes that the shapes are interleaved
98
121
such that the holes (interior rings) are associated with the exteriors (exterior rings) that
99
122
immediately precede them.
You can’t perform that action at this time.
0 commit comments