Skip to content

Stac extension

STACExtension

Bases: BaseModel

Model for STAC Extension.

Parameters:

Name Type Description Default
url str

Extension URL.

required
prefix str

Extension prefix.

required
properties list[str]

Extension properties.

required
Source code in extraction_methods/plugins/stac_extension.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class STACExtension(BaseModel):
    """
    Model for STAC Extension.
    """

    url: str = Field(
        description="Extension URL.",
    )
    prefix: str = Field(
        description="Extension prefix.",
    )
    properties: list[str] = Field(
        description="Extension properties.",
    )

STACExtensionExtract

Bases: ExtractionMethod

Accepts a list of extensions which contain url, prefix and list of properties.

Method name: stac_extension

Example Configuration

.. code-block:: yaml

- method: stac_extension
  inputs:
    extensions:
      - url: hello.com/v1.0.0/world.json
        prefix: hello
        properties:
          - foo
          - bar
Source code in extraction_methods/plugins/stac_extension.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class STACExtensionExtract(ExtractionMethod):
    """
    Accepts a list of extensions which contain url, prefix and
    list of properties.

    **Method name:** ``stac_extension``

    Example Configuration:
        .. code-block:: yaml

            - method: stac_extension
              inputs:
                extensions:
                  - url: hello.com/v1.0.0/world.json
                    prefix: hello
                    properties:
                      - foo
                      - bar
    """

    input_class = STACExtensionInput

    @update_input
    def run(self, body: dict[str, Any]) -> dict[str, Any]:

        extension_urls = []
        for extension in self.input.extensions:
            extension_urls.append(extension.url)
            for property_name in extension.properties:
                if property_name in body:
                    body[f"{extension.prefix}:{property_name}"] = body.pop(
                        property_name
                    )

        body["stac_extensions"] = body.get("stac_extensions", []) + extension_urls

        return body

STACExtensionInput

Bases: Input

Model for STAC Extension Input.

Parameters:

Name Type Description Default
extensions list[STACExtension]

List of extensions.

required
Source code in extraction_methods/plugins/stac_extension.py
39
40
41
42
43
44
45
46
class STACExtensionInput(Input):
    """
    Model for STAC Extension Input.
    """

    extensions: list[STACExtension] = Field(
        description="List of extensions.",
    )