Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ permissions:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ['3.10']
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ git push && git push --tags
- [Creodias OpenSearch](https://finder.creodias.eu/resto/api/collections/describe.xml)
- [Creodias Sentinel1](https://finder.creodias.eu/resto/api/collections/Sentinel1/describe.xml)
- [Creodias Sentinel2](https://finder.creodias.eu/resto/api/collections/Sentinel2/describe.xml)
- [EOEPCA+ develop resource catalogue](https://resource-catalogue.apx.develop.eoepca.org/collections)

### Inspiration

Expand Down
19 changes: 18 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lxml = "^5.3.0"
geojson-pydantic = "^1.1.2"
rio-stac = "^0.10.1"
rasterio = "^1.4.3"
owslib = "^0.34.1"


[tool.poetry.group.dev.dependencies]
Expand Down
55 changes: 52 additions & 3 deletions src/eodm/extract.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Iterator, Optional

import pystac_client
from owslib.ogcapi.records import Records
from pystac import Collection, Item

from .opensearch import OpenSearchClient, OpenSearchFeature
Expand Down Expand Up @@ -59,9 +60,7 @@ def extract_stac_api_collections(url: str) -> Iterator[Collection]:


def extract_opensearch_features(
url: str,
product_types: list[str],
limit: int = 0,
url: str, product_types: list[str], limit: int = 0
) -> Iterator[OpenSearchFeature]:
"""Extracts OpenSearch Features from an OpenSearch API

Expand All @@ -83,3 +82,53 @@ def extract_opensearch_features(
if limit and i >= limit:
break
yield feature


def extract_ogcapi_records_catalogs(url: str) -> Iterator[dict]:
"""Extracts OGC API Records from an OGC API Records endpoint

Args:
url (str): Link to OGC API Records endpoint

Yields:
Iterator[Item]: OGC API Records Catalogs(collections)
"""

records = Records(url)
for record in records.collections()["collections"]:
yield record


def extract_ogcapi_records(
url: str,
catalog_ids: list[str],
datetime_interval: str | None = None,
bbox: list[float] | None = None,
filter: str | None = None,
limit: int | None = None,
) -> Iterator[dict]:
"""Extracts OGC API Records from an OGC API Records endpoint

Args:
url (str): Link to OGC API Records endpoint
catalog_ids (list[str]): List of catalog/collection IDs to search for
datetime_interval (str | None, optional): Datetime interval to search. ISO8601
datetime or interval Defaults to None.
bbox (list[float, float, float, float] | None, optional): Bounding box to search.
filter (str, optional): CQL filter to apply. Defaults to None.
limit (int | None, optional): Limit query to given number. Defaults to None.

Yields:
Iterator[Item]: OGC API Records Items
"""

records = Records(url)
for catalog_id in catalog_ids:
for record in records.collection_items(
catalog_id,
bbox=bbox,
datetime_=datetime_interval,
filter=filter,
limit=limit,
)["features"]:
yield record
16 changes: 16 additions & 0 deletions tests/test_ogcapi_records.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from eodm.extract import extract_ogcapi_records, extract_ogcapi_records_catalogs


def test_extract_ogcapi_records_catalogs():
url = "https://resource-catalogue.apx.develop.eoepca.org"
for i in extract_ogcapi_records_catalogs(url):
assert i["type"] == "catalog"


def test_extract_ogcapi_records():
url = "https://resource-catalogue.apx.develop.eoepca.org"
catalog_ids = ["S2MSI1C"]
datetime_interval = "2018-01-01/2020-01-01"
bbox = [15.7308, 47.4577, 17.2709, 48.2459]
for i in extract_ogcapi_records(url, catalog_ids, datetime_interval, bbox):
assert i["type"] == "Feature"
Loading