DEDL - EODAG - A quick start with DEDL

DEDL - EODAG - A quick start with DEDL#

Author: EUMETSAT
Copyright: 2024 EUMETSAT
Licence: MIT

How to use EODAG to search and access DEDL data - quick start

EODAG is a command line tool and a Python package for searching and downloading earth observation data via a unified API.

This quickstart is to help get DEDL data using EODAG. Detailed information about the usage of EODAG can be found on the project documentation page.

Throughout this quickstart notebook, you will learn:

  1. Setup: How to configure EODAG to use the provider DEDL.

  2. Discover: How to discover DEDL datasets through EODAG.

  3. Search products: How to search DEDL data through EODAG.

  4. Download products: How to download DEDL data through EODAG.

The complete guide on how to use EODAG Python API is available via https://eodag.readthedocs.io/en/stable/api_user_guide.html.

Prequisites:
  • Search and download dedl products : DestinE user account
  • Setup#

    In this section, we set:

    • The output_dir, the directory where to store downloaded products.

    • The DEDL credentials, you’ll be asked to enter your DEDL credentials.

    • The search timeout, it is of 60 seconds to avoid any unexpected errors because of long running search queries.

    import os
    from getpass import getpass
    
    workspace = 'eodag_workspace'
    if not os.path.isdir(workspace):
        os.mkdir(workspace)
        
    os.environ["EODAG__DEDL__DOWNLOAD__OUTPUTS_PREFIX"] = os.path.abspath(workspace)
    
    os.environ["EODAG__DEDL__SEARCH__TIMEOUT"]="60"
    os.environ["DEFAULT_STREAM_REQUESTS_TIMEOUT"] = "15"
    os.environ["EODAG__DEDL__PRIORITY"]="10"
    
    
    DESP_USERNAME = input("Please input your DESP username or email: ")
    DESP_PASSWORD = getpass("Please input your DESP password: ")
    
    os.environ["EODAG__DEDL__AUTH__CREDENTIALS__USERNAME"]=DESP_USERNAME
    os.environ["EODAG__DEDL__AUTH__CREDENTIALS__PASSWORD"]=DESP_PASSWORD
    

    EODiscover#

    We now need to import the EODataAccessGateway class in order to discover the available DEDL collections.

    Collections are presented in a dropdown menu, selecting a collection its description will be prompted.

    from eodag import EODataAccessGateway, setup_logging
    dag = EODataAccessGateway()
    
    setup_logging(1)
    
    import ipywidgets as widgets
    from IPython.display import display, clear_output, HTML
    from ipywidgets import Layout, Box
    import json
    
    #default values
    
    DATASET_ID = 'EO.EUM.DAT.SENTINEL-3.OL_2_WFR___'
    
    
    # Event listeners
    def on_change(change):
        with output_area:
            clear_output()
            print(f'Selected: {change["new"]}')
            print('---------------------------------------------')
            delimiter=''
            global DATASET_ID
            DATASET_ID = delimiter.join(change["new"])
            product_types=dag.list_product_types("dedl")
            index = next((i for i, d in enumerate(product_types) if d.get('ID') == DATASET_ID), None)
            
            print("TITLE: "+product_types[index]['title'])
            print("ABSTRACT: "+product_types[index]['abstract'])
            print("KEYWORDS: "+product_types[index]['abstract'])
    
    options=[product_type["ID"] for product_type in dag.list_product_types("dedl")]
    
    # Widgets
    output_area = widgets.Output()
    
    dropdown = widgets.Dropdown(
        options=options,
        value=options[0],
        description="Datasets:",
        disabled=False,
    ) 
    
    dropdown.observe(on_change, names='value')
    
    
    # Layout
    # Define the layout for the dropdown
    dropdown_layout = Layout(display='space-between', justify_content='center', width='80%')
    # Create a box to hold the dropdown with the specified layout
    box = Box([dropdown, output_area], layout=dropdown_layout)
    display( box)  
    

    EOSearch#

    Once we selected our dataset of interest, we can define the search criteria to find data inside the chosen dataset.

    Select bbox, start and end date to use in the search:

    # Import necessary libraries
    import folium, datetime
    from ipywidgets import interactive, HBox, VBox, FloatText, Button, Label
    
    #default values
    
    START_DATE = '2024-08-11'
    END_DATE = '2024-08-13'
    
    sw_lat = 37.0
    sw_lng = 14.0
    ne_lat = 38.0
    ne_lng = 16.0
    
    #functions to handle the chosen values
    def on_date_change(change):
        with output_area:
            clear_output()
            global START_DATE
            global END_DATE
            t1 = start_date.value
            t2 = end_date.value
            START_DATE = t1.strftime('%Y-%m-%d')
            END_DATE = t2.strftime('%Y-%m-%d')
    
            
    def update_map(sw_lat, sw_lng, ne_lat, ne_lng):
        # Clear the map
        m = folium.Map(location=[(sw_lat + ne_lat) / 2, (sw_lng + ne_lng) / 2], zoom_start=4, tiles=None)
    
        nasa_wms = folium.WmsTileLayer(
            url='https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi',
            name='NASA Blue Marble',
            layers='BlueMarble_ShadedRelief',
            format='image/png',
            transparent=True,
            attr='NASA'
        )
        nasa_wms.add_to(m)
        
        # Add the bounding box rectangle
        folium.Rectangle(
            bounds=[[sw_lat, sw_lng], [ne_lat, ne_lng]],
            color="#ff7800",
            fill=True,
            fill_opacity=0.3
        ).add_to(m)
        
        # Display the map
        display(m)
        return (sw_lat, sw_lng, ne_lat, ne_lng)
    
    def save_bbox(button):
        global sw_lat 
        global sw_lng  
        global ne_lat 
        global ne_lng 
    
        sw_lat = sw_lat_input.value
        sw_lng = sw_lng_input.value
        ne_lat = ne_lat_input.value
        ne_lng = ne_lng_input.value
        
        with output:
            clear_output()
            print(f"BBox: sw_lat {sw_lat} sw_lng {sw_lng} ne_lat {ne_lat} ne_lng {ne_lng}")
    
    
    # Create a base map
    m = folium.Map(location=[40, 20], zoom_start=4)
            
            
    # Widgets
    output = widgets.Output()
    
    # Widgets for bbox coordinates input
    sw_lat_input = FloatText(value=sw_lat, description='SW Latitude:')
    sw_lng_input = FloatText(value=sw_lng, description='SW Longitude:')
    ne_lat_input = FloatText(value=ne_lat, description='NE Latitude:')
    ne_lng_input = FloatText(value=ne_lng, description='NE Longitude:')
    
    save_button = Button(description="Save BBox")
    
    
    # Create DatePicker widgets
    start_date = widgets.DatePicker(
        description='Start Date',value = datetime.date(2024,8,11),
        disabled=False
    )
    
    end_date = widgets.DatePicker(
        description='End Date',value = datetime.date(2024,8,13),
        disabled=False
    )
    
    
    ui = VBox([
       # HBox([sw_lat_input, sw_lng_input]),
      #  HBox([ne_lat_input, ne_lng_input]),
        save_button,
        output,
        start_date, 
        end_date
    ])
    
    # Display the interactive map and UI
    interactive_map = interactive(update_map, sw_lat=sw_lat_input, sw_lng=sw_lng_input,
                                  ne_lat=ne_lat_input, ne_lng=ne_lng_input)
    
    
    display(interactive_map, ui)
    
         
    #Events
    
    start_date.observe(on_date_change, names='value')
    end_date.observe(on_date_change, names='value')
    save_button.on_click(save_bbox)
    

    Selected criteria:

    search_criteria = {
        "productType": DATASET_ID,
        "start": START_DATE,
        "end": END_DATE,
        "geom": {"lonmin": sw_lng, "latmin": sw_lat, "lonmax": ne_lng, "latmax": ne_lat},
        "count": True
    }
    
    print(json.dumps(search_criteria, indent=2))
    
    {
      "productType": "EO.EUM.DAT.SENTINEL-3.OL_2_WFR___",
      "start": "2024-08-11",
      "end": "2024-08-13",
      "geom": {
        "lonmin": 14.0,
        "latmin": 37.0,
        "lonmax": 16.0,
        "latmax": 38.0
      },
      "count": true
    }
    

    Use selected criteria to search data:

    products_first_page = dag.search(**search_criteria)
    print(f"Got {len(products_first_page)} products and an estimated total number of {products_first_page.number_matched} products.")
    products_first_page
    
    Got 2 products and an estimated total number of 2 products.
    
    SearchResult (2/2)
    0  EOProduct(id=S3A_OL_2_WFR____20240811T091234_20240811T091534_20240812T163228_0180_115_321_2340_MAR_O_NT_003, provider=dedl)
    EOProduct
    provider: 'dedl',
    product_type: 'S3_OLCI_L2WFR',
    properties["id"]: 'S3A_OL_2_WFR____20240811T091234_20240811T091534_20240812T163228_0180_115_321_2340_MAR_O_NT_003',
    properties["startTimeFromAscendingNode"]: '2024-08-11T09:12:33.892532Z',
    properties["completionTimeFromAscendingNode"]: '2024-08-11T09:15:33.892532Z',
    properties: (36){
    alias: 'EO.EUM.DAT.SENTINEL-3.OL_2_WFR___',
    abstract: 'OLCI (Ocean and Land Colour Instrument) Ocean Colour Geophysical Products. Full Resolution: 300m at nadir. All Sentinel-3 NRT products are available at pick-up point in less than 3h. Level 2 marine products include the following: * water-leaving reflectances in 16 bands, Oa**_reflectance (Baseline Atmospheric Correction (BAC) algorithm, bands: 400, 412, 442, 490, 510, 560, 620, 665, 674, 681, 709, 754, 779, 865, 885, 1024 nanometer (nm)); *algal pigment concentration in clear waters, chl_oc4me (BAC and maximum band ratio algorithm, log10 scaled); *algal pigment concentration in turbid waters, chl_nn (neural net algorithm, log10 scaled); *total suspended matter concentration, tsm_nn (neural net algorithm, log10 scaled); *diffuse attenuation coefficient Kd of downward irradiance at 490 nm, trsp (BAC and M07 algorithm, log10 scaled); *absorption coefficient at 443 nm of coloured detrital and dissolved organic matter, iop_nn (neural net algorithm, log10 scaled); *instantaneous photosynthetically active radiation, PAR (BAC and clear-sky ocean algorithm); *aerosol optical thickness T865 and aerosol Angstrom exponent A865, w_aer (BAC algorithm, A for bands 779 and 865 nm) *integrated water vapour column, iwv (1D-Var algorithm). The geophysical products are accompanied by error estimate products. Pixel classification, quality and science flags, as well as meteorological, geometry and geolocation data at tie points are provided. - All Sentinel-3 NRT products are available at pick-up point in less than 3h - All Sentinel-3 Non Time Critical (NTC) products are available at pick-up point in less than 30 days Sentinel-3 is part of a series of Sentinel satellites, under the umbrella of the EU Copernicus programme.',
    instrument: ['OLCI' ],
    platform: 'SENTINEL-3',
    platformSerialIdentifier: 'SENTINEL-3A,SENTINEL-3B',
    processingLevel: 2,
    keywords: 'OLCI,SENTINEL,SENTINEL3,S3,S3A,S3B,L2,L2WFR,WFR',
    sensorType: 'OPTICAL',
    license: 'proprietary',
    title: 'S3A_OL_2_WFR____20240811T091234_20240811T091534_20240812T163228_0180_115_321_2340_MAR_O_NT_003',
    missionStartDate: '2016-02-16T00:00:00Z',
    _id: 'S3_OLCI_L2WFR',
    productType: 'EO.EUM.DAT.SENTINEL-3.OL_2_WFR___',
    publicationDate: '2024-08-12T16:55:56.745432Z',
    orbitNumber: 321,
    orbitDirection: 'DESCENDING',
    modificationDate: '2024-08-12T16:56:04.265652Z',
    sensorMode: 'Earth Observation',
    startTimeFromAscendingNode: '2024-08-11T09:12:33.892532Z',
    completionTimeFromAscendingNode: '2024-08-11T09:15:33.892532Z',
    id: 'S3A_OL_2_WFR____20240811T091234_20240811T091534_20240812T163228_0180_115_321_2340_MAR_O_NT_003',
    downloadLink: 'https://hda.data.destination-earth.eu/stac/collections/EO.EUM.DAT.SENTINEL-3.OL_2_WFR___/items/S3A_OL_2_WFR____20240811T091234_20240811T091534_20240812T163228_0180_115_321_2340_MAR_O_NT_003/download?provider=dedl',
    storageStatus: 'ONLINE',
    defaultGeometry: 'POLYGON((180 -90, 180 90, -180 90, -180 -90, 180 -90))',
    providers: [{ 'name': 'dedl' , 'description': 'DestineE Data Lake Fresh Data Pool' , 'roles': ['host' ] , 'url': 'https://creodias.eu/' , 'priority': 1 } ],
    start_datetime: '2024-08-11T09:12:33.892532Z',
    sat:absolute_orbit: 44184,
    sar:product_type: 'OL_2_WFR___',
    dedl:baselineCollection: '003',
    dedl:timeliness: 'NT',
    dedl:scope: { 'discover': None , 'search': 'hda-public-data-access' , 'download': 'hda-public-data-access' },
    dedl:productIdentifier: '/eodata/Sentinel-3/OLCI/OL_2_WFR___/2024/08/11/S3A_OL_2_WFR____20240811T091234_20240811T091534_20240812T163228_0180_115_321_2340_MAR_O_NT_003.SEN3',
    dedl:alias: 'EO.EUM.DAT.SENTINEL-3.OL_2_WFR___',
    dedl:endingDateTime: '2024-08-11T09:15:33.892532Z',
    dedl:uid: 'fb18abc3-3725-478a-a833-2d3ec29ba015',
    dedl:beginningDateTime: '2024-08-11T09:12:33.892532Z',
    }
    assets: (0)
    geometry
    1  EOProduct(id=S3A_OL_2_WFR____20240811T091234_20240811T091534_20240811T111434_0179_115_321_2340_MAR_O_NR_003, provider=dedl)
    EOProduct
    provider: 'dedl',
    product_type: 'S3_OLCI_L2WFR',
    properties["id"]: 'S3A_OL_2_WFR____20240811T091234_20240811T091534_20240811T111434_0179_115_321_2340_MAR_O_NR_003',
    properties["startTimeFromAscendingNode"]: '2024-08-11T09:12:33.893679Z',
    properties["completionTimeFromAscendingNode"]: '2024-08-11T09:15:33.893679Z',
    properties: (36){
    alias: 'EO.EUM.DAT.SENTINEL-3.OL_2_WFR___',
    abstract: 'OLCI (Ocean and Land Colour Instrument) Ocean Colour Geophysical Products. Full Resolution: 300m at nadir. All Sentinel-3 NRT products are available at pick-up point in less than 3h. Level 2 marine products include the following: * water-leaving reflectances in 16 bands, Oa**_reflectance (Baseline Atmospheric Correction (BAC) algorithm, bands: 400, 412, 442, 490, 510, 560, 620, 665, 674, 681, 709, 754, 779, 865, 885, 1024 nanometer (nm)); *algal pigment concentration in clear waters, chl_oc4me (BAC and maximum band ratio algorithm, log10 scaled); *algal pigment concentration in turbid waters, chl_nn (neural net algorithm, log10 scaled); *total suspended matter concentration, tsm_nn (neural net algorithm, log10 scaled); *diffuse attenuation coefficient Kd of downward irradiance at 490 nm, trsp (BAC and M07 algorithm, log10 scaled); *absorption coefficient at 443 nm of coloured detrital and dissolved organic matter, iop_nn (neural net algorithm, log10 scaled); *instantaneous photosynthetically active radiation, PAR (BAC and clear-sky ocean algorithm); *aerosol optical thickness T865 and aerosol Angstrom exponent A865, w_aer (BAC algorithm, A for bands 779 and 865 nm) *integrated water vapour column, iwv (1D-Var algorithm). The geophysical products are accompanied by error estimate products. Pixel classification, quality and science flags, as well as meteorological, geometry and geolocation data at tie points are provided. - All Sentinel-3 NRT products are available at pick-up point in less than 3h - All Sentinel-3 Non Time Critical (NTC) products are available at pick-up point in less than 30 days Sentinel-3 is part of a series of Sentinel satellites, under the umbrella of the EU Copernicus programme.',
    instrument: ['OLCI' ],
    platform: 'SENTINEL-3',
    platformSerialIdentifier: 'SENTINEL-3A,SENTINEL-3B',
    processingLevel: 2,
    keywords: 'OLCI,SENTINEL,SENTINEL3,S3,S3A,S3B,L2,L2WFR,WFR',
    sensorType: 'OPTICAL',
    license: 'proprietary',
    title: 'S3A_OL_2_WFR____20240811T091234_20240811T091534_20240811T111434_0179_115_321_2340_MAR_O_NR_003',
    missionStartDate: '2016-02-16T00:00:00Z',
    _id: 'S3_OLCI_L2WFR',
    productType: 'EO.EUM.DAT.SENTINEL-3.OL_2_WFR___',
    publicationDate: '2024-08-11T11:27:44.249034Z',
    orbitNumber: 321,
    orbitDirection: 'DESCENDING',
    modificationDate: '2024-08-11T11:27:53.460052Z',
    sensorMode: 'Earth Observation',
    startTimeFromAscendingNode: '2024-08-11T09:12:33.893679Z',
    completionTimeFromAscendingNode: '2024-08-11T09:15:33.893679Z',
    id: 'S3A_OL_2_WFR____20240811T091234_20240811T091534_20240811T111434_0179_115_321_2340_MAR_O_NR_003',
    downloadLink: 'https://hda.data.destination-earth.eu/stac/collections/EO.EUM.DAT.SENTINEL-3.OL_2_WFR___/items/S3A_OL_2_WFR____20240811T091234_20240811T091534_20240811T111434_0179_115_321_2340_MAR_O_NR_003/download?provider=dedl',
    storageStatus: 'ONLINE',
    defaultGeometry: 'POLYGON((180 -90, 180 90, -180 90, -180 -90, 180 -90))',
    providers: [{ 'name': 'dedl' , 'description': 'DestineE Data Lake Fresh Data Pool' , 'roles': ['host' ] , 'url': 'https://creodias.eu/' , 'priority': 1 } ],
    start_datetime: '2024-08-11T09:12:33.893679Z',
    sat:absolute_orbit: 44184,
    sar:product_type: 'OL_2_WFR___',
    dedl:baselineCollection: '003',
    dedl:timeliness: 'NR',
    dedl:scope: { 'discover': None , 'search': 'hda-public-data-access' , 'download': 'hda-public-data-access' },
    dedl:productIdentifier: '/eodata/Sentinel-3/OLCI/OL_2_WFR___/2024/08/11/S3A_OL_2_WFR____20240811T091234_20240811T091534_20240811T111434_0179_115_321_2340_MAR_O_NR_003.SEN3',
    dedl:alias: 'EO.EUM.DAT.SENTINEL-3.OL_2_WFR___',
    dedl:endingDateTime: '2024-08-11T09:15:33.893679Z',
    dedl:uid: '000dd59b-0870-4f5e-bc28-4f3c493dffbd',
    dedl:beginningDateTime: '2024-08-11T09:12:33.893679Z',
    }
    assets: (0)
    geometry

    See the available metadata:

    if(len(products_first_page)>0):
        one_product = products_first_page[0]
        print(one_product.properties.keys())
    
    dict_keys(['alias', 'abstract', 'instrument', 'platform', 'platformSerialIdentifier', 'processingLevel', 'keywords', 'sensorType', 'license', 'title', 'missionStartDate', '_id', 'productType', 'publicationDate', 'orbitNumber', 'orbitDirection', 'modificationDate', 'sensorMode', 'startTimeFromAscendingNode', 'completionTimeFromAscendingNode', 'id', 'downloadLink', 'storageStatus', 'defaultGeometry', 'providers', 'start_datetime', 'sat:absolute_orbit', 'sar:product_type', 'dedl:baselineCollection', 'dedl:timeliness', 'dedl:scope', 'dedl:productIdentifier', 'dedl:alias', 'dedl:endingDateTime', 'dedl:uid', 'dedl:beginningDateTime'])
    

    EODownload#

    EOProducts can be downloaded individually. The last image is going to be downloaded.

    if(len(products_first_page)>0):
        product_to_download = one_product
        product_path = dag.download(product_to_download)
        print(product_path)
    
    /home/jovyan/dev-branch/DestinE-DataLake-Lab/HDA/EODAG/eodag_workspace/S3A_OL_2_WFR____20240811T091234_20240811T091534_20240812T163228_0180_115_321_2340_MAR_O_NT_003