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
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Hämtar verkliga Sentinel-2 bilder från Copernicus Data Space
|
||||
"""
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# Uppsala area bounding box
|
||||
BBOX = {
|
||||
"min_lon": 17.4,
|
||||
"min_lat": 59.8,
|
||||
"max_lon": 17.8,
|
||||
"max_lat": 60.1
|
||||
}
|
||||
|
||||
# Copernicus Data Space API
|
||||
COPERNICUS_URL = "https://catalogue.dataspace.copernicus.eu/odata/v1/Products"
|
||||
|
||||
def search_sentinel_images():
|
||||
"""Sök efter Sentinel-2 bilder för Uppsala-området"""
|
||||
|
||||
# Bygg sökquery
|
||||
params = {
|
||||
"$filter": f"Collection/Name eq 'SENTINEL-2' and OData.CSC.Intersects(area=geography'SRID=4326;POLYGON(({BBOX['min_lon']} {BBOX['min_lat']}, {BBOX['max_lon']} {BBOX['min_lat']}, {BBOX['max_lon']} {BBOX['max_lat']}, {BBOX['min_lon']} {BBOX['max_lat']}, {BBOX['min_lon']} {BBOX['min_lat']}))')",
|
||||
"$orderby": "ContentDate/Start desc",
|
||||
"$top": 5,
|
||||
"$skip": 0
|
||||
}
|
||||
|
||||
print(f"[{datetime.now().isoformat()}] Searching Sentinel-2 images...")
|
||||
print(f"Area: Uppsala ({BBOX['min_lon']}, {BBOX['min_lat']}, {BBOX['max_lon']}, {BBOX['max_lat']})")
|
||||
|
||||
try:
|
||||
response = requests.get(COPERNICUS_URL, params=params, timeout=30)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
products = data.get('value', [])
|
||||
|
||||
print(f"Found {len(products)} products")
|
||||
|
||||
for i, product in enumerate(products[:3]):
|
||||
print(f"\nProduct {i+1}:")
|
||||
print(f" ID: {product.get('Id')}")
|
||||
print(f" Name: {product.get('Name')}")
|
||||
print(f" Date: {product.get('ContentDate', {}).get('Start')}")
|
||||
print(f" Cloud Cover: {product.get('CloudCover', 'N/A')}%")
|
||||
print(f" Size: {product.get('ContentLength', 0) / (1024*1024):.1f} MB")
|
||||
|
||||
# Spara produktinfo
|
||||
with open(f'satellite_product_{i+1}.json', 'w') as f:
|
||||
json.dump(product, f, indent=2)
|
||||
|
||||
return products
|
||||
else:
|
||||
print(f"Error: HTTP {response.status_code}")
|
||||
print(response.text[:500])
|
||||
return []
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
return []
|
||||
|
||||
def download_quicklook(product_id, filename):
|
||||
"""Ladda ner quicklook (förhandsvisning)"""
|
||||
url = f"{COPERNICUS_URL}({product_id})/Products(Quicklook)"
|
||||
|
||||
print(f"\nDownloading quicklook for {product_id}...")
|
||||
|
||||
try:
|
||||
response = requests.get(url, timeout=30)
|
||||
if response.status_code == 200:
|
||||
with open(filename, 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f"Saved to {filename} ({len(response.content)} bytes)")
|
||||
return True
|
||||
else:
|
||||
print(f"Error: HTTP {response.status_code}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("="*60)
|
||||
print("SENTINEL-2 SATELLITE IMAGE FETCH")
|
||||
print("="*60)
|
||||
|
||||
products = search_sentinel_images()
|
||||
|
||||
if products:
|
||||
print("\n" + "="*60)
|
||||
print("DOWNLOADING QUICKLOOKS")
|
||||
print("="*60)
|
||||
|
||||
for i, product in enumerate(products[:2]):
|
||||
product_id = product.get('Id')
|
||||
if product_id:
|
||||
download_quicklook(product_id, f"quicklook_{i+1}.jpg")
|
||||
|
||||
print("\n" + "="*60)
|
||||
print("DONE")
|
||||
print("="*60)
|
||||
Reference in New Issue
Block a user