Skip to content

Commit 3f85bfb

Browse files
authored
release(v0.2.8)
v0.2.8
2 parents d1bc03f + 0032252 commit 3f85bfb

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.8] - 2024-09-23
8+
9+
### Added
10+
11+
- `buffer_meters` is available in the `datacube.ed.zonal_stats` function.
12+
13+
### Fixed
14+
15+
- `bbox` argument in datacube has been restored.
16+
717
## [0.2.7] - 2024-08-29
818

919
### Changed

earthdaily/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# to hide warnings from rioxarray or nano seconds conversion
88
# warnings.filterwarnings("ignore")
99

10-
__version__ = "0.2.7"
10+
__version__ = "0.2.8"
1111

1212

1313
def EarthDataStore(

earthdaily/earthdatastore/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,9 @@ def datacube(
943943
# query the items
944944
items = self.search(
945945
collections=collections,
946-
bbox=list(cube_utils.GeometryManager(intersects).to_bbox()),
947-
# intersects=intersects,
946+
bbox=list(cube_utils.GeometryManager(intersects).to_bbox())
947+
if bbox is None
948+
else bbox,
948949
datetime=datetime,
949950
assets=assets,
950951
prefer_alternate=prefer_alternate,
@@ -989,10 +990,11 @@ def datacube(
989990
xr_datacube = xr_datacube.ed.clip(intersects)
990991
# Create mask datacube and apply it to xr_datacube
991992
if mask_with:
992-
kwargs["dtype"] = "int8"
993993
if "geobox" not in kwargs:
994994
kwargs["geobox"] = xr_datacube.odc.geobox
995-
995+
kwargs.pop("crs", "")
996+
kwargs.pop("resolution", "")
997+
kwargs["dtype"] = "int8"
996998
if clear_cover and mask_statistics is False:
997999
mask_statistics = True
9981000
mask_kwargs = dict(mask_statistics=False)
@@ -1025,11 +1027,6 @@ def datacube(
10251027
]: mask._native_mask_def_mapping[collections[0]]
10261028
}
10271029

1028-
if "resolution" in kwargs:
1029-
kwargs.pop("resolution")
1030-
if "epsg" in kwargs:
1031-
kwargs.pop("epsg")
1032-
10331030
clouds_datacube = datacube(
10341031
items,
10351032
groupby_date=None,

earthdaily/earthdatastore/cube_utils/_zonal.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def zonal_stats(
119119
reducers: list = ["mean"],
120120
all_touched=True,
121121
label=None,
122+
buffer_meters: int | float | None = None,
122123
**kwargs,
123124
):
124125
"""
@@ -174,6 +175,13 @@ def _loop_time_chunks(dataset, method, smart_load, time_chunks):
174175

175176
t_start = time.time()
176177
dataset = dataset.rio.clip_box(*geoms.to_crs(dataset.rio.crs).total_bounds)
178+
if isinstance(buffer_meters, float | int):
179+
input_crs = geoms.crs
180+
geoms = geoms.to_crs({"proj": "cea"})
181+
geoms["geometry_original"] = geoms.geometry
182+
geoms.geometry = geoms.buffer(buffer_meters)
183+
geoms.to_crs(input_crs)
184+
177185
if method == "numpy":
178186
feats, yx_pos = _rasterize(geoms, dataset, all_touched=all_touched)
179187
positions = [np.asarray(yx_pos[i + 1]) for i in np.arange(geoms.shape[0])]
@@ -203,7 +211,8 @@ def _loop_time_chunks(dataset, method, smart_load, time_chunks):
203211
)
204212

205213
# create the WKT geom
206-
214+
if isinstance(buffer_meters, float | int):
215+
geoms.geometry = geoms["geometry_original"]
207216
geometry = xr.DataArray(
208217
list(geoms.iloc[f - 1].to_crs("EPSG:4326").geometry.to_wkt()),
209218
dims=["feature"],

0 commit comments

Comments
 (0)