Skip to article frontmatterSkip to article content

EODAG - A quick start with DEDL

This notebook provides a quickstart guide for using the EODAG Python API and CLI to search, discover, and download DEDL data.

🚀 Launch in JupyterHub

Copyright: 2025 EUMETSAT
License: MIT
Authors: Serena Avolio (EUMETSAT/Starion)

EODAG - A quick start with DEDL

Prerequisites:
  • To search and access DEDL data a DestinE user account is needed

  • References:
  • EODAG - Earth Observation Data Access Gateway

  • EODAG - DEDL

  • EODAG API documentation

  • Credit:
  • Code used in this context takes inspiration from the Python API User Guide produced by CS Group.

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

    This quickstart tutorial has the aim to show how to get DEDL data using the EODAG python API. It contains some help tools to select the dataset of interest, the bounding box and the time range for searching DEDL data.

    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.

    In this notebook the word ‘collection’, ‘dataset’ and ‘product type’ have the same meaning.

    Note:

    Please note that the two factor authentication (2FA) is still not implemented in EODAG. The users who have enabled 2FA on DESP will not be able to run this notebook.

    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__OUTPUT_DIR"] = 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

    In this section, we:

    • import and instantiate an EODataAccessGateway object that will be used for all the operations in this tutorial.

    • discover DEDL collections. The collections are presented in a dropdown menu, selecting a collection its description will be prompted.

    • the collection selected will be used in the rest of the tutorial

    
    from eodag import EODataAccessGateway, setup_logging
    dag = EODataAccessGateway()
    
    setup_logging(0)
    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

    In this section, we define the search criteria to find data inside the chosen dataset.

    • Bounding box can be modified using the text inputs, it will be visualized on the map. Once selected, to use it for the search we need to use the ‘save bbox’ button under the map.

    • Time range can be modified using the inputs for dates under the map.

    # 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))

    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

    See the available metadata:

    
    if(len(products_first_page)>0):
        one_product = products_first_page[0]
        print(one_product.properties.keys())
    if(len(products_first_page)>0):
        product_to_download = one_product
        product_path = dag.download(product_to_download)
        print(product_path)