Skip to content

Commit

Permalink
perf(datacube) : chunks and geobox/geopolygon. Close #26
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasK committed Dec 8, 2023
1 parent 5d838a5 commit 8b6ce0e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
35 changes: 21 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ 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.0.1]

### Changed

- Default chunks using odc is now `x="auto"` and `y="auto"`.
- `geobox` or `geopolygon` is used to have a preclipped datacube to the bounding box of the geometry. It enhances performances.

## [0.0.1-rc8] - 2023-07-12

### Added
Expand All @@ -13,21 +20,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- handle cross calibration (harmonization) using private collection.
- `Auth` automatically to EarhtDataStore after 3600 seconds.
- `Auth` now supports presign_urls parameter.
- `load_pivot_corumba` in datasets
- `load_pivot_corumba` in datasets.

### Fixed

- Perfect dimension compatibility between cloudmask and sensor datacube using `geobox` .
- Perfect dimension compatibility between cloudmask and sensor datacube using `geobox`.
- Force loading native landsat cloudmask because not compatible with dask.

## [0.0.1-rc7] - 2023-11-22

### Fixed

- issue with unlogged datacube and non-geodataframe intersects
- for element84 sentinel-2-l2a collection, `boa_offset_applied`is set to True since 2022-02-28
- added `nir` band in `boa_offset_applied` control
- fix percentage in landsat agriculture cloudmask
- issue with unlogged datacube and non-geodataframe intersects.
- for element84 sentinel-2-l2a collection, `boa_offset_applied`is set to True since 2022-02-28.
- added `nir` band in `boa_offset_applied` control.
- fix percentage in landsat agriculture cloudmask .

## [0.0.1-rc6] - 2023-11-10

Expand All @@ -39,7 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `intersects` argument in search/datacube now supports wkt/geojson/geopandas
- `intersects` argument in search/datacube now supports wkt/geojson/geopandas.
- `common_band_names` default set to True in datacube creation. It uses the new Assets Mapper in order to define to best suitable bands according to user needs.
- `clear_cover` argument in the datacube method when using the `earthdatastore.Auth` method.
- `datasets.load_pivot()` to load a GeoDataFrame of a pivot in Nebraska (alternates between corn or soy between years).
Expand Down Expand Up @@ -103,16 +110,16 @@ really faster faster. Previous behavior is available by selecting `method="stand

### Changed

- Python version must be at least 3.10
- Gdal version must be at least 3.7.0
- A better documentation
- Python version must be at least 3.10.
- Gdal version must be at least 3.7.0.
- A better documentation.


## [0.0.1-beta] 2023-09-20

### Added

- First public release under the name of earthdaily
- module earthdatastore gathers all cube fonctions
- earthdatastore.Auth() allows methods for search and datacube creation
- Add if missing default scale/offset factor to collection (landsat-c2l2-sr, landsat-c2l2-st, landsat-c2l1)
- First public release under the name of earthdaily.
- module earthdatastore gathers all cube fonctions.
- earthdatastore.Auth() allows methods for search and datacube creation.
- Add if missing default scale/offset factor to collection (landsat-c2l2-sr, landsat-c2l2-st, landsat-c2l1).
2 changes: 1 addition & 1 deletion earthdaily/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import earthdatastore, datasets

__version__ = "0.0.1-rc8"
__version__ = "0.0.1"
11 changes: 7 additions & 4 deletions earthdaily/earthdatastore/cube_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ def _cube_odc(items_collection, assets=None, times=None, dtype="float32", **kwar
if "resampling" in kwargs:
if isinstance(kwargs["resampling"], int):
kwargs["resampling"] = Resampling(kwargs["resampling"]).name
kwargs["chunks"] = kwargs.get("chunks", dict(x=512, y=512, time=1))

kwargs["chunks"] = kwargs.get("chunks", dict(x="auto", y="auto", time=1))
if "geobox" in kwargs.keys() and "geopolygon" in kwargs.keys():
kwargs.pop("geobox")
ds = stac.load(
items_collection,
bands=assets,
Expand Down Expand Up @@ -123,6 +124,8 @@ def datacube(
assets = aM.map_collection_assets(items_collection[0].collection_id, assets)
if isinstance(assets, dict):
assets_keys = list(assets.keys())
if engine == 'odc' and intersects is not None:
kwargs['geopolygon'] = intersects
ds = engines[engine](
items_collection,
assets=assets_keys if isinstance(assets, dict) else assets,
Expand Down Expand Up @@ -165,9 +168,9 @@ def datacube(
intersects = GeometryManager(intersects).to_geopandas()

if isinstance(intersects, gpd.GeoDataFrame):
# itrscts = intersects.to_crs(ds.rio.crs).iloc[[0]]
# optimize by perclipping using bbox
ds = ds.rio.clip_box(*intersects.to_crs(ds.rio.crs).total_bounds)
# no need anymore thanks to geobox/geopolygon in doc
# ds = ds.rio.clip_box(*intersects.to_crs(ds.rio.crs).total_bounds)
ds = ds.rio.clip(intersects.to_crs(ds.rio.crs).geometry)
# apply nodata
ds = _apply_nodata(ds, nodatas)
Expand Down

0 comments on commit 8b6ce0e

Please sign in to comment.