Skip to content

Allow products filtering before downloading

We can add the possibility to choose to download only "ascending" or "descending" orbits, or a list of "relativeOrbitNumber". Additionally, we can also filter the products to download with a minimum coverage of the tile (min overlaping)

In the config file, we can add a section like this

[DataSource]
orbit_direction: DES
relative_orbits_list: 26 128

The lines "orbit_direction" and "relative_orbits_list" are exclusive.

In the sofware, we can use the eodag filtering option

from eodag import EODataAccessGateway
from eodag.crunch import FilterOverlap, FilterProperty

dag = EODataAccessGateway()

search_criteria = {
    "productType": "S1_SAR_GRD",
    "start": "2022-04-03",
    "end": "2022-04-30",
    "geom": {"lonmin": 105.9146, "latmin": 10.7611, "lonmax": 106.9252, "latmax": 11.7586    }
}
products_first_page, estimated_total_number = dag.search(**search_criteria)

search_geometry = shapely.geometry.box(
    search_criteria["geom"]["lonmin"],
     search_criteria["geom"]["latmin"],
     search_criteria["geom"]["lonmax"],
     search_criteria["geom"]["latmax"],
)

orbits_to_keep=[26,128]

# Filter products with a minimum overlaping of 20%
filtered_products = products_first_page.filter_overlap(
    minimum_overlap=20,
    geometry=search_criteria["geom"]
)

# Filter products with orbitDirection or relativeOrbitNumber
filtered_orb_products=[]
for orbit in orbits_to_keep:
    filtered_orb_products+=filtered_products.filter_property(relativeOrbitNumber=orbit)
#filtered_products=filtered_products.filter_property(orbitDirection="ascending")
#filtered_products=filtered_products.filter_property(orbitDirection="descending")
filtered_products=filtered_orb_products