Skip to content

Commit

Permalink
Fix issue in sentinel 2 metadata where 0 z coordinates are listed.
Browse files Browse the repository at this point in the history
There are some produt metadata files that contain 0 z coordinate
values in the product metadata that is used to construct STAC Item
geometries. This causes the Item geometry to be invalid. This change
modifies the parsing logic to filter out '0' string values in the
coordinates to avoid this issue.
  • Loading branch information
lossyrob authored and gadomski committed Jun 7, 2021
1 parent e1fcbff commit 065ff38
Show file tree
Hide file tree
Showing 4 changed files with 2,389 additions and 4 deletions.
5 changes: 4 additions & 1 deletion stactools_sentinel2/stactools/sentinel2/product_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ def _get_geometries():
ProductMetadataError(
f'Cannot parse footprint from product metadata at {self.href}'
)

# Some coordinates contain a 0 z dimension for some reason;
# filter those out
footprint_coords = [
float(c) for c in footprint_text.split(' ') if c
float(c) for c in footprint_text.split(' ') if c and c != '0'
]
footprint_points = [
p[::-1] for p in list(zip(*[iter(footprint_coords)] * 2))
Expand Down
Loading

0 comments on commit 065ff38

Please sign in to comment.