analitics

Pages

Wednesday, December 28, 2022

Python 3.10.2 : Copernicus A.P.I. and python sentinelsat python package - part 001.

Last night I worked a bit with python and tested on the online tool from Copernicus.
Copernicus is the European Union's Earth observation programme, which analyzes our planet and its environment for the benefit of all European citizens.
If you want to test it with python or another A.P>I. you need to create an user and a apassword.This is the source code I used with S:
from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date
# Connect to the Sentinel API
api = SentinelAPI('___', '___', 'https://scihub.copernicus.eu/dhus')
#
api.download('___from_copernicus_website___')
# Search for Sentinel-2 images covering a specific area
footprint = geojson_to_wkt(read_geojson('area_of_interest.geojson'))

products = api.query(footprint,
                     date=('20211201', '20211205'),
                     platformname='Sentinel-1')
# convert to Pandas DataFrame
products_df = api.to_dataframe(products)
print(products_df)
# sort and limit to first 5 sorted products
products_df_sorted = products_df.sort_values(['link'], ascending=[True])
products_df_sorted = products_df_sorted.head(5)

# download sorted and reduced products
api.download_all(products_df_sorted.index)
You need a JSOn file to select the area of interest:
After I run this python script, the result is this:
python test001.py
                                                                                  title  ... productconsolidation
8f12995e-8f4b-4634-91bb-4971a1bdd0c3  S1B_IW_SLC__1SDV_20211201T160049_20211201T1601...  ...                  NaN
c62ceac6-c9ac-409d-bea9-d1bc23b1b183  S1B_IW_GRDH_1SDV_20211201T160050_20211201T1601...  ...                  NaN
2d1319c5-60af-468b-904a-5dfbdd5f205c  S1B_IW_RAW__0SDV_20211201T160046_20211201T1601...  ...                SLICE

[3 rows x 36 columns]
Downloading S1B_IW_GRDH_1SDV_20211201T160050_20211201T160115_029834_038FB2_A390.zip: 100%|█| 929M/929M [02:44<00:00, 5.
Downloading products:  33%|██████████████████▋                                     | 1/3 [02:58<05:57, 178.58s/product]
Downloading S1B_IW_RAW__0SDV_20211201T160046_20211201T160119_029834_038FB2_D35D.zip:  83%|▊| 1.31G/1.58G [03:21<00:26,
Downloading S1B_IW_SLC__1SDV_20211201T160049_20211201T160116_029834_038FB2_AC13.zip:  31%|▎| 1.33G/4.35G [03:18<04:16,
...
The copernicus online map can be seen in the next inage: