Skip to content

Commit

Permalink
Changes to incorporate geoserver in collection
Browse files Browse the repository at this point in the history
Also put stac_io to default from pystac as in CoCliCo
Note, geoserver link is still a dummy.. Cannot fix it yet (will be soon)
  • Loading branch information
EtienneKras committed Nov 22, 2024
1 parent a3da587 commit 5b7ce11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
AZURE_STORAGE_SAS_TOKEN="paste-your-sas-token-here"
CLIENT_AZURE_STORAGE_CONNECTION_STRING="paste-your-connection-string-here"
AZURE_STORAGE_ACCOUNT_NAME="paste-your-connection-string-here"
17 changes: 15 additions & 2 deletions scripts/python/stac_deltadtm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from coclicodata.coclico_stac.layouts import CoCliCoCOGLayout
from dotenv import load_dotenv
from pystac.extensions import raster
from pystac.stac_io import DefaultStacIO
from stactools.core.utils import antimeridian

# Load the environment variables from the .env file
Expand All @@ -35,9 +36,10 @@
sas_token = os.getenv("AZURE_STORAGE_SAS_TOKEN")
storage_account_name = os.getenv("AZURE_STORAGE_ACCOUNT_NAME")
storage_options = {"account_name": storage_account_name, "credential": sas_token}
item_type = "mosaic" # "single" or "mosaic"

# CoCliCo STAC
STAC_DIR = pathlib.Path.home() / "dev" / "coclicodata" / "current"
STAC_DIR = pathlib.Path.home() / "Documents" / "GitHub" / "coclicodata" / "current"

COLLECTION_ID = "deltares-delta-dtm"
COLLECTION_TITLE = "DeltaDTM: A global coastal digital terrain model"
Expand Down Expand Up @@ -245,7 +247,7 @@ def create_asset(

fps = fs.glob(f"{root}/**/*.tif")

stac_io = CoCliCoStacIO()
stac_io = DefaultStacIO() #CoCliCoStacIO()
layout = CoCliCoCOGLayout()

collection = create_collection()
Expand Down Expand Up @@ -293,6 +295,17 @@ def create_asset(
),
)

if item_type == "mosaic":
collection.add_asset(
"geoserver_link",
pystac.Asset(
# https://coclico.avi.deltares.nl/geoserver/%s/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&transparent=true&width=256&height=256&layers=%s"%(COLLECTION_ID, COLLECTION_ID + ":" + ASSET_TITLE),
"https://coclico.avi.deltares.nl/geoserver/cfhp/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&transparent=true&width=256&height=256&layers=cfhp:HIGH_DEFENDED_MAPS_Mean_spring_tide", # test
title="Geoserver Mosaic link",
media_type="application/vnd.apache.parquet",
),
)

catalog = pystac.Catalog.from_file(str(STAC_DIR / "catalog.json"))

if catalog.get_child(collection.id):
Expand Down

0 comments on commit 5b7ce11

Please sign in to comment.