### Querying Products by Sensing Date Range in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This Python snippet demonstrates filtering products by their sensing start date (`ContentDate/Start`) within a specific date range. It uses the `requests` library to perform the GET request, parses the JSON response, and converts the results into a Pandas DataFrame. The head of selected columns ('Id', 'Name', 'S3Path', 'GeoFootprint') is then displayed. Dependencies: `requests`, `pandas`. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=ContentDate/Start gt 2019-05-15T00:00:00.000Z and ContentDate/Start lt 2019-05-16T00:00:00.000Z").json() df = pd.DataFrame.from_dict(json['value']) ``` -------------------------------- ### Querying Products by Date Range (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Retrieves products from the OData API by filtering based on a specific date range for both the start and end content dates. The fetched JSON data is converted into a pandas DataFrame, and the initial rows for selected columns are displayed. Requires `requests` and `pandas`. ```Python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=ContentDate/Start gt 2019-05-15T00:00:00.000Z and ContentDate/End lt 2019-05-15T00:05:00.000Z").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData API with Skip using Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates fetching data from the Copernicus Data Space Ecosystem OData API using the requests library, including the $skip=20 query parameter to retrieve results starting from the 21st item for pagination. The JSON response is parsed and loaded into a pandas DataFrame, then the head of specified columns ('Id', 'Name', 'S3Path', 'GeoFootprint') is printed. Requires the requests and pandas libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-1' and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'IW_GRDH_1S') and ContentDate/Start gt 2022-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T12:00:00.000Z&$skip=20").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Fetching OData Data with Count in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates fetching data from an OData endpoint that includes the `$count=True` option. It uses the requests library to make an HTTP GET request, parses the JSON response, converts the data list found under the 'value' key into a pandas DataFrame, and then displays the first 3 rows of specific columns. Requires the 'requests' and 'pandas' libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=Collection/Name eq 'SENTINEL-1' and DeletionDate gt 2023-04-01T00:00:00.000Z and DeletionDate lt 2023-05-30T23:59:59.999Z&$orderby=DeletionDate desc&$count=True").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying CCM Products by Date and Area (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Fetches products from the Copernicus Data Space Ecosystem OData API for the 'CCM' collection, filtering by intersection with a specific polygon and a date range (Start and End). The response is parsed as JSON and loaded into a pandas DataFrame, then specific columns are displayed. Requires the `requests` and `pandas` libraries. ```Python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'CCM' and OData.CSC.Intersects(area=geography'SRID=4326;POLYGON((12.655118166047592 47.44667197521409,21.39065656328509 48.347694733853245,28.334291357162826 41.877123516783655,17.47086198383573 40.35854475076158,12.655118166047592 47.44667197521409))') and ContentDate/Start gt 2021-05-20T00:00:00.000Z and ContentDate/Start lt 2021-07-21T00:00:00.000Z").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData Endpoint with Requests and Pandas in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet fetches data from the Copernicus Dataspace DeletedProducts OData endpoint by sending an HTTP GET request with a filter for specific attributes (orbitNumber and orbitDirection). It uses the `requests` library for the GET request and converts the JSON response into a pandas DataFrame. Finally, it displays the first three rows of a subset of columns from the resulting DataFrame. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=Attributes/OData.CSC.IntegerAttribute/any(att:att/Name eq 'orbitNumber' and att/OData.CSC.IntegerAttribute/Value eq 10844) and attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'orbitDirection' and att/OData.CSC.StringAttribute/Value eq 'ASCENDING')").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Products by Collection Name (CCM) in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This Python snippet demonstrates filtering products belonging to the 'CCM' (Copernicus Contributing Missions) collection using the OData `$filter` parameter. It retrieves the data via a GET request, parses the JSON response, creates a Pandas DataFrame from the results, and outputs the head of specific columns. Dependencies: `requests`, `pandas`. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'CCM'").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Copernicus OData by Dataset Filter (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates how to query the Copernicus Data Space Ecosystem OData catalogue for products belonging to a specific dataset ('VHR_IMAGE_2018') using the $filter option. It fetches the data via HTTP GET, parses the JSON response, converts the results into a pandas DataFrame, and then prints the head of selected columns. Requires the 'requests' and 'pandas' libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'datasetFull' and att/OData.CSC.StringAttribute/Value eq 'VHR_IMAGE_2018')").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Downloading Product | curl Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This 'curl' command downloads a specific product from the Copernicus Data Space Ecosystem download API using its UUID. It requires an 'Authorization' header containing a 'Bearer' token obtained through the authentication process. The '--location-trusted' flag is used to follow redirects, and the '--output' flag specifies the local file path where the downloaded product will be saved. ```curl curl -H "Authorization: Bearer $ACCESS_TOKEN" 'https://catalogue.dataspace.copernicus.eu/odata/v1/Products(060882f4-0a34-5f14-8e25-6876e4470b0d)/$value' --location-trusted --output /tmp/product.zip ``` -------------------------------- ### Downloading Compressed Product | curl Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This 'curl' command downloads a product in its native compressed format using the OData API's '/$zip' endpoint suffix. It requires an 'Authorization' header with a valid bearer token. The '--location-trusted' flag handles redirects, and the '--output' flag specifies the local path for the downloaded zip file. ```curl curl -H "Authorization: Bearer $ACCESS_TOKEN" 'https://catalogue.dataspace.copernicus.eu/odata/v1/Products(002f0c9e-8a4c-465b-9e03-479475947630)/$zip' --location-trusted --output /tmp/product.zip ``` -------------------------------- ### Querying OData API Expanding Assets using Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates querying the Copernicus Data Space Ecosystem OData API using the requests library, including the $expand=Assets parameter. This option retrieves additional assets associated with each product, such as quicklooks. The JSON response is loaded into a pandas DataFrame, and the head of selected columns ('Id', 'Name', 'S3Path', 'GeoFootprint') is printed. Requires the requests and pandas libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-3' and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'SL_2_FRP___')&$expand=Assets").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData Products with Expand | Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet fetches product data from the Copernicus Data Space OData catalogue API using 'requests'. It includes the '$expand=Locations' query parameter to retrieve associated location details. The JSON response is then loaded into a pandas DataFrame for easier analysis and display of selected columns like 'Id', 'Name', 'S3Path', and 'GeoFootprint'. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-1' and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'IW_RAW__0S')&$orderby=ContentDate/Start desc&$top=10&$expand=Locations").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Copernicus OData with Orderby (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet shows how to query the Copernicus Data Space Ecosystem OData catalogue, filtering by collection ('SENTINEL-1'), product type, and content date range, and then ordering the results by 'ContentDate/Start' in descending order using the $orderby option. It fetches the data, parses the JSON, converts to a pandas DataFrame, and prints the head of selected columns. Requires the 'requests' and 'pandas' libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-1' and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'EW_GRDM_1S') and ContentDate/Start gt 2022-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T03:00:00.000Z&$orderby=ContentDate/Start desc").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Sentinel-2 Products by Attributes (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This code queries the Copernicus Data Space Ecosystem OData API for Sentinel-2 products. It filters for products with cloud cover <= 40% and a content date between 2022-01-01 and 2022-01-03. It fetches the data using `requests`, parses the JSON response, loads the 'value' list into a pandas DataFrame, and then selects and prints specific columns. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name%20eq%20%27SENTINEL-2%27%20and%20Attributes/OData.CSC.DoubleAttribute/any(att:att/Name eq 'cloudCover' and att/OData.CSC.DoubleAttribute/Value le 40.00) and ContentDate/Start gt 2022-01-01T00:00:00.000Z and ContentDate/Start lt 2022-01-03T00:00:00.000Z&$top=10").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Copernicus OData with Top Limit (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates querying the Copernicus Data Space Ecosystem OData catalogue, filtering by collection ('SENTINEL-1'), product type, and content date range, and limiting the number of results to 100 using the $top option. It fetches the data, parses the JSON response, converts the results into a pandas DataFrame, and prints the head of selected columns. Requires the 'requests' and 'pandas' libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-1' and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'EW_GRDM_1S') and ContentDate/Start gt 2022-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T12:00:00.000Z&$top=100").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Products by Polygon and Date (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Queries the OData API for products that intersect a specified geographic polygon and fall within a given date range (based on ContentDate/Start). The results are parsed into a pandas DataFrame, and the first three rows with selected columns are printed. Requires `requests` and `pandas`. ```Python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=OData.CSC.Intersects(area=geography'SRID=4326;POLYGON((12.655118166047592 47.44667197521409,21.39065656328509 48.347694733853245,28.334291357162826 41.877123516783655,17.47086198383573 40.35854475076158,12.655118166047592 47.44667197521409))') and ContentDate/Start gt 2022-05-20T00:00:00.000Z and ContentDate/Start lt 2022-05-21T00:00:00.000Z").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData API Expanding Attributes using Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates querying the Copernicus Data Space Ecosystem OData API using the requests library, including the $expand=Attributes parameter. This option retrieves the full metadata for each product in the results. The JSON response is loaded into a pandas DataFrame, and the head of selected columns ('Id', 'Name', 'S3Path', 'GeoFootprint') is printed. Requires the requests and pandas libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-1' and ContentDate/Start gt 2022-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T12:00:00.000Z&$expand=Attributes").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Copernicus OData with Skip Offset (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet shows how to query the Copernicus Data Space Ecosystem OData catalogue, filtering by collection ('SENTINEL-1'), product type, and content date range, and skipping the first 23 results using the $skip option. It fetches the data, parses the JSON response, and converts the results into a pandas DataFrame for further processing. Requires the 'requests' and 'pandas' libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-1' and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'EW_GRDM_1S') and ContentDate/Start gt 2022-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T12:00:00.000Z&$skip=23").json() df = pd.DataFrame.from_dict(json['value']) ``` -------------------------------- ### Querying Products by Collection Name (SENTINEL-2) in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This Python snippet shows how to filter products by a specific collection name ('SENTINEL-2') using the OData `$filter` option. It fetches the data, converts the response into a Pandas DataFrame, and displays the first few rows for the 'Id', 'Name', 'S3Path', and 'GeoFootprint' columns. Requires `requests` and `pandas`. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-2'").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData Endpoint with Skip Option in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet retrieves data from the Copernicus Dataspace DeletedProducts OData endpoint, filtering by the 'SENTINEL-2' collection and a content date range. It uses the `$skip=30` option to skip the first 30 results, allowing for pagination. The returned data is loaded into a pandas DataFrame, and the first three rows of selected columns are printed. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=Collection/Name eq 'SENTINEL-2' and ContentDate/Start ge 2021-04-01T00:00:00.000Z and ContentDate/Start le 2021-04-30T23:59:59.999Z&$skip=30").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData Endpoint with Top Option in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet fetches data from the Copernicus Dataspace DeletedProducts OData endpoint, filtering by the 'SENTINEL-1' collection and a content date range. It utilizes the `$top=40` option to limit the number of results returned to a maximum of 40. The fetched JSON data is loaded into a pandas DataFrame, and the first three rows of selected columns are displayed. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=Collection/Name eq 'SENTINEL-1' and ContentDate/Start ge 2021-09-01T00:00:00.000Z and ContentDate/Start le 2021-09-30T23:59:59.999Z&$top=40").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Deleted Products by Collection and Date - OData API - Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Queries the Copernicus OData API for deleted products within a specific collection ('SENTINEL-2') and deleted within a defined date range using the `$filter` parameter and logical `and`. Processes the API's JSON response into a pandas DataFrame and displays the initial rows of selected columns. Depends on `requests` and `pandas` libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=Collection/Name eq 'SENTINEL-2' and DeletionDate gt 2023-04-01T00:00:00.000Z and DeletionDate lt 2023-09-30T23:59:59.999Z").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData Endpoint with Expand Option in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet fetches data from the Copernicus Dataspace DeletedProducts OData endpoint, applying a filter based on collection name and deletion date range. It includes the `$expand=Attributes` option in the query URL to retrieve full metadata for each result. The retrieved JSON data is parsed, loaded into a pandas DataFrame, and the first three rows of selected columns are printed. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=Collection/Name eq 'SENTINEL-1' and DeletionDate gt 2023-04-01T00:00:00.000Z and DeletionDate lt 2023-05-30T23:59:59.999Z&$expand=Attributes").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Sentinel-2 by Multiple Attributes (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates a more complex query for Sentinel-2 products from the OData API. It filters by cloud cover (< 10%), product type ('S2MSI2A'), orbit direction ('ASCENDING'), and a narrow date range (2022-05-03 00:00Z to 04:00Z). It fetches the data, loads it into a pandas DataFrame, and selects/prints specific columns. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-2' and Attributes/OData.CSC.DoubleAttribute/any(att:att/Name eq 'cloudCover' and att/OData.CSC.DoubleAttribute/Value lt 10.00) and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'S2MSI2A') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'orbitDirection' and att/OData.CSC.StringAttribute/Value eq 'ASCENDING') and ContentDate/Start gt 2022-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T04:00:00.000Z&$top=10").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Displaying Specific DataFrame Columns in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet defines a list of specific column names and then uses pandas indexing to select these columns from a DataFrame named `df`. It subsequently displays the first three rows of this reduced DataFrame using the `.head(3)` method. This requires the pandas library to be imported and a DataFrame `df` to exist. ```python columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying CCM Products by Collection and Date Range in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This Python snippet illustrates filtering 'CCM' collection products within a specified date range (`ContentDate/Start`). It fetches data using `requests`, converts the JSON response to a Pandas DataFrame, and prints the head of the 'Id', 'Name', 'S3Path', and 'GeoFootprint' columns. Dependencies: `requests`, `pandas`. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'CCM' and ContentDate/Start gt 2005-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T00:11:00.000Z").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Deleted Products | Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This Python snippet uses the 'requests' library to query the OData 'DeletedProducts' endpoint of the Copernicus Data Space catalogue. It applies filters based on collection name and deletion date range, and orders the results by deletion date. The JSON response is then parsed and loaded into a pandas DataFrame for analysis. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=Collection/Name eq 'SENTINEL-1' and DeletionDate gt 2023-04-01T00:00:00.000Z and DeletionDate lt 2023-05-30T23:59:59.999Z&$orderby=DeletionDate&$top=20").json() df = pd.DataFrame.from_dict(json['value']) ``` -------------------------------- ### Querying Products with Complex Filter in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This Python snippet demonstrates how to query the OData Products endpoint using the `requests` library with a complex filter combining `not`, `and` operators, and date range criteria. It retrieves the results, parses the JSON response, converts the product list into a Pandas DataFrame, and displays the head of selected columns (`Id`, `Name`, `S3Path`, `GeoFootprint`). Requires `requests` and `pandas` libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=not (Collection/Name eq 'SENTINEL-2') and ContentDate/Start gt 2022-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T00:10:00.000Z&$orderby=ContentDate/Start&$top=100").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying SENTINEL-1 Products by Point and Top N (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Retrieves the top 20 products from the 'SENTINEL-1' collection that intersect a specified geographic point via an OData API call. The fetched JSON data is parsed and converted into a pandas DataFrame. Requires `requests` and `pandas`. ```Python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=OData.CSC.Intersects(area=geography'SRID=4326;POINT(-0.5319577002158441 28.65487836189358)') and Collection/Name eq 'SENTINEL-1'&$top=20").json() df = pd.DataFrame.from_dict(json['value']) ``` -------------------------------- ### Querying CCM Products by Polygon and Top N (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Makes an OData API call to retrieve the top 20 products from the 'CCM' collection that intersect a specified geographic polygon. The returned data is converted into a pandas DataFrame, and the initial rows with selected columns are displayed. Requires `requests` and `pandas`. ```Python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'CCM' and OData.CSC.Intersects(area=geography'SRID=4326;POLYGON((12.655118166047592 47.44667197521409,21.39065656328509 48.347694733853245,28.334291357162826 41.877123516783655,17.47086198383573 40.35854475076158,12.655118166047592 47.44667197521409))')&$top=20").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Deleted Products by Deletion Date - OData API - Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Fetches deleted product data from the Copernicus OData API, filtering by a specific deletion date range using the `$filter` parameter with `ge` and `le` operators. Parses the JSON response into a pandas DataFrame and displays the first three rows of selected columns ('Id', 'Name', 'DeletionCause', 'GeoFootprint'). Requires the `requests` and `pandas` libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=DeletionDate ge 2023-04-26T00:00:00.000Z and DeletionDate le 2023-04-27T23:59:59.999Z").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Deleted Products by Cause - OData API - Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Retrieves deleted products from the Copernicus OData API, filtered by specific deletion causes ('Duplicated product' or 'Corrupted product') using the `$filter` parameter with `eq` and `or` operators. Converts the JSON response into a pandas DataFrame and outputs the head of key columns. Requires `requests` and `pandas` libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=DeletionCause eq 'Duplicated product' or DeletionCause eq 'Corrupted product'").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData API with Count using Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates querying the Copernicus Data Space Ecosystem OData API using the requests library and including the $count=True parameter to request the total number of results matching the query. While the $count is requested, the code snippet processes the 'value' array of the JSON response, loading it into a pandas DataFrame and printing the head of selected columns. Requires the requests and pandas libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'SENTINEL-1' and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'productType' and att/OData.CSC.StringAttribute/Value eq 'IW_GRDH_1S') and ContentDate/Start gt 2022-05-03T00:00:00.000Z and ContentDate/Start lt 2022-05-03T12:00:00.000Z&$count=True").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying Deleted Products by Sensing Date - OData API - Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Filters deleted products from the Copernicus OData API based on their sensing date range (`ContentDate/Start` and `ContentDate/End`) using the `$filter` parameter. The code fetches data, converts the JSON `value` into a pandas DataFrame, and shows the first three rows of specific columns. Requires the `requests` and `pandas` libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=ContentDate/Start gt 2021-09-01T00:00:00.000Z and ContentDate/End lt 2021-09-01T00:05:00.000Z").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Selecting Columns from Pandas DataFrame (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet demonstrates how to select and display specific columns ('Id', 'Name', 'S3Path', 'GeoFootprint') from the first few rows (head) of a pandas DataFrame named `df`. It requires a pandas DataFrame `df` to be already populated with data, likely from a previous API call. ```python columns_to_print = ['Id', 'Name','S3Path','GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Selecting Specific Columns - Pandas - Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Demonstrates how to filter a pandas DataFrame `df` to show only a specific list of columns defined by `columns_to_print`. It then displays the first three rows of the filtered DataFrame. Requires the `pandas` library and a DataFrame `df` to be already loaded. ```python columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying OData Endpoint with Orderby in Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This snippet retrieves data from the Copernicus Dataspace DeletedProducts OData endpoint, applying a filter based on the 'SENTINEL-1' collection and a date range for 'DeletionDate'. It also incorporates the `$orderby` option to sort the results by 'DeletionDate' in descending order. The fetched JSON data is then converted into a pandas DataFrame, and the first three rows of selected columns are displayed. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=Collection/Name eq 'SENTINEL-1' and DeletionDate gt 2023-04-01T00:00:00.000Z and DeletionDate lt 2023-05-30T23:59:59.999Z&$orderby=DeletionDate desc").json() df = pd.DataFrame.from_dict(json['value']) # Print only specific columns columns_to_print = ['Id', 'Name', 'DeletionCause', 'GeoFootprint'] df[columns_to_print].head(3) ``` -------------------------------- ### Querying CCM Products by Geography and Attributes (Python) Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md This code queries the OData API for CCM (Copernicus Contributing Mission) products. It filters for products that geometrically intersect a specified polygon (SRID=4326), have the platform name 'WorldView-3', and fall within a date range (2022-05-20 to 2022-07-21). It fetches the data using `requests`, parses the JSON, and loads the 'value' list into a pandas DataFrame. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/Products?$filter=Collection/Name eq 'CCM' and OData.CSC.Intersects(area=geography'SRID=4326;POLYGON ((6.535492 50.600673, 6.535492 50.937662, 7.271576 50.937662, 7.271576 50.600673, 6.535492 50.600673))') and Attributes/OData.CSC.StringAttribute/any(att:att/Name eq 'platformName' and att/OData.CSC.StringAttribute/Value eq 'WorldView-3') and ContentDate/Start gt 2022-05-20T00:00:00.000Z and ContentDate/Start lt 2022-07-21T00:00:00.000Z").json() df = pd.DataFrame.from_dict(json['value']) ``` -------------------------------- ### Querying Deleted Products by Geographic Area - OData API - Python Source: https://github.com/alexandrosliaskos/odata/blob/main/OData.md Retrieves deleted products from the Copernicus OData API that intersect a specified geographic polygon using the `OData.CSC.Intersects` function, combined with a sensing date range filter. The code fetches data from the API and converts the JSON response's `value` array into a pandas DataFrame. Requires the `requests` and `pandas` libraries. ```python json = requests.get("https://catalogue.dataspace.copernicus.eu/odata/v1/DeletedProducts?$filter=OData.CSC.Intersects(area=geography'SRID=4326;POLYGON ((-75.000244 -42.4521508418609, -75.000244 -43.4409190460844, -73.643585 -43.432873907284, -73.66513 -42.4443775132447, -75.000244 -42.4521508418609))') and ContentDate/Start gt 2021-01-01T00:00:00.000Z and ContentDate/End lt 2021-04-01T23:59:59.999Z").json() df = pd.DataFrame.from_dict(json['value']) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.