Skip to content

Commit

Permalink
use antimeridian package for creating bbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Varner committed Dec 13, 2023
1 parent 82c2dbc commit 101f180
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 40 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]: <https://github.com/stactools-packages/sentinel2/compare/v0.4.2..main> -->
[Unreleased]: <https://github.com/stactools-packages/sentinel2/compare/v0.4.2..main>
[0.5.0]: <https://github.com/stactools-packages/sentinel2/compare/v0.4.2..v0.5.0>
[0.4.2]: <https://github.com/stactools-packages/sentinel2/compare/v0.4.1..v0.4.2>
[0.4.1]: <https://github.com/stactools-packages/sentinel2/compare/v0.4.0..v0.4.1>
Expand Down
2 changes: 2 additions & 0 deletions scripts/create_expected.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

from pathlib import Path

from stactools.sentinel2 import stac
Expand Down
8 changes: 4 additions & 4 deletions src/stactools/sentinel2/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -791,9 +791,9 @@
}
},
"bbox": [
-179.71667,
179.256949,
-16.351724,
180.0,
-179.70343,
-15.345454
],
"stac_extensions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1712,9 +1712,9 @@
}
},
"bbox": [
-179.0443,
178.474107,
65.67165,
180.0,
-178.96619,
66.7056
],
"stac_extensions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1710,9 +1710,9 @@
}
},
"bbox": [
-179.0443,
178.474107,
65.67165,
180.0,
-178.96619,
66.7056
],
"stac_extensions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1740,9 +1740,9 @@
}
},
"bbox": [
-179.93085,
179.0059,
68.372483,
180.0,
-179.197,
69.394461
],
"stac_extensions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1712,9 +1712,9 @@
}
},
"bbox": [
-179.72957,
179.23921,
-17.25485,
180.0,
-179.71545,
-16.247763
],
"stac_extensions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 101f180

Please sign in to comment.