From 101f18008f9b98d3fc52fa41462093a05dc84155 Mon Sep 17 00:00:00 2001 From: Phil Varner Date: Wed, 13 Dec 2023 10:15:39 -0500 Subject: [PATCH] use antimeridian package for creating bbox --- CHANGELOG.MD | 8 +++++++- scripts/create_expected.py | 2 ++ src/stactools/sentinel2/stac.py | 8 ++++---- .../expected_output.json | 6 +++--- .../expected_output.json | 6 +++--- .../expected_output.json | 6 +++--- .../expected_output.json | 6 +++--- .../expected_output.json | 6 +++--- .../expected_output.json | 10 +++++----- .../expected_output.json | 10 +++++----- .../expected_output.json | 10 +++++----- .../expected_output.json | 10 +++++----- 12 files changed, 48 insertions(+), 40 deletions(-) mode change 100644 => 100755 scripts/create_expected.py diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 02f6a7f..5080e01 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project attempts to match the major and minor versions of [stactools](https://github.com/stac-utils/stactools) and increments the patch number as needed. +## [Unreleased] - TBD + +### Fixed + +- Antimeridian-crossing scene bboxes + ## [0.5.0] - 2023-12-01 ### Added @@ -97,7 +103,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Modified Item IDs to include product discriminator ([#7](https://github.com/stactools-packages/sentinel2/pull/7)) - Upgrade to stactools 0.2.1.a2 (supporting PySTAC 1.0.0) - +[Unreleased]: [0.5.0]: [0.4.2]: [0.4.1]: diff --git a/scripts/create_expected.py b/scripts/create_expected.py old mode 100644 new mode 100755 index 91af74f..c7618e9 --- a/scripts/create_expected.py +++ b/scripts/create_expected.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + from pathlib import Path from stactools.sentinel2 import stac diff --git a/src/stactools/sentinel2/stac.py b/src/stactools/sentinel2/stac.py index fab162a..3375bb5 100644 --- a/src/stactools/sentinel2/stac.py +++ b/src/stactools/sentinel2/stac.py @@ -138,14 +138,14 @@ def create_item( created = now_to_rfc3339_str() # ensure that we have a valid geometry, fixing any antimeridian issues - geometry = shapely_mapping( - make_valid(shapely_shape(antimeridian.fix_shape(metadata.geometry))) - ) + shapely_geometry = shapely_shape(antimeridian.fix_shape(metadata.geometry)) + geometry = shapely_mapping(make_valid(shapely_geometry)) + bbox = [round(v, COORD_ROUNDING) for v in antimeridian.bbox(geometry)] item = pystac.Item( id=metadata.scene_id, geometry=geometry, - bbox=metadata.bbox, + bbox=bbox, datetime=metadata.datetime, properties={"created": created}, ) diff --git a/tests/data-files/S2A_MSIL1C_20200717T221941_R029_T01LAC_20200717T234135.SAFE/expected_output.json b/tests/data-files/S2A_MSIL1C_20200717T221941_R029_T01LAC_20200717T234135.SAFE/expected_output.json index 8fb3491..2a0c30d 100644 --- a/tests/data-files/S2A_MSIL1C_20200717T221941_R029_T01LAC_20200717T234135.SAFE/expected_output.json +++ b/tests/data-files/S2A_MSIL1C_20200717T221941_R029_T01LAC_20200717T234135.SAFE/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_T01LAC_20200717T221944_L1C", "properties": { - "created": "2023-11-20T17:22:07.294960Z", + "created": "2023-12-13T15:10:35.662528Z", "providers": [ { "name": "ESA", @@ -791,9 +791,9 @@ } }, "bbox": [ - -179.71667, + 179.256949, -16.351724, - 180.0, + -179.70343, -15.345454 ], "stac_extensions": [ diff --git a/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCP_20230626T022157.SAFE/expected_output.json b/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCP_20230626T022157.SAFE/expected_output.json index d796d2c..495bfa4 100644 --- a/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCP_20230626T022157.SAFE/expected_output.json +++ b/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCP_20230626T022157.SAFE/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_T01WCP_20230625T234624_L2A", "properties": { - "created": "2023-11-20T17:22:06.726429Z", + "created": "2023-12-13T15:10:35.151115Z", "providers": [ { "name": "ESA", @@ -1712,9 +1712,9 @@ } }, "bbox": [ - -179.0443, + 178.474107, 65.67165, - 180.0, + -178.96619, 66.7056 ], "stac_extensions": [ diff --git a/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCP_20230626T022158.SAFE/expected_output.json b/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCP_20230626T022158.SAFE/expected_output.json index eba5dcd..31d369e 100644 --- a/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCP_20230626T022158.SAFE/expected_output.json +++ b/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCP_20230626T022158.SAFE/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_T01WCP_20230625T234624_L2A", "properties": { - "created": "2023-11-20T17:22:07.028165Z", + "created": "2023-12-13T15:10:35.432011Z", "providers": [ { "name": "ESA", @@ -1710,9 +1710,9 @@ } }, "bbox": [ - -179.0443, + 178.474107, 65.67165, - 180.0, + -178.96619, 66.7056 ], "stac_extensions": [ diff --git a/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCS_20230626T022157.SAFE/expected_output.json b/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCS_20230626T022157.SAFE/expected_output.json index ea5c290..d5d1ad1 100644 --- a/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCS_20230626T022157.SAFE/expected_output.json +++ b/tests/data-files/S2A_MSIL2A_20230625T234621_N0509_R073_T01WCS_20230626T022157.SAFE/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_T01WCS_20230625T234624_L2A", "properties": { - "created": "2023-11-20T17:22:07.138030Z", + "created": "2023-12-13T15:10:35.529969Z", "providers": [ { "name": "ESA", @@ -1740,9 +1740,9 @@ } }, "bbox": [ - -179.93085, + 179.0059, 68.372483, - 180.0, + -179.197, 69.394461 ], "stac_extensions": [ diff --git a/tests/data-files/S2A_MSIL2A_20230821T221941_N0509_R029_T01KAB_20230822T021825.SAFE/expected_output.json b/tests/data-files/S2A_MSIL2A_20230821T221941_N0509_R029_T01KAB_20230822T021825.SAFE/expected_output.json index 47d605b..62be381 100644 --- a/tests/data-files/S2A_MSIL2A_20230821T221941_N0509_R029_T01KAB_20230822T021825.SAFE/expected_output.json +++ b/tests/data-files/S2A_MSIL2A_20230821T221941_N0509_R029_T01KAB_20230822T021825.SAFE/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_T01KAB_20230821T221944_L2A", "properties": { - "created": "2023-11-20T17:22:06.799537Z", + "created": "2023-12-13T15:10:35.226345Z", "providers": [ { "name": "ESA", @@ -1712,9 +1712,9 @@ } }, "bbox": [ - -179.72957, + 179.23921, -17.25485, - 180.0, + -179.71545, -16.247763 ], "stac_extensions": [ diff --git a/tests/data-files/S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG/expected_output.json b/tests/data-files/S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG/expected_output.json index 63e49ab..19c7281 100644 --- a/tests/data-files/S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG/expected_output.json +++ b/tests/data-files/S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_OPER_MSI_L1C_TL_SGS__20181231T203637_A018414_T10SDG", "properties": { - "created": "2023-11-20T17:22:07.346802Z", + "created": "2023-12-13T15:10:35.705354Z", "providers": [ { "name": "ESA", @@ -721,10 +721,10 @@ } }, "bbox": [ - -123.77120008096219, - 36.95538583284048, - -122.88892538947995, - 37.94752813015373 + -123.7712, + 36.955386, + -122.888925, + 37.947528 ], "stac_extensions": [ "https://stac-extensions.github.io/eo/v1.1.0/schema.json", diff --git a/tests/data-files/S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG/expected_output.json b/tests/data-files/S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG/expected_output.json index 64cc19a..e12803e 100644 --- a/tests/data-files/S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG/expected_output.json +++ b/tests/data-files/S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_OPER_MSI_L2A_TL_SGS__20181231T210250_A018414_T10SDG", "properties": { - "created": "2023-11-20T17:22:07.092086Z", + "created": "2023-12-13T15:10:35.489434Z", "providers": [ { "name": "ESA", @@ -1783,10 +1783,10 @@ } }, "bbox": [ - -123.77120008096219, - 36.95538583284048, - -122.88892538947995, - 37.94752813015373 + -123.7712, + 36.955386, + -122.888925, + 37.947528 ], "stac_extensions": [ "https://stac-extensions.github.io/eo/v1.1.0/schema.json", diff --git a/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP/expected_output.json b/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP/expected_output.json index 957002b..bc5bcf6 100644 --- a/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP/expected_output.json +++ b/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBP", "properties": { - "created": "2023-11-20T17:22:06.388489Z", + "created": "2023-12-13T15:10:34.067362Z", "providers": [ { "name": "ESA", @@ -1783,10 +1783,10 @@ } }, "bbox": [ - 18.837533655044183, - -10.048676709777588, - 19.26487070909741, - -9.943916470908118 + 18.837534, + -10.048677, + 19.264871, + -9.943916 ], "stac_extensions": [ "https://stac-extensions.github.io/eo/v1.1.0/schema.json", diff --git a/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBQ/expected_output.json b/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBQ/expected_output.json index 3a499df..3b7977a 100644 --- a/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBQ/expected_output.json +++ b/tests/data-files/S2A_OPER_MSI_L2A_TL_VGS1_20220401T110010_A035382_T34LBQ/expected_output.json @@ -3,7 +3,7 @@ "stac_version": "1.0.0", "id": "S2A_T34LBQ_20220401T090142_L2A", "properties": { - "created": "2023-11-20T17:22:06.849436Z", + "created": "2023-12-13T15:10:35.272511Z", "providers": [ { "name": "ESA", @@ -1796,10 +1796,10 @@ } }, "bbox": [ - 18.837533655044183, - -10.048676709777588, - 19.26487070909741, - -9.943916470908118 + 18.837534, + -10.048677, + 19.264871, + -9.943916 ], "stac_extensions": [ "https://stac-extensions.github.io/eo/v1.1.0/schema.json",