Skip to content

Instantly share code, notes, and snippets.

@cas--
Created December 21, 2023 14:23
Show Gist options
  • Save cas--/8c17ca14a20af54f159ff6e743cfd1f3 to your computer and use it in GitHub Desktop.
Save cas--/8c17ca14a20af54f159ff6e743cfd1f3 to your computer and use it in GitHub Desktop.
Satellite data example
import pandas as pd
import requests
from shapely.geometry import box
start_date = "2022-06-01"
end_date = "2022-06-10"
data_collection = "SENTINEL-1"
# http://bboxfinder.com/#49.693397,-5.862579,50.839769,-4.107513
shapely_polygon = box(-5.862579, 49.693397, -4.107513, 50.839769)
aoi = shapely_polygon.wkt
PRODUCTS_URL = "https://catalogue.dataspace.copernicus.eu/odata/v1/Products"
collection_filter = f"Collection/Name eq '{data_collection}'"
aoi_filter = f"Geo.Intersects(area=geography'SRID=4326;{aoi}')"
start_date_filter = f"ContentDate/Start gt {start_date}T00:00:00.000Z"
end_date_filter = f"ContentDate/Start lt {end_date}T00:00:00.000Z"
data_filters = " and ".join(
[collection_filter, aoi_filter, start_date_filter, end_date_filter]
)
url_params = {"$filter": data_filters}
json_data = requests.get(PRODUCTS_URL, params=url_params).json()
df = pd.DataFrame.from_dict(json_data["value"]).head(5)
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment