Skip to content

Fix indexer chip geometry #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions stacchip/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def crs(self) -> CRS:
return CRS.from_epsg(self.item.properties["proj:epsg"])
elif "proj:wkt2" in self.item.properties:
return CRS.from_string(self.item.properties["proj:wkt2"])
elif "proj:code" in self.item.properties:
return CRS.from_string(self.item.properties["proj:code"])
else:
raise ValueError("Could not identify CRS of source files")

Expand Down Expand Up @@ -97,8 +99,14 @@ def _get_trsf_or_shape(self, key: str) -> list:
for asset in self.item.assets.values():
if key not in asset.extra_fields:
continue
if not data or data[0] < asset.extra_fields[key][0]:
data = asset.extra_fields[key]
# Get largest shape or smallest transform (scaling).
if "shape" in key:
if not data or data[0] < asset.extra_fields[key][0]:
data = asset.extra_fields[key]
else:
if not data or data[0] > asset.extra_fields[key][0]:
data = asset.extra_fields[key]

if not data:
raise ValueError("Could not determine {key} for this STAC item")

Expand Down