Skip to content

Bbox

BboxExtract

Bases: ExtractionMethod

Converts a coordinate values to RFC 7946, section 5 <https://tools.ietf.org/html/rfc7946#section-5>_ formatted bbox.

Method name: bbox

Example Configuration

.. code-block:: yaml

- method: bbox
  inputs:
    west: 0
    south: 0
    east: $east_variable
    north: $north_variable
Source code in extraction_methods/plugins/bbox.py
41
42
43
44
45
46
47
48
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
class BboxExtract(ExtractionMethod):
    """
    Converts a coordinate values to `RFC 7946,
    section 5 <https://tools.ietf.org/html/rfc7946#section-5>`_ formatted bbox.

    **Method name:** ``bbox``

    Example Configuration:
        .. code-block:: yaml

            - method: bbox
              inputs:
                west: 0
                south: 0
                east: $east_variable
                north: $north_variable
    """

    input_class = BboxInput

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

        try:
            body["bbox"] = {
                "type": "envelope",
                "coordinates": [
                    [
                        float(self.input.west),
                        float(self.input.south),
                    ],
                    [
                        float(self.input.east),
                        float(self.input.north),
                    ],
                ],
            }

        except (TypeError, KeyError):
            LOGGER.warning("Unable to convert bbox.", exc_info=True)

        return body

BboxInput

Bases: Input

Model for BBox Method Input.

Parameters:

Name Type Description Default
west float | str

west coordinate.

required
south float | str

south coordinate.

required
east float | str

east coordinate.

required
north float | str

north coordinate.

required
Source code in extraction_methods/plugins/bbox.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class BboxInput(Input):
    """
    Model for BBox Method Input.
    """

    west: float | str = Field(
        description="west coordinate.",
    )
    south: float | str = Field(
        description="south coordinate.",
    )
    east: float | str = Field(
        description="east coordinate.",
    )
    north: float | str = Field(
        description="north coordinate.",
    )