Parameters mapping#
eodag interacts with various data providers, each having its own way of naming and structuring metadata parameters. To provide a unified interface for users, eodag maps these provider metadata parameters to a common model.
Parameters mapping#
EODAG maps each provider’s specific metadata parameters to a common model using OGC OpenSearch Extension for Earth Observation. Extra parameters having no equivalent in this model are mapped as is.
Depending on the provider, some parameters are queryable or not. This is configured in each configuration file located in the eodag/resources/providers/ directory.
If a parameter metadata-mapping is a list, the first element will help constructing the query (using format()), and the 2nd will help extracting its values from the query result (using jsonpath)
If a parameter metadata-mapping is a string, it will not be queryable and this string will help extracting its values from the query result (using jsonpath).
some_provider:
search:
metadata_mapping:
queryableParameter:
- 'this_is_query_string={queryableParameter}'
- '$.jsonpath.in.result.to.parameter'
nonQueryableParameter: '$.jsonpath.in.result.to.another_parameter'
Formatters#
An EOProduct has a properties attribute
which is built based on how its metadata are set in the provider configuration. For example:
search:
...
metadata_mapping:
publicationDate: '{$.data.timestamp#to_iso_utc_datetime_from_milliseconds}'
...
Converters can be chained using #. They are applied from left to right, passing
each result directly to the next converter. Chaining works both when building
search queries and when extracting metadata from JSON or XML results. For example:
platform:
- '{{"platformSerialIdentifier": "{platform#replace_str(r"^sentinel-1([a-c])$", r"\1")#to_upper}"}}'
- '{$.properties.metadata.platformSerialIdentifier#to_lower#replace_str(r"^([a-c])$", r"sentinel-1\1")}'
This maps sentinel-1a to A for a search and A back to sentinel-1a
in returned metadata, likewise for b and c. A # inside converter
arguments is treated as part of the argument, not as a chain separator. If a
value is None, the remaining converters are skipped.
The following converters can be used to transform the values collected from the provider:
- eodag.api.product.metadata_mapping.format_metadata(search_param, *args, **kwargs)[source]#
Format a string of form
{<field_name>#<conversion_function>}Converters can be chained with
#and are applied from left to right. Separators inside converter arguments are kept unchanged.- The currently understood converters are:
assets_list_to_dict: convert a list of asset objects into a dictionary keyed by asset nameceda_collection_name: generate a CEDA collection name from a stringcsv_list: convert to a comma separated listdates_from_cmems_id: extract min/max UTC datetimes from a CMEMS product identifierdatetime_to_timestamp_milliseconds: converts a utc date string to a timestamp in millisecondsdict_filter: filter dict items using a jsonpath predicatedict_update: add/update nested dictionary items from a list of key/value pairsdict_with_roles: keep only dict items with given roles in their “roles” listfake_l2a_title_from_l1c: used to generate SAFE format metadata for data from AWSfrom_alternate: update assets using given alternatefrom_ewkt: convert EWKT to shapely geometry / WKT in DEFAULT_PROJfrom_georss: convert GeoRSS to shapely geometry / WKT in DEFAULT_PROJget_ecmwf_time: get the time of a datetime string in the ECMWF formatget_dates_from_string: extract start/end UTC datetimes from a date range embedded in textget_group_name: get the matching regex group nameget_hydrological_year: build hydrological year string(s) from an input dateget_variables_from_path: extract variables listed in the query part of a pathinterval_to_datetime_dict: convert a date interval string to a dictionary of year/month/day listsliteralize_unicode: convert a string to its raw Unicode literal formnot_available: replace value with “Not Available”recursive_sub_str: recursively substitue in the structure (e.g. dict) values matching a regexremove_extension: on a string that contains dots, only take the first part of the list obtained by splitting the string on dotsreplace_str: execute “string”.replace(old, new)replace_tuple: apply multiple replacements matching whole values2msil2a_title_to_aws_productinfo: used to generate SAFE format metadata for data from AWSsanitize: sanitize stringslice_str: slice a string (equivalent to s[start, end, step])split: split a string using given separatorsplit_id_into_s3_params: parse a Sentinel-3 product id into S3 query parameter valuesto_bounds: convert an input geometry to [min_lon, min_lat, max_lon, max_lat]to_bounds_lists: convert to list(s) of boundsto_datetime_dict: convert a datetime string to a dictionary where values are either a string or a listto_ewkt: convert to EWKT (Extended Well-Known text)to_geojson: convert to a GeoJSON (via __geo_interface__ if exists)to_geojson_polytope: convert shapely Point/LineString/Polygon to ECMWF polytope feature dictsto_iso_date: remove the time part of a iso datetime stringto_iso_utc_datetime_from_milliseconds: convert a utc timestamp in given milliseconds to a utc iso datetimeto_iso_utc_datetime: convert a UTC datetime string to ISO UTC datetime stringto_longitude_latitude: compute geometry center as a{"lon": ..., "lat": ...}dictionaryto_lower: Convert a string to lowercaseto_non_separated_date: convert an ISO datetime/date string toYYYYMMDDto_nwse_bounds_str: convert to North,West,South,East bounds string with given separatorto_nwse_bounds: convert to North,West,South,East boundsto_rounded_wkt: simplify the WKT of a geometryto_title: Convert a string to title caseto_upper: Convert a string to uppercase
- Parameters:
- Return type:
- Returns:
The formatted string
>>> format_metadata("{date#to_iso_utc_datetime}", date="2021-04-21") '2021-04-21T00:00:00.000Z' >>> format_metadata("{values#csv_list}", values=["a", "b", "c"]) 'a,b,c' >>> format_metadata('{platform#slice_str(-1, None, None)#to_upper}', platform="sentinel-1a") 'A'
Queryables#
The list_queryables() method will help you to dynamically check which
parameters are queryable for a given provider or collection.
See Python API User Guide / Queryables
for more information and examples.