Skip to content

Commit

Permalink
FIX: Upgrade to v2.0.0 of projection STAC extension
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-braun committed Feb 5, 2025
1 parent d3ca8ce commit b7c7ee2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

- FIX: Fix Sentinel-2 Theia footprints when the nodata area is wider than the data area ([#201](https://github.com/sertit/eoreader/issues/201))
- FIX: Pop `driver` keyword in stack function to only use it for writing, allowing people to drive stack as COGs ([#181](https://github.com/sertit/eoreader/issues/181), [#202](https://github.com/sertit/eoreader/discussions/202))
- FIX : Fix import of `SaocomSensorMode` and `TsxProduct` from `eoreader.product`
- FIX: Fix import of `SaocomSensorMode` and `TsxProduct` from `eoreader.product`
- FIX: Upgrade to v2.0.0 of projection STAC extension
- DEPS: Add `tifffile` as a dependency to allow to write COGs with `dask` ([#181](https://github.com/sertit/eoreader/issues/181), [#202](https://github.com/sertit/eoreader/discussions/202))

## 0.21.9 (2024-01-22)
Expand Down
12 changes: 6 additions & 6 deletions ci/weekly/test_stac_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
EO_CC,
GSD,
PROJ_BBOX,
PROJ_EPSG,
PROJ_CODE,
PROJ_GEOMETRY,
PROJ_SHAPE,
PROJ_TRANSFORM,
Expand Down Expand Up @@ -170,7 +170,7 @@ def _test_core(
item.stac_extensions,
[
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/projection/v2.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json",
],
"item.stac_extensions",
Expand All @@ -180,7 +180,7 @@ def _test_core(
item.stac_extensions,
[
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/projection/v2.0.0/schema.json",
],
"item.stac_extensions",
)
Expand Down Expand Up @@ -210,9 +210,9 @@ def _test_core(
f"{DATETIME} (item.properties)",
)
compare(
item.properties[PROJ_EPSG],
prod.crs().to_epsg(),
f"{PROJ_EPSG} (item.properties)",
item.properties[PROJ_CODE],
f"EPSG:{prod.crs().to_epsg()}",
f"{PROJ_CODE} (item.properties)",
)
compare(
item.properties[PROJ_WKT],
Expand Down
4 changes: 2 additions & 2 deletions eoreader/products/stac_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from eoreader import EOREADER_NAME, cache
from eoreader.exceptions import InvalidProductError
from eoreader.products.product import Product
from eoreader.stac import PROJ_EPSG
from eoreader.stac import PROJ_CODE
from eoreader.utils import simplify

try:
Expand Down Expand Up @@ -123,7 +123,7 @@ def crs(self) -> crs.CRS:
Returns:
crs.CRS: CRS object
"""
epsg = self.item.properties.get(PROJ_EPSG)
epsg = self.item.properties.get(PROJ_CODE)

if epsg is None:
def_crs = gpd.GeoDataFrame(
Expand Down
2 changes: 1 addition & 1 deletion eoreader/stac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
PLATFORM,
PROJ_BBOX,
PROJ_CENTROID,
PROJ_EPSG,
PROJ_CODE,
PROJ_GEOMETRY,
PROJ_SHAPE,
PROJ_TRANSFORM,
Expand Down
4 changes: 2 additions & 2 deletions eoreader/stac/_stac_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"INTENSITY",
"COHERENCE",
"PROJ_BBOX",
"PROJ_EPSG",
"PROJ_CODE",
"PROJ_WKT",
"PROJ_SHAPE",
"PROJ_GEOMETRY",
Expand Down Expand Up @@ -132,7 +132,7 @@ class StacCommonNames(ListEnum):
# ---------------- Projection Extension Specification ----------------

# https://github.com/stac-extensions/projection/
PROJ_EPSG = "proj:epsg"
PROJ_CODE = "proj:code"
PROJ_WKT = "proj:wkt2"
PROJ_GEOMETRY = "proj:geometry"
PROJ_BBOX = "proj:bbox"
Expand Down
4 changes: 2 additions & 2 deletions eoreader/stac/stac_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
GSD,
PROJ_BBOX,
PROJ_CENTROID,
PROJ_EPSG,
PROJ_CODE,
PROJ_GEOMETRY,
PROJ_SHAPE,
PROJ_TRANSFORM,
Expand Down Expand Up @@ -263,7 +263,7 @@ def _to_repr(self) -> list:
"""
repr_list = [
"Projection STAC Extension attributes:",
f"\t{PROJ_EPSG}: {self.epsg}",
f"\t{PROJ_CODE}: EPSG:{self.epsg}",
# f"\t{PROJ_WKT}: {self.wkt2}", # Too long to display
f"\t{PROJ_GEOMETRY}: {repr_multiline_str(self.geometry, nof_tabs=3)}",
f"\t{PROJ_BBOX}: {repr_multiline_str(self.bbox, nof_tabs=3)}",
Expand Down
8 changes: 5 additions & 3 deletions eoreader/stac/stac_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def fill_common_mtd(asset: Any, prod, **kwargs) -> None:
"""
# Basics
asset.common_metadata.title = kwargs.get(TITLE, "No title available")
asset.common_metadata.description = kwargs.get(DESCRIPTION, "")
if len(asset.common_metadata.description) < 1:
asset.common_metadata.description = "No description available"
description = kwargs.get(DESCRIPTION, "")
if len(description) < 1:
description = "No description available"

asset.common_metadata.description = description

# Date and Time
asset.common_metadata.created = datetime.utcnow()
Expand Down

0 comments on commit b7c7ee2

Please sign in to comment.