File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -19,18 +19,33 @@ def __init__(self, obj: xr.Dataset | xr.DataArray):
19
19
for k , idx in obj .xindexes .items ():
20
20
if isinstance (idx , DGGSIndex ):
21
21
if index is not None :
22
- raise ValueError ("Only one DGGSIndex per object is supported" )
22
+ raise ValueError ("Only one DGGSIndex per dataset or dataarray is supported" )
23
23
index = idx
24
24
name = k
25
25
self ._name = name
26
26
self ._index = index
27
27
28
28
@property
29
29
def index (self ) -> DGGSIndex :
30
+ """Returns the DGGSIndex instance for this Dataset or DataArray.
31
+
32
+ Raise a ``ValueError`` if no such index is found.
33
+ """
30
34
if self ._index is None :
31
35
raise ValueError ("no DGGSIndex found on this Dataset or DataArray" )
32
36
return self ._index
33
37
38
+ @property
39
+ def coord (self ) -> xr .DataArray :
40
+ """Returns the indexed DGGS (cell ids) coordinate as a DataArray.
41
+
42
+ Raise a ``ValueError`` if no such coordinate is found on this Dataset or DataArray.
43
+
44
+ """
45
+ if not self ._name :
46
+ raise ValueError ("no coordinate with a DGGSIndex found on this Dataset or DataArray" )
47
+ return self ._obj [self ._name ]
48
+
34
49
def sel_latlon (
35
50
self , latitude : npt .ArrayLike , longitude : npt .ArrayLike
36
51
) -> xr .Dataset | xr .DataArray :
You can’t perform that action at this time.
0 commit comments