Skip to content

Commit

Permalink
Update to Shoreline Monitor dataset
Browse files Browse the repository at this point in the history
Fix license, providers & CRS errors when uploading to a STAC fastAPI
  • Loading branch information
EtienneKras committed Jun 19, 2024
1 parent b67bd20 commit f8edade
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"deltares:type": "circle",
"deltares:stations": "locationId",
"deltares:onclick": {},
"datetime": "2024-06-03T11:25:31.883235Z"
"datetime": "2024-06-19T08:28:16.036044Z"
},
"geometry": {
"type": "Polygon",
Expand Down
207 changes: 201 additions & 6 deletions STAC/data/current/shore_mon/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,104 @@
179.667697861
],
"description": "Longitude",
"reference_system": "EPSG:4326",
"reference_system": {
"$schema": "https://proj.org/schemas/v0.7/projjson.schema.json",
"type": "GeographicCRS",
"name": "WGS 84",
"datum_ensemble": {
"name": "World Geodetic System 1984 ensemble",
"members": [
{
"name": "World Geodetic System 1984 (Transit)",
"id": {
"authority": "EPSG",
"code": 1166
}
},
{
"name": "World Geodetic System 1984 (G730)",
"id": {
"authority": "EPSG",
"code": 1152
}
},
{
"name": "World Geodetic System 1984 (G873)",
"id": {
"authority": "EPSG",
"code": 1153
}
},
{
"name": "World Geodetic System 1984 (G1150)",
"id": {
"authority": "EPSG",
"code": 1154
}
},
{
"name": "World Geodetic System 1984 (G1674)",
"id": {
"authority": "EPSG",
"code": 1155
}
},
{
"name": "World Geodetic System 1984 (G1762)",
"id": {
"authority": "EPSG",
"code": 1156
}
},
{
"name": "World Geodetic System 1984 (G2139)",
"id": {
"authority": "EPSG",
"code": 1309
}
}
],
"ellipsoid": {
"name": "WGS 84",
"semi_major_axis": 6378137,
"inverse_flattening": 298.257223563
},
"accuracy": "2.0",
"id": {
"authority": "EPSG",
"code": 6326
}
},
"coordinate_system": {
"subtype": "ellipsoidal",
"axis": [
{
"name": "Geodetic latitude",
"abbreviation": "Lat",
"direction": "north",
"unit": "degree"
},
{
"name": "Geodetic longitude",
"abbreviation": "Lon",
"direction": "east",
"unit": "degree"
}
]
},
"scope": "Horizontal component of 3D system.",
"area": "World.",
"bbox": {
"south_latitude": -90,
"west_longitude": -180,
"north_latitude": 90,
"east_longitude": 180
},
"id": {
"authority": "EPSG",
"code": 4326
}
},
"type": "spatial"
},
"lat": {
Expand All @@ -68,7 +165,104 @@
66.4159042598
],
"description": "Latitude",
"reference_system": "EPSG:4326",
"reference_system": {
"$schema": "https://proj.org/schemas/v0.7/projjson.schema.json",
"type": "GeographicCRS",
"name": "WGS 84",
"datum_ensemble": {
"name": "World Geodetic System 1984 ensemble",
"members": [
{
"name": "World Geodetic System 1984 (Transit)",
"id": {
"authority": "EPSG",
"code": 1166
}
},
{
"name": "World Geodetic System 1984 (G730)",
"id": {
"authority": "EPSG",
"code": 1152
}
},
{
"name": "World Geodetic System 1984 (G873)",
"id": {
"authority": "EPSG",
"code": 1153
}
},
{
"name": "World Geodetic System 1984 (G1150)",
"id": {
"authority": "EPSG",
"code": 1154
}
},
{
"name": "World Geodetic System 1984 (G1674)",
"id": {
"authority": "EPSG",
"code": 1155
}
},
{
"name": "World Geodetic System 1984 (G1762)",
"id": {
"authority": "EPSG",
"code": 1156
}
},
{
"name": "World Geodetic System 1984 (G2139)",
"id": {
"authority": "EPSG",
"code": 1309
}
}
],
"ellipsoid": {
"name": "WGS 84",
"semi_major_axis": 6378137,
"inverse_flattening": 298.257223563
},
"accuracy": "2.0",
"id": {
"authority": "EPSG",
"code": 6326
}
},
"coordinate_system": {
"subtype": "ellipsoidal",
"axis": [
{
"name": "Geodetic latitude",
"abbreviation": "Lat",
"direction": "north",
"unit": "degree"
},
{
"name": "Geodetic longitude",
"abbreviation": "Lon",
"direction": "east",
"unit": "degree"
}
]
},
"scope": "Horizontal component of 3D system.",
"area": "World.",
"bbox": {
"south_latitude": -90,
"west_longitude": -180,
"north_latitude": 90,
"east_longitude": 180
},
"id": {
"authority": "EPSG",
"code": 4326
}
},
"type": "spatial"
}
},
Expand Down Expand Up @@ -447,20 +641,21 @@
]
}
},
"license": "proprietary",
"license": "CC-BY-4.0",
"keywords": [
"GlobalCoastalAtlas",
"DeltaPortfolio"
],
"providers": [
{
"name": "Deltares",
"description": "Deltares is an independent institute for applied research in the field of water and subsurface.",
"description": "Deltares is an independent knowledge institute for applied research in the field of water and subsurface.",
"roles": [
"producer",
"processor"
"processor",
"host"
],
"url": "https://www.deltares.nl"
"url": "https://deltares.nl"
}
],
"assets": {
Expand Down
21 changes: 20 additions & 1 deletion STAC/data/scripts/01_shorelinemonitor_stacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
with open(metadata_fp, "r") as f:
metadata = json.load(f)

if "Creative Commons" in metadata["LICENSE"] and "4.0" in metadata["LICENSE"]:
metadata["LICENSE"] = "CC-BY-4.0"

# STAC configs
STAC_DIR = "current"
TEMPLATE_COLLECTION = "template" # stac template for dataset collection
Expand Down Expand Up @@ -137,6 +140,9 @@ def get_paint_props(item_key: str):
# cast zero terminated bytes to str because json library cannot write handle bytes
ds = zero_terminated_bytes_as_str(ds)

# add the crs to match the STAC encoding with small letters
ds.attrs["crs"] = ds.attrs["CRS"]

# remove characters that cause problems in the frontend.
ds = rm_special_characters(
ds, dimensions_to_check=ADDITIONAL_DIMENSIONS, characters=["%"]
Expand All @@ -163,6 +169,19 @@ def get_paint_props(item_key: str):
title=COLLECTION_TITLE,
description=DATASET_DESCRIPTION,
keywords=["GlobalCoastalAtlas", "DeltaPortfolio"],
license=metadata["LICENSE"],
providers=[
pystac.Provider(
name="Deltares",
roles=[
pystac.provider.ProviderRole.PRODUCER,
pystac.provider.ProviderRole.PROCESSOR,
pystac.provider.ProviderRole.HOST,
],
url="https://deltares.nl",
description=metadata["PROVIDERS"]["description"],
),
],
)

# add datacube dimensions derived from xarray dataset to dataset stac_obj
Expand All @@ -173,7 +192,7 @@ def get_paint_props(item_key: str):
y_dimension=Y_DIMENSION,
temporal_dimension=TEMPORAL_DIMENSION,
additional_dimensions=ADDITIONAL_DIMENSIONS,
reference_system=ds.CRS,
# reference_system=ds.CRS, # note, when supplying a CRS string, this is not recognised as valid STAC CRS in a STAC fastAPI. We need to have it created but ds.attrs["CRS"] is not used by xstac. Hence above we set ds.attrs["crs"].
)

# generate stac feature keys (strings which will be stac item ids) for mapbox layers
Expand Down

0 comments on commit f8edade

Please sign in to comment.