Skip to content

Commit

Permalink
load_stac got a bit more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
jdries committed Apr 19, 2024
1 parent 9cf3797 commit d1c55d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion openeogeotrellis/load_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ def intersects_temporally(interval) -> bool:
builder = builder.withResolution(cell_width)

latlon_bbox = BoundingBox.from_wsen_tuple(itm.bbox,4326) if itm.bbox else None
item_bbox = latlon_bbox
if proj_bbox is not None and proj_epsg is not None:
item_bbox = BoundingBox.from_wsen_tuple(proj_bbox, crs=proj_epsg)
latlon_bbox = item_bbox.reproject(4326)
Expand All @@ -308,7 +309,7 @@ def intersects_temporally(interval) -> bool:
opensearch_client.addFeature(f)


stac_bbox = (latlon_bbox if stac_bbox is None
stac_bbox = (item_bbox if stac_bbox is None
else BoundingBox.from_wsen_tuple(item_bbox.as_polygon().union(stac_bbox.as_polygon()).bounds,
stac_bbox.crs))

Expand Down
12 changes: 6 additions & 6 deletions tests/test_api_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -3860,14 +3860,14 @@ def item_json(path):

ds = xarray.load_dataset(res_path)

assert ds.dims["x"] == 13010
assert ds.dims["y"] == 773
assert ds.dims["x"] == 12987
assert ds.dims["y"] == 767
# TODO: there's a "t" dimension that corresponds to the start_datetime of the two items; is this right?
assert list(ds.data_vars.keys())[1:] == ["B04", "B03", "B02"]
assert ds.coords["x"].values.min() == pytest.approx(572400.000, abs=10)
assert ds.coords["y"].values.min() == pytest.approx(5618660.000, abs=10)
assert ds.coords["x"].values.max() == pytest.approx(702500.000, abs=10)
assert ds.coords["y"].values.max() == pytest.approx(5626390.000, abs=10)
assert ds.coords["x"].values.min() == pytest.approx(572465.000, abs=10)
assert ds.coords["y"].values.min() == pytest.approx(5618675.000, abs=10)
assert ds.coords["x"].values.max() == pytest.approx(702325.000, abs=10)
assert ds.coords["y"].values.max() == pytest.approx(5626335.000, abs=10)

def test_load_stac_from_spatiotemporal_netcdf_job_results(self, api110, urllib_mock, tmp_path):

Expand Down

0 comments on commit d1c55d1

Please sign in to comment.