### Install EODag with All Providers Source: https://eodag.readthedocs.io/en/stable/breaking_changes Installs the EODag library with all available providers using pip. This command ensures that all necessary dependencies for every supported provider are included in the installation. ```bash # install eodag with all available providers supported pip install "eodag[all-providers]" ``` -------------------------------- ### EODAG Discover Command Examples (Console) Source: https://eodag.readthedocs.io/en/stable/_sources/cli_user_guide Demonstrates basic and advanced usage of the 'eodag discover' command to find available products. This command can be used with or without specifying a provider and can also load custom product type configurations. ```console eodag discover eodag discover -p planetary_computer eodag discover -p planetary_computer --storage my_product_types_conf.json ``` -------------------------------- ### Basic eodag search and download in Python Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_fedeo_ceda Demonstrates a fundamental eodag workflow: initializing the API, searching for products based on criteria (like start date, end date, and geographic extent), and downloading the first found product. This requires the 'eodag' library to be installed. ```python from eodag import EOProduct from eodag.api.core import EOProduct # Initialize the EOProduct API api = EOProduct() # Define search criteria search_criteria = { 'start': '2022-01-01', 'end': '2022-01-31', 'geom': { 'type': 'Point', 'coordinates': [2.3522, 48.8566] # Example: Paris coordinates }, 'collection': 'S2MSI1C' } # Search for products products = api.search(**search_criteria) # Check if any products were found if products: # Get the first product product = products[0] # Download the product product.download(path='/path/to/download/directory') print(f"Downloaded product: {product.properties['title']}") else: print("No products found matching the criteria.") ``` -------------------------------- ### EODAG Setup and Basic Search (Python) Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_fedeo_ceda Demonstrates how to initialize the EODAG library and perform a basic search for EO data products. This involves creating an EODAG instance and using its search methods to query for specific criteria. It assumes EODAG is installed and configured with a supported data access point. ```python from eodag import EOProduct, EODAG # Initialize EODAG with a configuration (e.g., default or a custom one) eodag = EODAG() # Perform a basic search for products # Example: Search for Sentinel-1 products in a specific region and date range search_results = eodag.search(productType='S1', geom='POLYGON((11.0 45.0, 11.0 46.0, 12.0 46.0, 12.0 45.0, 11.0 45.0))', startDate='2023-01-01', endDate='2023-01-31', limit=10) # Iterate through the search results for product in search_results: print(f"Found product: {product.properties['title']}") print(f" ID: {product.properties['id']}") print(f" Size: {product.properties['size']}") ``` -------------------------------- ### Python: Basic EODAG Product Search Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_fedeo_ceda This Python snippet demonstrates how to initialize EODAG, search for products based on specified criteria (like start date, end date, and geographic BBOX), and retrieve a list of matching products. It requires the 'eodag' library to be installed. ```python from eodag import EOProduct, from eodag.api.core import EODataAccessGateway # Initialize EODAG api = EODataAccessGateway() # Define search criteria start_date = "2023-01-01" end_date = "2023-01-31" bbox = {"lonmin": -10, "latmin": 40, "lonmax": 0, "latmax": 50} # Search for products (e.g., Sentinel-1 products) products = api.search(productType='S1T', start=start_date, end=end_date, bbox=bbox) # Process the search results for product in products: print(f"Found product: {product.title} - {product.properties['creation_time']}") ``` -------------------------------- ### Basic EODAG Search and Download in Python Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_meteoblue Demonstrates the fundamental usage of EODAG to search for products based on criteria and initiate a download. This snippet requires the EODAG library to be installed and configured with at least one data access provider. ```python from eodag import EOProduct # Initialize an EODAG instance (assuming default configuration or a configured config file) from eodag import SearchCriteria from eodag import EOProduct from eodag import StakeholderStatus from eodag import Api api = Api() # Define search criteria search_criteria = SearchCriteria( {'start': '2020-01-01T00:00:00Z', 'end': '2020-12-31T23:59:59Z'}, {'maxCloudCover': 10} ) # Search for products (example for a specific product type and geometry) products = api.search(productType='SENTINEL-1', geom='POINT: 2.35, 48.86', criteria=search_criteria) # Check if any products were found if products: # Select the first product and initiate download product_to_download = products[0] print(f"Found product: {product_to_download.properties.title}") # Example of downloading the product (ensure download directory exists) # product_to_download.download(path='/path/to/your/download/directory') # print(f"Download initiated for {product_to_download.properties.title}") else: print("No products found matching the criteria.") ``` -------------------------------- ### Chain Search and Download Commands (CLI) Source: https://eodag.readthedocs.io/en/stable/cli_user_guide This example demonstrates command chaining, where the output of an `eodag search` command is directly piped to the `eodag download` command. This allows for a streamlined workflow, enabling users to search for products and initiate their download in a single, continuous operation without saving intermediate results. ```bash eodag search --productType S2_MSI_L1C --bbox 1 43 2 44 --start 2025-03-01 download ``` -------------------------------- ### CLI: Search and Download EO Products with EODAG Source: https://eodag.readthedocs.io/en/stable/index This example shows how to use the EODAG command-line interface to search for and download Earth Observation products. It first performs a search using specific parameters and then initiates the download using the results from the search. This requires the EODAG CLI to be installed and configured. ```bash eodag search --productType S2_MSI_L1C --box 1 43 2 44 --start 2021-03-01 --end 2021-03-31 eodag download --search-results search_results.geojson ``` -------------------------------- ### EODAG Configuration Example (YAML) Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_dedt_lumi_roi This is an example of an EODAG configuration file in YAML format. It shows how to define data providers, their endpoints, authentication methods, and supported product types. ```yaml stac_api: type: "STAC" api_endpoint: "https://earth-search.aws.element84.com/v1" auth: [] item_fields: - "id" - "properties.datetime" - "properties.proj:bbox" - "properties.collection" products: - "sentinel-2-l2a" - "sentinel-1-grd" # Example for another provider (e.g., a custom one) custom_provider: type: "REST" api_endpoint: "http://my-eo-data.com/api" auth: - type: "basic" username: "user" password: "pass" products: - "MY_CUSTOM_PRODUCT" ``` -------------------------------- ### Asset Class Initialization Source: https://eodag.readthedocs.io/en/stable/_modules/eodag/api/product/_assets Describes the initialization of the Asset class, its parameters, and provides an example. ```APIDOC ## Asset Class ### Description Represents a single asset within an EOProduct. ### Method __init__ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None - **product** (EOProduct) - The EOProduct this asset belongs to. - **key** (str) - The unique identifier for the asset. - **args** (Any) - Optional arguments used to initialize the dictionary. - **kwargs** (Any) - Optional additional named-arguments used to initialize the dictionary. ### Request Example ```python from eodag.api.product import EOProduct product = EOProduct( provider="foo", properties={"id": "bar", "geometry": "POINT (0 0)"} ) product.assets.update({"foo": {"href": "http://somewhere/something"}}) ``` ### Response #### Success Response (200) None (Initialization does not return a value). #### Response Example None ``` -------------------------------- ### Install EODAG using Pip Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_meteoblue Installs the EODAG Python package and its dependencies using pip. Ensure you have Python and pip installed on your system. ```bash pip install eodag ``` -------------------------------- ### Basic EODAG Usage Example Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_cds Demonstrates how to initialize EODAG, search for products, and download a product. This requires an internet connection and access to supported data providers. ```python from eodag import EODAG # Initialize EODAG eodag = EODAG() # Search for products (example: Sentinel-1, GRD, Europe, date range) products = eodag.search(productType='S1RF', geom='POLYGON((2.5 48.5, 3.5 48.5, 3.5 49.5, 2.5 49.5, 2.5 48.5))', start='2023-01-01', end='2023-01-31') # Select a product to download product_to_download = products.iloc[0] # Download the product eodag.download(product_to_download) ``` -------------------------------- ### Initialize EODAG and Search for Products Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_dedt_lumi_roi Demonstrates how to initialize the EODAG instance and perform a basic search for products based on specified criteria. It shows how to set up authentication and filter search results. ```python from eodag import EOProduct, EODAG api = EODAG() products = api.search_eop(query={"collection": "sentinel-1", "box": [-25.0, 30.0, -15.0, 40.0]}) # Optionally, you can access the first product for more details if products: first_product = EOProduct(products[0], api=api) print(f"Found {len(products)} products. First product ID: {first_product.properties.get('title')}") else: print("No products found.") ``` -------------------------------- ### file_position_from_s3_zip Source: https://eodag.readthedocs.io/en/stable/api_reference/utils Gets the start position and size of a file within a ZIP archive stored in S3. ```APIDOC ## GET /file_position_from_s3_zip ### Description Get the start position and size of a specific file inside a ZIP archive stored in S3. This function assumes the file is uncompressed (ZIP_STORED). ### Method GET ### Endpoint /file_position_from_s3_zip ### Parameters #### Query Parameters - **s3_bucket** (str) - Required - The S3 bucket name. - **object_key** (str) - Required - The S3 object key for the ZIP file. - **s3_client** (S3Client) - Required - The Boto3 S3 client. - **target_filepath** (str) - Required - The file path inside the ZIP archive to locate. ### Response #### Success Response (200) - **tuple** (tuple[int, int]) - A tuple containing (file_data_start, file_size). #### Error Response - **FileNotFoundError**: If the target file is not found in the ZIP archive. - **NotImplementedError**: If the file is not uncompressed (ZIP_STORED). ``` -------------------------------- ### EOProduct Download Methods Source: https://eodag.readthedocs.io/en/stable/api_reference/eoproduct This snippet demonstrates the download functionalities of the EOProduct class. It shows how to initiate a download for an EO product using the `download()` method and how to retrieve a quicklook image if available. ```python from eodag.api.product._product import EOProduct # Assuming 'product' is an instance of EOProduct # Download the product to the local filesystem try: product.download() print(f"Product downloaded successfully to: {product.location}") except Exception as e: print(f"Error downloading product: {e}") # Get a quicklook image (if available) try: quicklook_path = product.get_quicklook() print(f"Quicklook available at: {quicklook_path}") except Exception as e: print(f"Could not retrieve quicklook: {e}") ``` -------------------------------- ### Example GeoJSON Data for Leaflet Map Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_cop_dem An example of GeoJSON data structure representing a Polygon feature, suitable for adding to a Leaflet map via the 'geo_json_1cafae43389544b0a95bbbb978333112_add' function. Includes geometry, properties, and metadata. ```json {"features": [{"geometry": {"coordinates": [[[2.0, 43.0], [3.0, 43.0], [3.0, 44.0], [2.0, 44.0], [2.0, 43.0]]], "type": "Polygon"}, "id": "DEM1_SAR_DGE_30_20110216T174143_20140906T174215_ADS_000000_jSLP", "properties": {"abstract": "The Copernicus DEM is a Digital Surface Model (DSM) that represents the surface of the Earth including buildings, infrastructure and vegetation. Data were acquired through the TanDEM-X mission between 2011 and 2015 [https://spacedata.copernicus.eu/collections/copernicus-digital-elevation-model].", "accessConstraint": {"description": {"shortName": "No license"}, "grantedCountries": null, "grantedFlags": null, "grantedOrganizationCountries": null, "hasToBeSigned": "never", "licenseId": "unlicensed", "signatureQuota": -1, "viewService": "public"}, "centroid": {"coordinates": [2.5, 43.5], "type": "Point"}, "completionTimeFromAscendingNode": "2014-09-06T17:42:15.000Z", "downloadLink": "https://zipper.creodias.eu/download/e2d2e6dd-198f-53b0-9b93-f898ab28cf8c", "eodag_product_type": "COP_DEM_GLO30_DGED", "eodag_provider": "creodias", "eodag_search_intersection": {"coordinates": [[[2.0, 43.9], [2.8, 43.9], [2.8, 43.2], [2.0, 43.2], [2.0, 43.9]]], "type": "Polygon"}, "gmlgeometry": "\u003cgml:Polygon srsName=\"EPSG:4326\"\u003e\u003cgml:outerBoundaryIs\u003e\u003cgml:LinearRing\u003e\u003cgml:coordinates\u003e2,43 3,43 3,44 2,44 2,43\u003c/gml:coordinates\u003e\u003c/gml:LinearRing\u003e\u003c/gml:outerBoundaryIs\u003e\u003c/gml:Polygon\u003e", "instrument": null, "keywords": "TerraSAR,TanDEM-X,DEM,surface,GLO-30,DSM,GDGED", "license": "other", "links": [{"href": "https://datahub.creodias.eu/resto/collections/COP-DEM/e2d2e6dd-198f-53b0-9b93-f898ab28cf8c.json", "rel": "self", "title": "GeoJSON link for e2d2e6dd-198f-53b0-9b93-f898ab28cf8c", "type": "application/json"}], "missionStartDate": "2010-06-21T00:00:00Z", "modificationDate": "2021-06-21T22:01:44.918Z", "orbitNumber": 0, "organisationName": "ESA", "parentIdentifier": null, "platform": "COP-DEM", "platformSerialIdentifier": "", "polarizationMode": "HH", "processingLevel": null, "productIdentifier": "/eodata/auxdata/CopDEM/COP-DEM_GLO-30-DGED/DEM1_SAR_DGE_30_20110216T174143_20140906T174215_ADS_000000_jSLP.DEM", "productType": "DGE_30", "publicationDate": "2021-06-21T22:01:44.918Z", "quicklook": null, "resolution": 30.0, "sensorMode": null, "sensorType": "ALTIMETRIC", "services": {"download": {"mimeType": "application/octet-stream", "size": 0, "url": "https://datahub.creodias.eu/download/e2d2e6dd-198f-53b0-9b93-f898ab28cf8c"}}, "snowCover": 0, "startTimeFromAscendingNode": "2011-02-16T17:41:43.000Z", "storageStatus": "ONLINE", "thumbnail": "https://datahub.creodias.eu/get-object?path=/auxdata/CopDEM/COP-DEM_GLO-30-DGED/DEM1_SAR_DGE_30_20110216T174143_20140906T174215_ADS_000000_jSLP.DEM/DEM1_SAR_DGE_30_20110216T174143_20140906T174215_ADS_000000_jSLP-ql.jpg", "title": "DEM1_SAR_DGE_30_20110216T174143_20140906T174215_ADS_000000_jSLP", "uid": "e2d2e6dd-198f-53b0-9b93-f898ab28cf8c"}, "type": "Feature"}, {"geometry": {"coordinates": [[[1.0, 43.0], [2.0, 43.0], [2.0, 44.0], [1.0, 44.0], [1.0, 43.0]]], "type" ``` -------------------------------- ### Initialize EODAG and Set Provider Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_meteoblue Initializes the EODataAccessGateway with optional logging and sets the preferred provider to 'meteoblue'. This is the starting point for interacting with EODAG. ```python import datetime from eodag import EODataAccessGateway, setup_logging setup_logging(1) # 0: nothing, 1: only progress bars, 2: INFO, 3: DEBUG dag = EODataAccessGateway() dag.set_preferred_provider("meteoblue") ``` -------------------------------- ### EODAG Serve REST Command Help (Console) Source: https://eodag.readthedocs.io/en/stable/_sources/cli_user_guide Displays the help information for the 'eodag serve-rest' command, which is used to start a STAC-compliant REST API server for EODAG. ```console eodag serve-rest --help ``` -------------------------------- ### Initialize and Configure eodag Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_fedeo_ceda Demonstrates how to initialize the eodag instance and load configuration files, which is essential for setting up data providers and authentication. ```python from eodag import EOProduct, EODAGApplication # Initialize EODAG with a custom configuration file config = { "data_access_protocol": "rest", "api_endpoint": "https://earth.esa.int/web/veda/rest/api/search/", "outputs": { "default": { "path": "./outputs" } } } eodag = EODAGApplication(config=config) # Or load configuration from a YAML file # eodag = EODAGApplication(config_path='path/to/your/config.yml') ``` -------------------------------- ### Get Product Metadata Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_ecmwf This example demonstrates how to retrieve detailed metadata for a given Earth Observation product. It accesses the `properties` attribute of an `EOProduct` object, which contains various metadata fields. ```python from eodag import EOProduct, Search # Assuming 'products' is a list of EOProduct objects from a previous search if products: product_with_metadata = products[0] metadata = product_with_metadata.properties print(metadata) ``` -------------------------------- ### Basic EODAG Search and Download Example Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_cds Demonstrates a fundamental workflow using EODAG to search for products based on criteria and then download a selected product. This requires an EODAG configuration file or default settings to be in place. ```python from eodag import EOProduct, SearchCriteria # Initialize EODAG with default configuration from eodag.api import EODataAccessGateway gateway = EODataAccessGateway() # Define search criteria search_criteria = SearchCriteria(productType='S2MSI_L1C', start='2023-01-01', end='2023-01-31', geom='POINT(10 50)') # Search for products products = gateway.search(search_criteria) # Check if any products were found if products: # Get the first product product_to_download = products[0] # Download the product download_path = gateway.download(product_to_download) print(f"Downloaded product to: {download_path}") else: print("No products found matching the criteria.") ``` -------------------------------- ### Start EODAG REST API Server Source: https://eodag.readthedocs.io/en/stable/cli_user_guide This command starts the EODAG HTTP server, which provides a STAC compliant REST API. It can be configured with a path to the user configuration file, location shapefiles, and options for daemon mode, network binding, and debugging. The server listens on a specified port, defaulting to 5000. Note that this feature is deprecated and moved to a separate repository. ```bash $ eodag serve-rest --help Usage: eodag serve-rest [OPTIONS] (deprecated) Start eodag HTTP server Running a web server from the CLI is deprecated and will be removed in a future version. This feature has been moved to its own repository: https://github.com/CS-SI/stac-fastapi-eodag Set EODAG_CORS_ALLOWED_ORIGINS environment variable to configure Cross- Origin Resource Sharing allowed origins as comma-separated URLs (e.g. 'http://somewhere,http://somewhere.else'). Options: -f, --config PATH File path to the user configuration file with its credentials, default is ~/.config/eodag/eodag.yml -l, --locs PATH File path to the location shapefiles configuration file -d, --daemon run in daemon mode -w, --world run uvicorn using IPv4 0.0.0.0 (all network interfaces), otherwise bind to 127.0.0.1 (localhost). -p, --port INTEGER The port on which to listen [default: 5000] --debug Run in debug mode (for development purpose) --help Show this message and exit. ``` -------------------------------- ### Python: Initialize EODAG and Search for Products Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_fedeo_ceda This Python snippet demonstrates how to initialize the EODAG interface and perform a basic search for data products. It requires the `eodag` library to be installed. The search is typically performed against a configured data access endpoint. ```python from eodag import EOProduct, EODataAccessGateway # Initialize EODAG with a specific configuration (e.g., 'creodias') g = EODataAccessGateway('creodias') # Define search criteria search_params = { "start": "2023-01-01T00:00:00Z", "end": "2023-01-31T23:59:59Z", "collection": "sentinel-1-grd", "intersects": { "type": "Point", "coordinates": [2.3522, 48.8566] # Example coordinates for Paris }, "productType": "S1GRD" } # Perform the search products = g.search(**search_params) # Print the number of found products print(f"Found {len(products)} products.") # Example: Accessing a product's metadata if products: first_product = products[0] print(f"First product ID: {first_product.properties.get('title')}") print(f"Product metadata: {first_product.properties}") ``` -------------------------------- ### EODAG Plugin Example Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_dedt_lumi_roi Demonstrates how to use custom EODAG plugins. Plugins allow extending EODAG's functionality, such as adding support for new data providers or custom search criteria. Ensure the plugin is installed and configured. ```python from eodag import EODAGContext # Assuming 'my_custom_plugin' is installed and configured with EODAGContext(plugins=['my_custom_plugin']) as dag: products = dag.search(productType='Sentinel-1') print(products) ``` -------------------------------- ### Initialize eodag and search for products (Python) Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_dedt_lumi_roi Demonstrates how to initialize the eodag framework and perform a basic search for products based on specified criteria. This is a fundamental step for data discovery within the eodag ecosystem. It requires the eodag library to be installed. ```python from eodag import EOProduct, SearchCriteria from eodag.api.core import EOProduct from eodag.api.search import SearchCriteria # Initialize eodag with default configuration eodag_instance = EOProduct() # Define search criteria search_criteria = SearchCriteria( collection="SENTINEL-2", geom="POINT(10.5 45.5)", start="2023-01-01T00:00:00Z", end="2023-01-31T23:59:59Z", productType="S2MSI_LEVEL2A" ) # Perform the search products = eodag_instance.search(search_criteria) # Print the number of found products print(f"Found {len(products)} products.") ``` -------------------------------- ### Get eodag Package Version Source: https://eodag.readthedocs.io/en/stable/_modules/eodag/api/core Retrieves the installed version of the eodag package. This function relies on the 'version' function from the 'importlib_metadata' module (or similar package versioning tools). It returns a string representing the package version. ```python def get_version(self) -> str: """Get eodag package version""" return version("eodag") ``` -------------------------------- ### Search for products using default configuration Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_cds This example shows how to perform a product search using the default eodag configuration. It specifies search criteria such as collection, start date, and end date. ```python from eodag import EODataBase eodag = EODataBase() # Search for Sentinel-1 products between two dates products = eodag.search(collection="SENTINEL-1", from_date="2020-01-01T00:00:00Z", to_date="2020-01-31T23:59:59Z") print(f"Found {len(products)} products.") ``` -------------------------------- ### EODAG Configuration Example Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_dedt_lumi_roi Demonstrates how to configure EODAG, specifying the data access gateway to use. This is essential for setting up EODAG to connect to your chosen data sources. ```python from eodag import EOProduct, SearchCriteria from eodag.api.core import EOProduct, SearchCriteria # Configure EODAG to use the 'creodias' provider config = { 'data_access_gateways': { 'creodias': { 'api_endpoint': 'https://finder.creodias.eu/resto/api/collections/all/search' } } } # Create an EOProduct instance with the configuration product = EOProduct(config=config) # Define search criteria search_criteria = SearchCriteria(keyword='Copernicus', geom='POLYGON((2.5 48.8, 2.5 49.1, 2.8 49.1, 2.8 48.8, 2.5 48.8))') # Search for products results = product.search(search_criteria) # Print the first result's title if results: print(f"Found product: {results[0].properties['title']}") else: print("No products found.") ``` -------------------------------- ### Initialize EODAG and Search for Data Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_dedt_lumi_roi This Python snippet demonstrates how to initialize the EODAG object and perform a search for satellite data based on specified criteria such as product type, start and end dates, and geographical area. It requires the 'eodag' library to be installed. ```python from eodag import EOProduct from eodag.api.core import EOProduct from eodag import setup_logging setup_logging(level=2) # EOProduct is an alias for EOProduct, which is a registered plugin # You can instantiate it directly product = EOProduct("Awesome-Pleiades") # Example of a search with more options # product.search(query={"collections": ["S2MSI1C"], "bbox": [2.5, 41.5, 2.7, 41.7], "startDate": "2020-01-01T00:00:00Z", "completionDate": "2020-01-01T12:00:00Z"}) product.search(count=1, query={"collections": ["S2MSI1C"], "bbox": [2.5, 41.5, 2.7, 41.7], "startDate": "2020-01-01T00:00:00Z", "completionDate": "2020-01-01T12:00:00Z"}) # Example of searching for products by name # product.search(productType="S2MSI1C", # box="2,41.5,2.7,41.7", # start="2020-01-01", # end="2020-01-01", # count=1) ``` -------------------------------- ### Initialize Leaflet GeoJSON Layer with Feature Handling Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_cop_dem Defines a Leaflet GeoJSON layer and an associated 'onEachFeature' function. This setup is used to handle individual features when they are added to the map, though the provided 'onEachFeature' is currently empty. ```javascript function geo_json_1cafae43389544b0a95bbbb978333112_onEachFeature(feature, layer) { layer.on({ }); }; var geo_json_1cafae43389544b0a95bbbb978333112 = L.geoJson(null, { onEachFeature: geo_json_1cafae43389544b0a95bbbb978333112_onEachFeature, }); ``` -------------------------------- ### Python: Basic EODAG Search and Download Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_dedt_lumi_roi Demonstrates how to initialize EODAG, search for products based on criteria like date, geometry, and product type, and download the found products. This function requires the 'eodag' library to be installed and configured with an appropriate product provider. ```python from eodag import EOProduct, SearchCriteria from eodag.api.core import EODataAccessGateway # Initialize EODAG with a product provider dwg = EODataAccessGateway() # Define search criteria search_criteria = SearchCriteria(geom={'lon': 2.35, 'lat': 48.85}, start='2023-01-01', end='2023-01-31', productType='S2MSI_L2A') # Search for products products = dwg.search(criteria=search_criteria) # Download the first product if found if products: product_to_download = products[0] download_dir = './downloads' product_to_download.download(path=download_dir) print(f"Downloaded: {product_to_download.properties['title']}") else: print("No products found for the given criteria.") ``` -------------------------------- ### EODAG Configuration Management in Python Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_meteoblue This example demonstrates how to load and manage EODAG configurations, including specifying a custom configuration file path. This is useful for setting up specific providers, authentication methods, or download directories. ```python from eodag import Api # Path to your custom EODAG configuration file custom_config_path = '/path/to/your/eodag_config.yml' # Initialize EODAG with a custom configuration try: api = Api(config=custom_config_path) print(f"EODAG initialized with configuration: {custom_config_path}") # You can now use the 'api' object for searches and downloads except FileNotFoundError: print(f"Error: Configuration file not found at {custom_config_path}") except Exception as e: print(f"An error occurred during EODAG initialization: {e}") # Example of accessing available providers after initialization # print("Available providers:", api.available_providers) ``` -------------------------------- ### Initialize EODataAccessGateway and Setup Workspace Source: https://eodag.readthedocs.io/en/stable/notebooks/tutos/tuto_ship_detection Initializes the `EODataAccessGateway` from the `eodag` library and sets up a workspace directory for storing downloaded data and configuration. It also configures logging for `eodag` and creates a custom `eodag_conf.yml` file to specify the download output directory and extraction behavior. ```python from eodag.api.core import EODataAccessGateway from eodag import setup_logging setup_logging(verbose=2) # Create the workspace folder. workspace = 'eodag_workspace_shipdetection' if not os.path.isdir(workspace): os.mkdir(workspace) # Save the PEPS configuration file. yaml_content = """ peps: download: output_dir: "{}" extract: true """.format(os.path.abspath(workspace)) with open(os.path.join(workspace, 'eodag_conf.yml'), "w") as f_yml: f_yml.write(yaml_content.strip()) dag = EODataAccessGateway(os.path.join(workspace, 'eodag_conf.yml')) ``` -------------------------------- ### Search for Products Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_ecmwf This example shows how to perform a search for Earth Observation products using EODAG. It includes parameters like `geom` for geographic extent, `start` and `end` for time range, and `productType` to filter results. The output is a list of EOProduct objects. ```python from shapely.geometry import Polygon # Define search parameters geom = Polygon([(10, 40), (15, 40), (15, 45), (10, 45), (10, 40)]) start = "2020-01-01T00:00:00Z" end = "2020-01-31T23:59:59Z" product_type = "SENTINEL-1" # Perform the search products = search.products( geom=geom, start=start, end=end, productType=product_type ) ``` -------------------------------- ### Python: Initialize EO-DAG Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_cds Demonstrates how to initialize the EO-DAG object, which is the main entry point for interacting with the library. It shows the basic setup required before performing any data access operations. ```python from eodag import EODataAccessGateway # Initialize EODataAccessGateway with EODataAccessGateway() as dag: # Your operations here pass ``` -------------------------------- ### Search and Download Earth Observation Products (Bash) Source: https://eodag.readthedocs.io/en/stable/_sources/index This bash command-line example shows how to use the EODAG CLI to search for Sentinel 2 Level-1C products based on a bounding box and date range, and then download the results. It assumes EODAG CLI is installed and configured. ```bash eodag search --productType S2_MSI_L1C --box 1 43 2 44 --start 2021-03-01 --end 2021-03-31 eodag download --search-results search_results.geojson ``` -------------------------------- ### Start EODAG STAC REST API Server Source: https://eodag.readthedocs.io/en/stable/_sources/stac_rest This command initiates the EODAG STAC REST API server. The server allows access to configured providers' data through a STAC-compliant interface. No specific dependencies are required beyond the eodag installation. ```console eodag serve-rest ``` -------------------------------- ### Setup EO Product Downloader Source: https://eodag.readthedocs.io/en/stable/_modules/eodag/api/core Configures the downloader and authentication for an EOProduct if they are not already set. It retrieves plugins from a plugin manager and registers them with the product. ```python def _setup_downloader(self, product: EOProduct) -> None: if product.downloader is None: downloader = self._plugins_manager.get_download_plugin(product) auth = product.downloader_auth if auth is None: auth = self._plugins_manager.get_auth_plugin(downloader, product) product.register_downloader(downloader, auth) ``` -------------------------------- ### Download a product using eodag Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_cds This example illustrates how to download a specific product found through a search query. It requires the product's unique identifier and the desired download directory. The `download_product` method handles the data transfer. ```python from eodag import EOAG # Assume 'product_id' is obtained from a search query product_id = 'your_product_identifier' # Download the product to a specified directory with EOAG(provider='creodias') as api: api.download_product(product_id, '/path/to/download/directory') ``` -------------------------------- ### Start EODAG STAC REST API Server Source: https://eodag.readthedocs.io/en/stable/stac_rest This command initiates the EODAG STAC REST API server. It's a simple CLI command to get the server running. Note that this method is deprecated and functionality has moved to a separate repository. ```bash eodag serve-rest ``` -------------------------------- ### Get available products for a specific provider in Python Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_fedeo_ceda This example shows how to retrieve a list of all available product types (collections) offered by a specific Earth Observation data provider using eodag. This is essential for knowing what data can be requested from a given source. ```python from eodag import EOProduct from eodag.api.core import EOProduct api = EOProduct() # Specify the provider you are interested in provider_name = 'onda' # Get available products for the specified provider products = api.list_products(provider=provider_name) if products: print(f"Available products from {provider_name}:") for product in products: print(f"- {product}") else: print(f"No products found for provider: {provider_name}") ``` -------------------------------- ### Initialize EODataAccessGateway Source: https://eodag.readthedocs.io/en/stable/_modules/eodag/api/core Initializes the EODataAccessGateway, setting up product type and provider configurations. It also manages the configuration directory, creating it if it doesn't exist and falling back to a temporary directory if necessary. Authentication and plugin managers are instantiated. ```python from __future__ import annotations import datetime import logging import os import re import shutil import tempfile from importlib.metadata import version from importlib.resources import files as res_files from operator import itemgetter from typing import TYPE_CHECKING, Any, Iterator, Optional, Union import geojson import yaml.parser from eodag.api.product.metadata_mapping import ( NOT_AVAILABLE, mtd_cfg_as_conversion_and_querypath, ) from eodag.api.search_result import SearchResult from eodag.config import ( PLUGINS_TOPICS_KEYS, PluginConfig, SimpleYamlProxyConfig, credentials_in_auth, get_ext_product_types_conf, load_default_config, load_stac_provider_config, load_yml_config, override_config_from_env, override_config_from_file, override_config_from_mapping, provider_config_init, share_credentials, ) from eodag.plugins.manager import PluginManager from eodag.plugins.search import PreparedSearch from eodag.plugins.search.build_search_result import MeteoblueSearch from eodag.plugins.search.qssearch import PostJsonSearch from eodag.types import model_fields_to_annotated from eodag.types.queryables import CommonQueryables, QueryablesDict from eodag.utils import ( DEFAULT_DOWNLOAD_TIMEOUT, DEFAULT_DOWNLOAD_WAIT, DEFAULT_ITEMS_PER_PAGE, DEFAULT_MAX_ITEMS_PER_PAGE, DEFAULT_PAGE, GENERIC_PRODUCT_TYPE, GENERIC_STAC_PROVIDER, HTTP_REQ_TIMEOUT, MockResponse, _deprecated, get_geometry_from_various, makedirs, sort_dict, string_to_jsonpath, uri_to_path, ) from eodag.utils.dates import rfc3339_str_to_datetime from eodag.utils.env import is_env_var_true from eodag.utils.exceptions import ( AuthenticationError, NoMatchingProductType, PluginImplementationError, RequestError, UnsupportedProductType, UnsupportedProvider, ) from eodag.utils.free_text_search import compile_free_text_query from eodag.utils.stac_reader import fetch_stac_items if TYPE_CHECKING: from shapely.geometry.base import BaseGeometry from eodag.api.product import EOProduct from eodag.plugins.apis.base import Api from eodag.plugins.crunch.base import Crunch from eodag.plugins.search.base import Search from eodag.types import ProviderSortables from eodag.types.download_args import DownloadConf from eodag.utils import DownloadedCallback, ProgressCallback, Unpack logger = logging.getLogger("eodag.core") class EODataAccessGateway: """An API for downloading a wide variety of geospatial products originating from different types of providers. :param user_conf_file_path: (optional) Path to the user configuration file :param locations_conf_path: (optional) Path to the locations configuration file """ def __init__( self, user_conf_file_path: Optional[str] = None, locations_conf_path: Optional[str] = None, ) -> None: product_types_config_path = os.getenv("EODAG_PRODUCT_TYPES_CFG_FILE") or str( res_files("eodag") / "resources" / "product_types.yml" ) self.product_types_config = SimpleYamlProxyConfig(product_types_config_path) self.providers_config = load_default_config() env_var_cfg_dir = "EODAG_CFG_DIR" self.conf_dir = os.getenv( env_var_cfg_dir, default=os.path.join(os.path.expanduser("~"), ".config", "eodag"), ) try: makedirs(self.conf_dir) except OSError as e: logger.debug(e) tmp_conf_dir = os.path.join(tempfile.gettempdir(), ".config", "eodag") logger.warning( f"Cannot create configuration directory {self.conf_dir}. " + f"Falling back to temporary directory {tmp_conf_dir}." ) if os.getenv(env_var_cfg_dir) is None: logger.warning( "You can set the path of the configuration directory " + f"with the environment variable {env_var_cfg_dir}" ) self.conf_dir = tmp_conf_dir makedirs(self.conf_dir) self._plugins_manager = PluginManager(self.providers_config) # use updated providers_config self.providers_config = self._plugins_manager.providers_config # First level override: From a user configuration file if user_conf_file_path is None: env_var_name = "EODAG_CFG_FILE" standard_configuration_path = os.path.join(self.conf_dir, "eodag.yml") user_conf_file_path = os.getenv(env_var_name) if user_conf_file_path is None: user_conf_file_path = standard_configuration_path if not os.path.isfile(standard_configuration_path): shutil.copy( str( res_files("eodag") / "resources" / "user_conf_template.yml" ) ``` -------------------------------- ### Access EO Data using EODAG (Python) Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_meteoblue Demonstrates how to initialize EODAG and search for EO data based on specified criteria. This snippet requires the 'eodag' library to be installed. It takes a dictionary of search parameters and returns a list of found products. ```python from eodag import EOProduct from eodag.api.product.drivers.sentinel import SentinelHub def search_eo_data(search_params): """Searches for EO data using EODAG. Args: search_params (dict): A dictionary containing search parameters. Returns: list: A list of EOProduct objects matching the search criteria. """ # Example: Initialize a specific provider (e.g., SentinelHub) # In a real scenario, you might configure EODAG globally or pass configuration provider_config = { 'name': 'sentinelhub', 'api_url': 'https://sh.mundialis.de/v1/collections/', 'products': { 'sentinel-1-grd': { 'id': 'S1GRD', 'geometry_field': 'intersects', 'time_field': 'date', 'properties': { 'title': 'Sentinel-1 GRD', 'platform': 'Sentinel-1', 'sensorType': 'SAR', 'orbitDirection': 'ASCENDING' } } } } provider = SentinelHub(config=provider_config) # Perform the search results = provider.search(**search_params) return results # Example usage: if __name__ == '__main__': example_params = { 'geom': { 'type': 'Point', 'coordinates': [13.3833, 52.5167] # Example: Berlin }, 'start': '2023-01-01T00:00:00Z', 'end': '2023-01-31T23:59:59Z', 'productType': 'sentinel-1-grd' } found_products = search_eo_data(example_params) print(f"Found {len(found_products)} products.") for product in found_products: print(f"- ID: {product.properties.get('title')}, Date: {product.properties.get('time')}") ``` -------------------------------- ### Downloading Products Source: https://eodag.readthedocs.io/en/stable/_sources/notebooks/tutos/tuto_dedt_lumi_roi Example of downloading a product found via the search functionality. EODAG handles the authentication and download process for supported providers. The `download_product` method takes a product object and an optional download directory. ```python from eodag import EODAGContext with EODAGContext() as dag: products = dag.search(productType='S2MSI1C', count=1) if products: dag.download_product(products[0], '/path/to/download/dir') ```