File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ def is_geom_variable(
123
123
return False
124
124
125
125
@property
126
- def geom_coords (self ) -> Mapping [ Hashable , xr .DataArray ] :
126
+ def geom_coords (self ) -> xr .Coordinates :
127
127
"""Returns a dictionary of xarray.DataArray objects corresponding to
128
128
coordinate variables composed of :class:`shapely.Geometry` objects.
129
129
@@ -168,11 +168,16 @@ def geom_coords(self) -> Mapping[Hashable, xr.DataArray]:
168
168
is_geom_variable
169
169
"""
170
170
return xr .Coordinates (
171
- {
171
+ coords = {
172
172
c : coo
173
173
for c , coo in self ._obj .coords .items ()
174
174
if c in self ._geom_coords_all
175
- }
175
+ },
176
+ indexes = {
177
+ c : self ._obj .xindexes [c ]
178
+ for c in self ._obj .coords
179
+ if c in self ._geom_coords_all and c in self ._obj .xindexes
180
+ },
176
181
)
177
182
178
183
@property
@@ -220,10 +225,16 @@ def geom_coords_indexed(self) -> xr.Coordinates:
220
225
is_geom_variable
221
226
222
227
"""
223
- # TODO: use xarray.Coordinates constructor instead once available in xarray
224
- return self ._obj .drop_vars (
225
- [c for c in self ._obj .coords if c not in self ._geom_indexes ]
226
- ).coords
228
+ return xr .Coordinates (
229
+ coords = {
230
+ c : coo for c , coo in self ._obj .coords .items () if c in self ._geom_indexes
231
+ },
232
+ indexes = {
233
+ c : self ._obj .xindexes [c ]
234
+ for c in self ._obj .coords
235
+ if c in self ._geom_indexes and c in self ._obj .xindexes
236
+ },
237
+ )
227
238
228
239
def to_crs (
229
240
self ,
You can’t perform that action at this time.
0 commit comments