Commit af209d2 1 parent c17bc4d commit af209d2 Copy full SHA for af209d2
File tree 2 files changed +17
-14
lines changed
2 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
+ import copy
3
4
from collections .abc import Sequence
4
5
5
6
import numpy as np
8
9
9
10
GEOMETRY_CONTAINER_NAME = "geometry_container"
10
11
12
+ __all__ = [
13
+ "decode_geometries" ,
14
+ "encode_geometries" ,
15
+ "cf_to_shapely" ,
16
+ "shapely_to_cf" ,
17
+ ]
18
+
11
19
12
20
def decode_geometries (encoded : xr .Dataset ) -> xr .Dataset :
13
21
"""
14
- Decodes CF encoded geometries to a numpy object array
15
- containing shapely geometries.
22
+ Decode CF encoded geometries to a numpy object array containing shapely geometries.
16
23
17
24
Parameters
18
25
----------
19
- encoded: Dataset
26
+ encoded : Dataset
20
27
A Xarray Dataset containing encoded geometries.
21
28
22
29
Returns
@@ -74,14 +81,9 @@ def decode_geometries(encoded: xr.Dataset) -> xr.Dataset:
74
81
return decoded
75
82
76
83
77
- import copy
78
-
79
- GEOMETRY_CONTAINER_NAME = "geometry_container"
80
-
81
-
82
84
def encode_geometries (ds : xr .Dataset ):
83
85
"""
84
- Encodes any discovered geometry variables using the CF conventions.
86
+ Encode any discovered geometry variables using the CF conventions.
85
87
86
88
Practically speaking, geometry variables are numpy object arrays where the first
87
89
element is a shapely geometry.
@@ -93,7 +95,7 @@ def encode_geometries(ds: xr.Dataset):
93
95
94
96
Parameters
95
97
----------
96
- ds: Dataset
98
+ ds : Dataset
97
99
Dataset containing at least one geometry variable.
98
100
99
101
Returns
Original file line number Diff line number Diff line change @@ -8,15 +8,15 @@ kernelspec:
8
8
---
9
9
10
10
``` {eval-rst}
11
- .. currentmodule:: xarray
11
+ .. currentmodule:: cf_xarray
12
12
```
13
13
14
14
# Geometries
15
15
16
16
``` {seealso}
17
17
1. [The CF conventions on Geometries](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.11/cf-conventions.html#geometries)
18
- 1. {py:func}`cf_xarray. shapely_to_cf`
19
- 1. {py:func}`cf_xarray. cf_to_shapely`
18
+ 1. {py:func}`shapely_to_cf`
19
+ 1. {py:func}`cf_to_shapely`
20
20
```
21
21
22
22
` cf_xarray ` can convert between vector geometries represented as shapely objects
@@ -42,6 +42,7 @@ da = xr.DataArray(
42
42
dims=("index",),
43
43
name="geometry"
44
44
)
45
+ da
45
46
```
46
47
47
48
``` {warning}
@@ -73,7 +74,7 @@ ds.identical(decoded)
73
74
74
75
## Lower-level conversions
75
76
76
- Encoding a single DataArray is possible using {py: func }` cf_xarray. geometry.shapely_to_cf` .
77
+ Encoding a single DataArray is possible using {py: func }` geometry.shapely_to_cf ` .
77
78
78
79
``` {code-cell}
79
80
ds_cf = cfxr.shapely_to_cf(da)
You can’t perform that action at this time.
0 commit comments