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
The table of contents is too big for display.
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 @@ -60,7 +60,7 @@ jobs:
- name: Install project dependencies
run: poetry install
- name: Build the documentation
run: poetry run mkdocs build --strict --site-dir _site
run: poetry run mkdocs build --site-dir _site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ git push && git push --tags
- [EURAC STAC](https://stac.eurac.edu/)
- [EOEPCA develop STAC](https://eoapi.develop.eoepca.org/stac/)
- [EOX hub-int STAC](https://stac.hub-int.eox.at/)
- [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)

### Inspiration

Expand Down
25 changes: 23 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,28 @@

The section shows information about the API relevant for the developers.

::: eodm.extract
::: eodm.load
## Extractors

::: eodm.extract.extract_stac_api_items
::: eodm.extract.extract_stac_api_collections
::: eodm.extract.extract_opensearch_features

## Loaders

::: eodm.load.load_stac_api_items
::: eodm.load.load_stac_api_collections

## Opensearch

::: eodm.opensearch.OpenSearchClient
::: eodm.opensearch.OpenSearchFeature
::: eodm.opensearch.OpenSearchUrl

## Serializers

::: eodm.serializers


## STAC Contributions

::: eodm.stac_contrib
40 changes: 40 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ $ eodm extract [OPTIONS] COMMAND [ARGS]...
**Commands**:

* `openeo`: Extract data from openEO results
* `opensearch`: Extract features from a OpenSearch API
* `stac-api`: Extract data from a STAC API
* `stac-catalog`: Extract data from a STAC Catalog

Expand Down Expand Up @@ -74,6 +75,45 @@ $ eodm extract openeo results [OPTIONS] ASSET_NAME [RESULTS]

* `--help`: Show this message and exit.

### `eodm extract opensearch`

Extract features from a OpenSearch API

**Usage**:

```console
$ eodm extract opensearch [OPTIONS] COMMAND [ARGS]...
```

**Options**:

* `--help`: Show this message and exit.

**Commands**:

* `features`: Extract features found in an OpenSearch...

#### `eodm extract opensearch features`

Extract features found in an OpenSearch API given a product type

**Usage**:

```console
$ eodm extract opensearch features [OPTIONS] URL PRODUCT_TYPE
```

**Arguments**:

* `URL`: [required]
* `PRODUCT_TYPE`: [required]

**Options**:

* `-l, --limit INT`: Limit number of results [default: 0]
* `-o, --output [default|json]`: Output format. Default to STDOUT multiline [default: default]
* `--help`: Show this message and exit.

### `eodm extract stac-api`

Extract data from a STAC API
Expand Down
231 changes: 230 additions & 1 deletion poetry.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ rioxarray = "^0.15.5"
rio-cogeo = "^5.3.0"
rio-stac = "^0.9.0"
python-dateutil = "^2.9.0.post0"
lxml = "^5.3.0"
geojson-pydantic = "^1.1.2"


[tool.poetry.group.dev.dependencies]
Expand All @@ -38,6 +40,7 @@ mkdocs-material-extensions = "^1.3.1"
pytest-cov = "^6.0.0"
pytest-mock = "^3.14.0"
respx = "^0.21.1"
types-lxml = "^2024.12.13"


[tool.commitizen]
Expand Down
46 changes: 46 additions & 0 deletions src/eodm/cli/extract/apps/opensearch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from typing import Annotated

import typer

from eodm.cli._serialization import serialize
from eodm.cli._types import (
Output,
OutputType,
)
from eodm.extract import extract_opensearch_features

app = typer.Typer(no_args_is_help=True)


@app.callback()
def main():
"""
Extract features from a OpenSearch API
"""


@app.command(no_args_is_help=True)
def features(
url: str,
product_type: str,
limit: Annotated[
int,
typer.Option(
"--limit",
"-l",
metavar="INT",
help="Limit number of results",
),
] = 0,
output: OutputType = Output.default,
):
"""
Extract features found in an OpenSearch API given a product type
"""

features = extract_opensearch_features(
url=url,
product_types=[product_type],
limit=limit,
)
serialize(features, output_type=output)
2 changes: 2 additions & 0 deletions src/eodm/cli/extract/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import typer

from .apps.openeo import app as openeo
from .apps.opensearch import app as opensearch
from .apps.stac_api import app as stac_api
from .apps.stac_catalog import app as stac_catalog

Expand All @@ -12,3 +13,4 @@
app.add_typer(stac_api, name="stac-api")
app.add_typer(stac_catalog, name="stac-catalog")
app.add_typer(openeo, name="openeo")
app.add_typer(opensearch, name="opensearch")
33 changes: 31 additions & 2 deletions src/eodm/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import pystac_client
from pystac import Collection, Item

from .opensearch import OpenSearchClient, OpenSearchFeature


def extract_stac_api_items(
url: str,
Expand All @@ -13,7 +15,7 @@ def extract_stac_api_items(
query: dict | None = None,
filter: dict | None = None,
) -> Iterator[Item]:
"""Extracts items from a STAC API
"""Extracts STAC Items from a STAC API

Args:
url (str): Link to STAC API endpoint
Expand Down Expand Up @@ -43,7 +45,7 @@ def extract_stac_api_items(


def extract_stac_api_collections(url: str) -> Iterator[Collection]:
"""Extracts collections from a STAC API
"""Extracts STAC Collections from a STAC API

Args:
url (str): Link to STAC API endpoint
Expand All @@ -54,3 +56,30 @@ def extract_stac_api_collections(url: str) -> Iterator[Collection]:

client = pystac_client.Client.open(url)
yield from client.get_collections()


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

Args:
url (str): Link to OpenSearch API endpoint
productTypes (list[str]): List of productTypes to search for

Yields:
Iterator[OpenSearchFeature]: OpenSearch Features
"""
client = OpenSearchClient(url)

query = {}

# TODO: create mapper to map to STAC items
for product_type in product_types:
query["{eo:productType}"] = product_type
for i, feature in enumerate(client.search(query), start=1):
if limit and i >= limit:
break
yield feature
Loading
Loading