Skip to content

Commit 253ecbe

Browse files
committed
Cleanup based on PR comments.
1 parent 498e72b commit 253ecbe

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

odc/stac/_mdtools.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,16 +501,19 @@ def extract(self, md: Any) -> RasterGroupMetadata:
501501
item = md
502502
c = self._config(item.collection_id)
503503

504-
# Ignore non-proj data bands when Item has proj extension, unless user
505-
# disabled that filter with `ignore_proj=True` option
506-
check_proj = has_proj_ext(item) and not c.ignore_proj
507-
508504
def _keep(kv: tuple[str, pystac.asset.Asset], check_proj: bool) -> bool:
509505
name, asset = kv
510506
if name in c.band_cfg:
511507
return True
512508
return is_raster_data(asset, check_proj=check_proj)
513509

510+
# Ignore non-proj data bands when Item has proj extension, unless user
511+
# disabled that filter with `ignore_proj=True` option
512+
check_proj = (
513+
has_proj_ext(item)
514+
and not c.ignore_proj
515+
and not any(has_proj_data(a) for a in item.assets.values())
516+
)
514517
data_bands = dicttoolz.itemfilter(lambda kv: _keep(kv, check_proj), item.assets)
515518

516519
if len(data_bands) == 0 and check_proj:
@@ -681,8 +684,8 @@ def _bootstrap(self, item: pystac.item.Item) -> None:
681684
has_proj = False
682685

683686
# We assume that grouping of data bands into grids is consistent across
684-
# entire collection, so we compute it once and keep it
685-
if has_proj:
687+
# the entire collection, so we compute it once and keep it
688+
if has_proj and data_assets and any(has_proj_data(a) for a in data_assets.values()):
686689
_, band2grid = compute_eo3_grids(data_assets)
687690
else:
688691
band2grid = band2grid_from_gsd(data_assets)

tests/test_mdtools.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,7 @@ def test_noassets_case(no_bands_stac) -> None:
299299

300300

301301
def test_partial_proj_fallback(partial_proj_stac: pystac.item.Item) -> None:
302-
"""
303-
Test that items declaring proj extension but without per-asset proj data
304-
fall back correctly and don't produce empty datasets.
305-
Regression test for https://github.com/opendatacube/odc-stac/issues/251
306-
"""
302+
# Regression test for https://github.com/opendatacube/odc-stac/issues/251
307303
# Item declares proj extension but assets don't have proj:shape/transform
308304
item = partial_proj_stac
309305
assert has_proj_ext(item) is True

0 commit comments

Comments
 (0)