EODataAccessGateway#
The EODataAccessGateway class is the core component of the EODAG library. It provides a unified interface for interacting with various Earth Observation data providers. This class allows users to configure providers, search for products, download data, and perform other operations related to Earth Observation data management. Below is an overview of its main functionalities, categorized for ease of use.
Constructor#
|
An API for downloading a wide variety of geospatial products originating from different types of providers. |
Configuration#
|
Adds a new provider. |
Set max priority for the given provider. |
|
Get the provider currently set as the preferred one for searching products, along with its priority. |
|
Update providers configuration with given input. |
|
Update eodag product types list |
Catalog#
Gives the sorted list of the available providers or groups |
|
Lists supported product types. |
|
Find EODAG product type IDs that best match a set of search parameters. |
|
Fetch product types list and update if needed. |
|
Fetch providers for product types |
Search#
|
Look for products matching criteria on known providers. |
Search and return all the products matching the search criteria. |
|
Iterate over the pages of a products search. |
Crunch#
|
Apply the filters given through the keyword arguments to the results |
|
Build a crunch plugin from a configuration |
Download#
|
Download a single product. |
|
Download all products resulting from a search. |
Serialize/Deserialize#
|
Registers results of a search into a geojson file. |
|
Loads results of a search from a geojson file. |
Loads results of a search from a geojson file and register products with the information needed to download itself |
Misc#
|
Combines multiple SearchResults and return a list of SearchResults grouped by extent (i.e. bounding box). |
Find EODAG product type IDs that best match a set of search parameters. |
|
Fetch the queryable properties for a given product type and/or provider. |
|
For each provider, gives its available sortable parameter(s) and its maximum number of them if it supports the sorting feature, otherwise gives None. |
|
|
Import STAC items from a list of URLs and convert them to SearchResult. |
- class eodag.api.core.EODataAccessGateway(user_conf_file_path=None, locations_conf_path=None)[source]#
An API for downloading a wide variety of geospatial products originating from different types of providers.
- Parameters:
- add_provider(name, url=None, priority=None, search={'type': 'StacSearch'}, products={'GENERIC_PRODUCT_TYPE': {'productType': '{productType}'}}, download={'auth_error_code': 401, 'type': 'HTTPDownload'}, **kwargs)[source]#
Adds a new provider.
search,products&downloadalready have default values that will be updated (not replaced), with user provided ones:search:{"type": "StacSearch"}products:{"GENERIC_PRODUCT_TYPE": {"productType": "{productType}"}}download:{"type": "HTTPDownload", "auth_error_code": 401}
- Parameters:
name (
str) – Name of providerurl (
str|None, default:None) – Provider url, also used assearch["api_endpoint"]if not definedpriority (
int|None, default:None) – Provider priority. If None, provider will be set as preferred (highest priority)search (
dict[str,Any], default:{'type': 'StacSearch'}) – SearchPluginConfigmappingproducts (
dict[str,Any], default:{'GENERIC_PRODUCT_TYPE': {'productType': '{productType}'}}) – Provider product types mappingdownload (
dict[str,Any], default:{'type': 'HTTPDownload', 'auth_error_code': 401}) – DownloadPluginConfigmapping
- available_providers(product_type=None, by_group=False)[source]#
Gives the sorted list of the available providers or groups
The providers or groups are sorted first by their priority level in descending order, and then alphabetically in ascending order for providers or groups with the same priority level.
- Parameters:
- Return type:
- Returns:
the sorted list of the available providers or groups
- available_sortables()[source]#
For each provider, gives its available sortable parameter(s) and its maximum number of them if it supports the sorting feature, otherwise gives None.
- Return type:
- Returns:
A dictionary with providers as keys and dictionary of sortable parameter(s) and its (their) maximum number as value(s).
- Raises:
- crunch(results, **kwargs)[source]#
Apply the filters given through the keyword arguments to the results
- Parameters:
results (
SearchResult) – The results of a eodag search requestkwargs (
Any)
- Return type:
- Returns:
The result of successively applying all the filters to the results
- static deserialize(filename)[source]#
Loads results of a search from a geojson file.
- Parameters:
filename (
str) – A filename containing a search result encoded as a geojson- Return type:
- Returns:
The search results encoded in filename
- deserialize_and_register(filename)[source]#
Loads results of a search from a geojson file and register products with the information needed to download itself
- Parameters:
filename (
str) – A filename containing a search result encoded as a geojson- Return type:
- Returns:
The search results encoded in filename
- download(product, progress_callback=None, wait=0.2, timeout=10, **kwargs)[source]#
Download a single product.
This is an alias to the method of the same name on
EOProduct, but it performs some additional checks like verifying that a downloader and authenticator are registered for the product before trying to download it.If the metadata mapping for
downloadLinkis set to something that can be interpreted as a link on a local filesystem, the download is skipped (by now, only a link starting withfile:/is supported). Therefore, any user that knows how to extract product location from product metadata on a provider can override thedownloadLinkmetadata mapping in the right way. For example, using the environment variable:EODAG__CREODIAS__SEARCH__METADATA_MAPPING__DOWNLOADLINK="file:///{id}"will lead to allEOProduct’s originating from the providercreodiasto have theirdownloadLinkmetadata point to something like:file:///12345-678, making this method immediately return the later string without trying to download the product.- Parameters:
product (
EOProduct) – The EO product to downloadprogress_callback (
ProgressCallback|None, default:None) – (optional) A method or a callable object which takes a current size and a maximum size as inputs and handle progress bar creation and update to give the user a feedback on the download progresswait (
float, default:0.2) – (optional) If download fails, wait time in minutes between two download triestimeout (
float, default:10) – (optional) If download fails, maximum time in minutes before stop retrying to downloadkwargs (
Unpack[DownloadConf]) –Additional keyword arguments from the download plugin configuration class that can be provided to override any other values defined in a configuration file or with environment variables:
output_dir- where to store downloaded products, as an absolute file path (Default: local temporary directory)output_extension- downloaded file extensionextract- whether to extract the downloaded products, only applies to archived productsdl_url_params- additional parameters to pass over to the download url as an url parameterdelete_archive- whether to delete the downloaded archivesasset- regex filter to identify assets to download
- Return type:
- Returns:
The absolute path to the downloaded product in the local filesystem
- Raises:
- Raises:
- download_all(search_result, downloaded_callback=None, progress_callback=None, wait=0.2, timeout=10, **kwargs)[source]#
Download all products resulting from a search.
- Parameters:
search_result (
SearchResult) – A collection of EO products resulting from a searchdownloaded_callback (
DownloadedCallback|None, default:None) – (optional) A method or a callable object which takes as parameter theproduct. You can use the base classDownloadedCallbackand override its__call__method. Will be called each time a product finishes downloadingprogress_callback (
ProgressCallback|None, default:None) – (optional) A method or a callable object which takes a current size and a maximum size as inputs and handle progress bar creation and update to give the user a feedback on the download progresswait (
float, default:0.2) – (optional) If download fails, wait time in minutes between two download tries of the same producttimeout (
float, default:10) – (optional) If download fails, maximum time in minutes before stop retrying to downloadkwargs (
Unpack[DownloadConf]) –Additional keyword arguments from the download plugin configuration class that can be provided to override any other values defined in a configuration file or with environment variables:
output_dir- where to store downloaded products, as an absolute file path (Default: local temporary directory)output_extension- downloaded file extensionextract- whether to extract the downloaded products, only applies to archived productsdl_url_params- additional parameters to pass over to the download url as an url parameterdelete_archive- whether to delete the downloaded archivesasset- regex filter to identify assets to download
- Return type:
- Returns:
A collection of the absolute paths to the downloaded products
- fetch_product_types_list(provider=None)[source]#
Fetch product types list and update if needed.
If strict mode is enabled (by setting the
EODAG_STRICT_PRODUCT_TYPESenvironment variable to a truthy value), this method will not fetch or update product types and will return immediately.
- get_preferred_provider()[source]#
Get the provider currently set as the preferred one for searching products, along with its priority.
- static group_by_extent(searches)[source]#
Combines multiple SearchResults and return a list of SearchResults grouped by extent (i.e. bounding box).
- Parameters:
searches (
list[SearchResult]) – List of eodag SearchResult- Return type:
- Returns:
list of
SearchResult
- guess_product_type(free_text=None, intersect=False, instrument=None, platform=None, platformSerialIdentifier=None, processingLevel=None, sensorType=None, keywords=None, abstract=None, title=None, missionStartDate=None, missionEndDate=None, **kwargs)[source]#
Find EODAG product type IDs that best match a set of search parameters.
When using several filters, product types that match most of them will be returned at first.
- Parameters:
free_text (
str|None, default:None) – Free text search filter used to search accross all the following parameters. Handles logical operators with parenthesis (AND/OR/NOT), quoted phrases ("exact phrase"),*and?wildcards.intersect (
bool, default:False) – Join results for each parameter using INTERSECT instead of UNION.instrument (
str|None, default:None) – Instrument parameter.platformSerialIdentifier (
str|None, default:None) – Platform serial identifier parameter.processingLevel (
str|None, default:None) – Processing level parameter.sensorType (
str|None, default:None) – Sensor type parameter.missionStartDate (
str|None, default:None) – start date for datetime filtering. Not used by free_textmissionEndDate (
str|None, default:None) – end date for datetime filtering. Not used by free_textkwargs (
Any)
- Return type:
- Returns:
The best match for the given parameters.
- Raises:
- import_stac_items(items_urls)[source]#
Import STAC items from a list of URLs and convert them to SearchResult.
Origin provider and download links will be set if item comes from an EODAG server.
If item comes from a known EODAG provider, result will be registered to it, ready to download and its metadata normalized.
If item comes from an unknown provider, a generic STAC provider will be used.
- list_product_types(provider=None, fetch_providers=True)[source]#
Lists supported product types.
- Parameters:
- Return type:
- Returns:
The list of the product types that can be accessed using eodag.
- Raises:
- list_queryables(provider=None, fetch_providers=True, **kwargs)[source]#
Fetch the queryable properties for a given product type and/or provider.
- Parameters:
- Raises:
UnsupportedProductType – If the specified product type is not available for the provider.
- Return type:
QueryablesDict- Returns:
A
QuerybalesDictcontaining the EODAG queryable properties, associating parameters to their annotated type, and a additional_properties attribute
- search(page=1, items_per_page=20, raise_errors=False, start=None, end=None, geom=None, locations=None, provider=None, count=False, validate=True, **kwargs)[source]#
Look for products matching criteria on known providers.
The default behaviour is to look for products on the provider with the highest priority supporting the requested product type. These priorities are configurable through user configuration file or individual environment variable. If the request to the provider with the highest priority fails or is empty, the data will be request from the provider with the next highest priority. Only if the request fails for all available providers, an error will be thrown.
- Parameters:
page (
int, default:1) – (optional) The page number to returnitems_per_page (
int, default:20) – (optional) The number of results that must appear in one single pageraise_errors (
bool, default:False) – (optional) When an error occurs when searching, if this is set to True, the error is raisedstart (
str|None, default:None) – (optional) Start sensing time in ISO 8601 format (e.g. “1990-11-26”, “1990-11-26T14:30:10.153Z”, “1990-11-26T14:30:10+02:00”, …). If no time offset is given, the time is assumed to be given in UTC.end (
str|None, default:None) – (optional) End sensing time in ISO 8601 format (e.g. “1990-11-26”, “1990-11-26T14:30:10.153Z”, “1990-11-26T14:30:10+02:00”, …). If no time offset is given, the time is assumed to be given in UTC.geom (
str|dict[str,float] |BaseGeometry|None, default:None) –(optional) Search area that can be defined in different ways:
with a Shapely geometry object:
shapely.geometry.base.BaseGeometrywith a bounding box (dict with keys: “lonmin”, “latmin”, “lonmax”, “latmax”):
dict.fromkeys(["lonmin", "latmin", "lonmax", "latmax"])with a bounding box as list of float:
[lonmin, latmin, lonmax, latmax]with a WKT str
locations (
dict[str,str] |None, default:None) – (optional) Location filtering by name using locations configuration{"<location_name>"="<attr_regex>"}. For example,{"country"="PA."}will use the geometry of the features having the property ISO3 starting with ‘PA’ such as Panama and Pakistan in the shapefile configured with name=country and attr=ISO3provider (
str|None, default:None) – (optional) the provider to be used. If set, search fallback will be disabled. If not set, the configured preferred provider will be used at first before trying others until finding results.count (
bool, default:False) – (optional) Whether to run a query with a count request or notvalidate (
bool|None, default:True) – (optional) Set to True to validate search parameters before sending the query to the providerkwargs (
Any) – Some other criteria that will be used to do the search, using paramaters compatibles with the provider
- Return type:
- Returns:
A collection of EO products matching the criteria
Changed in version v3.0.0b1:
search()method now returns only a singleSearchResultinstead of a 2 values tuple.Note
The search interfaces, which are implemented as plugins, are required to return a list as a result of their processing. This requirement is enforced here.
- search_all(items_per_page=None, start=None, end=None, geom=None, locations=None, **kwargs)[source]#
Search and return all the products matching the search criteria.
It iterates over the pages of a search query and collects all the returned products into a single
SearchResultinstance.Requests are attempted to all providers of the product ordered by descending piority.
- Parameters:
items_per_page (
int|None, default:None) – (optional) The number of results requested internally per page. The maximum number of items than can be requested at once to a provider has been configured in EODAG for some of them. If items_per_page is None and this number is available for the searched provider, it is used to limit the number of requests made. This should also reduce the time required to collect all the products matching the search criteria. If this number is not available, a default value of 50 is used instead. items_per_page can also be set to any arbitrary value.start (
str|None, default:None) – (optional) Start sensing time in ISO 8601 format (e.g. “1990-11-26”, “1990-11-26T14:30:10.153Z”, “1990-11-26T14:30:10+02:00”, …). If no time offset is given, the time is assumed to be given in UTC.end (
str|None, default:None) – (optional) End sensing time in ISO 8601 format (e.g. “1990-11-26”, “1990-11-26T14:30:10.153Z”, “1990-11-26T14:30:10+02:00”, …). If no time offset is given, the time is assumed to be given in UTC.geom (
str|dict[str,float] |BaseGeometry|None, default:None) –(optional) Search area that can be defined in different ways:
with a Shapely geometry object:
shapely.geometry.base.BaseGeometrywith a bounding box (dict with keys: “lonmin”, “latmin”, “lonmax”, “latmax”):
dict.fromkeys(["lonmin", "latmin", "lonmax", "latmax"])with a bounding box as list of float:
[lonmin, latmin, lonmax, latmax]with a WKT str
locations (
dict[str,str] |None, default:None) – (optional) Location filtering by name using locations configuration{"<location_name>"="<attr_regex>"}. For example,{"country"="PA."}will use the geometry of the features having the property ISO3 starting with ‘PA’ such as Panama and Pakistan in the shapefile configured with name=country and attr=ISO3kwargs (
Any) – Some other criteria that will be used to do the search, using parameters compatible with the provider
- Return type:
- Returns:
An iterator that yields page per page a collection of EO products matching the criteria
- search_iter_page(items_per_page=20, start=None, end=None, geom=None, locations=None, **kwargs)[source]#
Iterate over the pages of a products search.
- Parameters:
items_per_page (
int, default:20) – (optional) The number of results requested per pagestart (
str|None, default:None) – (optional) Start sensing time in ISO 8601 format (e.g. “1990-11-26”, “1990-11-26T14:30:10.153Z”, “1990-11-26T14:30:10+02:00”, …). If no time offset is given, the time is assumed to be given in UTC.end (
str|None, default:None) – (optional) End sensing time in ISO 8601 format (e.g. “1990-11-26”, “1990-11-26T14:30:10.153Z”, “1990-11-26T14:30:10+02:00”, …). If no time offset is given, the time is assumed to be given in UTC.geom (
str|dict[str,float] |BaseGeometry|None, default:None) –(optional) Search area that can be defined in different ways:
with a Shapely geometry object:
shapely.geometry.base.BaseGeometrywith a bounding box (dict with keys: “lonmin”, “latmin”, “lonmax”, “latmax”):
dict.fromkeys(["lonmin", "latmin", "lonmax", "latmax"])with a bounding box as list of float:
[lonmin, latmin, lonmax, latmax]with a WKT str
locations (
dict[str,str] |None, default:None) – (optional) Location filtering by name using locations configuration{"<location_name>"="<attr_regex>"}. For example,{"country"="PA."}will use the geometry of the features having the property ISO3 starting with ‘PA’ such as Panama and Pakistan in the shapefile configured with name=country and attr=ISO3kwargs (
Any) – Some other criteria that will be used to do the search, using paramaters compatibles with the provider
- Return type:
- Returns:
An iterator that yields page per page a collection of EO products matching the criteria
- static serialize(search_result, filename='search_results.geojson')[source]#
Registers results of a search into a geojson file.
- Parameters:
search_result (
SearchResult) – A collection of EO products resulting from a searchfilename (
str, default:'search_results.geojson') – (optional) The name of the file to generate
- Return type:
- Returns:
The name of the created file