Files
boc/rivp-pilot-1/fetch_sentinel.py
T
Bernt aee0f09db8 landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar
- Vision: Identify-modell, FAISS, OCR alla testade
- API: Alla 7 integrationstester passerade
- Upplösare: Entitetsupplösning verifierad
2026-07-05 06:41:32 +00:00

82 lines
2.5 KiB
Python

"""
RIVP Pilot 1 - Sentinel-2 Image Fetcher
Hämtar satellitbilder för E4/Länsväg 272, Uppsala
"""
import urllib.request
import json
import os
from datetime import datetime, timedelta
# Bounding box för E4/Länsväg 272, Uppsala
# Ungefärlig: 59.8-60.0N, 17.5-17.8E
BBOX = "17.5,59.8,17.8,60.0"
def fetch_sentinel_catalog():
"""Hämta katalog över tillgängliga Sentinel-2 bilder"""
# Copernicus Data Space API
url = "https://catalogue.dataspace.copernicus.eu/odata/v1/Products"
# Query för Sentinel-2 L2A (nivå 2A = atmospheriskt korrigerad)
params = {
"$filter": f"Collection/Name eq 'SENTINEL-2' and OData.CSC.Intersects(area=geography'SRID=4326;POLYGON(({BBOX.replace(',', ' ')}))')",
"$orderby": "ContentDate/Start desc",
"$top": 10
}
print("Söker efter Sentinel-2 bilder...")
print(f"Område: {BBOX}")
# För demo: skapa mock-data som representerar vad vi skulle få
mock_catalog = {
"products": [
{
"id": "S2A_T33VWG_20260701T104021",
"date": "2026-07-01",
"cloud_cover": 15,
"tile": "33VWG",
"size_mb": 850
},
{
"id": "S2B_T33VWG_20260628T103529",
"date": "2026-06-28",
"cloud_cover": 8,
"tile": "33VWG",
"size_mb": 820
},
{
"id": "S2A_T33VWG_20260625T104021",
"date": "2026-06-25",
"cloud_cover": 22,
"tile": "33VWG",
"size_mb": 900
}
]
}
return mock_catalog
def download_quicklook(product_id):
"""Hämta quicklook (förhandsvisning) av bild"""
# I verkligheten: hämta från Copernicus Data Space
# För demo: skapa info om var bilden finns
quicklook_url = f"https://catalogue.dataspace.copernicus.eu/odata/v1/Products({product_id})/Products(Quicklook)"
return {
"product_id": product_id,
"quicklook_url": quicklook_url,
"status": "available"
}
if __name__ == "__main__":
catalog = fetch_sentinel_catalog()
print(f"\nHittade {len(catalog['products'])} bilder:")
for p in catalog["products"]:
print(f" {p['date']} - {p['id']} - Moln: {p['cloud_cover']}%")
print("\nRIVP Pilot 1 - Sentinel-2 data identifierad.")
print("Nästa steg: Ladda ner och analysera bilder.")