File tree 2 files changed +12
-12
lines changed
earthdatastore/cube_utils
2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -335,10 +335,8 @@ def whittaker(
335
335
max_iter = max_iter ,
336
336
)
337
337
338
- def zonal_stats (
339
- self ,
340
- geometry ,
341
- operations :list = ['mean' ]):
338
+ def zonal_stats (self , geometry , operations : list = ["mean" ]):
342
339
from ..earthdatastore .cube_utils import zonal_stats , GeometryManager
343
- geometry = GeometryManager (geometry ).to_geopandas ()
344
- return zonal_stats (self ._obj , geometry , operations = operations )
340
+
341
+ geometry = GeometryManager (geometry ).to_geopandas ()
342
+ return zonal_stats (self ._obj , geometry , operations = operations )
Original file line number Diff line number Diff line change @@ -110,18 +110,20 @@ def zonal_stats(
110
110
method = "geocube" ,
111
111
verbose = False ,
112
112
):
113
- if method == ' geocube' :
113
+ if method == " geocube" :
114
114
from geocube .api .core import make_geocube
115
- gdf ['feature' ] = list (gdf .index )
115
+
116
+ gdf ["feature" ] = list (gdf .index )
116
117
out_grid = make_geocube (
117
118
gdf ,
118
119
measurements = ["feature" ],
119
- like = dataset # ensure the data are on the same grid
120
+ like = dataset , # ensure the data are on the same grid
120
121
)
121
122
cube = dataset .groupby (out_grid .feature )
122
- zonal_stats = xr .concat ([
123
- getattr (cube , operation )() for operation in operations ], dim = 'stats' )
124
- zonal_stats ['stats' ] = operations
123
+ zonal_stats = xr .concat (
124
+ [getattr (cube , operation )() for operation in operations ], dim = "stats"
125
+ )
126
+ zonal_stats ["stats" ] = operations
125
127
return zonal_stats
126
128
tqdm_bar = tqdm .tqdm (total = gdf .shape [0 ])
127
129
You can’t perform that action at this time.
0 commit comments