Skip to content

Commit

Permalink
release(v0.2.8)
Browse files Browse the repository at this point in the history
v0.2.8
  • Loading branch information
nkarasiak authored Sep 23, 2024
2 parents d1bc03f + 0032252 commit 3f85bfb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.8] - 2024-09-23

### Added

- `buffer_meters` is available in the `datacube.ed.zonal_stats` function.

### Fixed

- `bbox` argument in datacube has been restored.

## [0.2.7] - 2024-08-29

### Changed
Expand Down
2 changes: 1 addition & 1 deletion earthdaily/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# to hide warnings from rioxarray or nano seconds conversion
# warnings.filterwarnings("ignore")

__version__ = "0.2.7"
__version__ = "0.2.8"


def EarthDataStore(
Expand Down
15 changes: 6 additions & 9 deletions earthdaily/earthdatastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,9 @@ def datacube(
# query the items
items = self.search(
collections=collections,
bbox=list(cube_utils.GeometryManager(intersects).to_bbox()),
# intersects=intersects,
bbox=list(cube_utils.GeometryManager(intersects).to_bbox())
if bbox is None
else bbox,
datetime=datetime,
assets=assets,
prefer_alternate=prefer_alternate,
Expand Down Expand Up @@ -989,10 +990,11 @@ def datacube(
xr_datacube = xr_datacube.ed.clip(intersects)
# Create mask datacube and apply it to xr_datacube
if mask_with:
kwargs["dtype"] = "int8"
if "geobox" not in kwargs:
kwargs["geobox"] = xr_datacube.odc.geobox

kwargs.pop("crs", "")
kwargs.pop("resolution", "")
kwargs["dtype"] = "int8"
if clear_cover and mask_statistics is False:
mask_statistics = True
mask_kwargs = dict(mask_statistics=False)
Expand Down Expand Up @@ -1025,11 +1027,6 @@ def datacube(
]: mask._native_mask_def_mapping[collections[0]]
}

if "resolution" in kwargs:
kwargs.pop("resolution")
if "epsg" in kwargs:
kwargs.pop("epsg")

clouds_datacube = datacube(
items,
groupby_date=None,
Expand Down
11 changes: 10 additions & 1 deletion earthdaily/earthdatastore/cube_utils/_zonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def zonal_stats(
reducers: list = ["mean"],
all_touched=True,
label=None,
buffer_meters: int | float | None = None,
**kwargs,
):
"""
Expand Down Expand Up @@ -174,6 +175,13 @@ def _loop_time_chunks(dataset, method, smart_load, time_chunks):

t_start = time.time()
dataset = dataset.rio.clip_box(*geoms.to_crs(dataset.rio.crs).total_bounds)
if isinstance(buffer_meters, float | int):
input_crs = geoms.crs
geoms = geoms.to_crs({"proj": "cea"})
geoms["geometry_original"] = geoms.geometry
geoms.geometry = geoms.buffer(buffer_meters)
geoms.to_crs(input_crs)

if method == "numpy":
feats, yx_pos = _rasterize(geoms, dataset, all_touched=all_touched)
positions = [np.asarray(yx_pos[i + 1]) for i in np.arange(geoms.shape[0])]
Expand Down Expand Up @@ -203,7 +211,8 @@ def _loop_time_chunks(dataset, method, smart_load, time_chunks):
)

# create the WKT geom

if isinstance(buffer_meters, float | int):
geoms.geometry = geoms["geometry_original"]
geometry = xr.DataArray(
list(geoms.iloc[f - 1].to_crs("EPSG:4326").geometry.to_wkt()),
dims=["feature"],
Expand Down

0 comments on commit 3f85bfb

Please sign in to comment.