time_range="2023-09-01/2023-09-21"# GEOJSON can be created on geojson.ioarea_of_interest={"coordinates":[[[14.631570827879642,48.95580055524857],[14.631570827879642,48.495695436823524],[15.727627794927486,48.495695436823524],[15.727627794927486,48.95580055524857],[14.631570827879642,48.95580055524857]]],"type":"Polygon"}
search=catalog.search(collections=["sentinel-2-l2a"],intersects=area_of_interest,datetime=time_range,query={"eo:cloud_cover":{"lt":10},"s2:nodata_pixel_percentage":{"lt":20}},)# Check how many items were returneditems=search.item_collection()console.print(f"Returned {len(items)} Items")
Returned 14 Items
least_cloudy_item=min(items,key=lambdaitem:eo.ext(item).cloud_cover)console.print(f"Choosing {least_cloudy_item.id} from {least_cloudy_item.datetime.date()}"f" with {eo.ext(least_cloudy_item).cloud_cover}% cloud cover")
Choosing S2A_MSIL2A_20230907T100031_R122_T33UWQ_20230907T211348 from 2023-09-07 with 0.000488% cloud cover