This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catalog = SentinelHubCatalog(config=config) | |
aoi_bbox = BBox(bbox=aoi_coords_wgs84, crs=CRS.WGS84) | |
time_interval = '2022-06-01', '2022-06-10' | |
search_iterator = catalog.search( | |
DataCollection.SENTINEL2_L2A, | |
bbox=aoi_bbox, | |
time=time_interval, | |
fields={"include": ["id", "properties.datetime"], "exclude": []}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
evalscript_true_color = """ | |
//VERSION=3 | |
function setup() { | |
return { | |
input: [{ | |
bands: ["B02", "B03", "B04"] | |
}], | |
output: { | |
bands: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url = f"https://zipper.dataspace.copernicus.eu/odata/v1/Products(acdd7b9a-a5d4-5d10-9ac8-554623b8a0c9)/$value" | |
headers = {"Authorization": f"Bearer {access_token}"} | |
session = requests.Session() | |
session.headers.update(headers) | |
response = session.get(url, headers=headers, stream=True) | |
with open("product.zip", "wb") as file: | |
for chunk in response.iter_content(chunk_size=8192): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import credentials | |
# from creds import * | |
def get_access_token(username: str, password: str) -> str: | |
data = { | |
"client_id": "cdse-public", | |
"username": username, | |
"password": password, | |
"grant_type": "password", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
json = requests.get(f"https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq '{data_collection}' and OData.CSC.Intersects(area=geography'SRID=4326;{aoi}) and ContentDate/Start gt {start_date}T00:00:00.000Z and ContentDate/Start lt {end_date}T00:00:00.000Z").json() | |
pd.DataFrame.from_dict(json['value']).head(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start_date = "2022-06-01" | |
end_date = "2022-06-10" | |
data_collection = "SENTINEL-2" | |
aoi = "POLYGON((4.220581 50.958859,4.521264 50.953236,4.545977 50.906064,4.541858 50.802029,4.489685 50.763825,4.23843 50.767734,4.192435 50.806369,4.189689 50.907363,4.220581 50.958859))'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
def get_keycloak(username: str, password: str) -> str: | |
data = { | |
"client_id": "cdse-public", | |
"username": username, | |
"password": password, | |
"grant_type": "password", | |
} | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//VERSION=3 | |
// Script to extract a time series of Band 5 values using | |
// Sentinel 2 Level 2A data and metadata file. | |
function setup() { | |
return { | |
input: [{ | |
bands: ["B05"], | |
units: "DN" | |
}], | |
output: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//VERSION=3 | |
//Basic initialization setup function | |
function setup() { | |
return { | |
//List of all bands, that will be used in the script, either for visualization or for choosing best pixel | |
input: [{ | |
bands: [ | |
"B04", | |
"B08" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//VERSION=3 | |
function setup() { | |
return { | |
input: [{ | |
bands: [ | |
"B04", | |
"B08", | |
"SCL", | |
"dataMask" | |
] |
NewerOlder