monkey_wrench.geometry package

class monkey_wrench.geometry.Area(*, area: ~typing.Annotated[~pathlib.Path, ~pydantic.types.PathType(path_type=file), ~pydantic.functional_validators.AfterValidator(func=~monkey_wrench.input_output._types.<lambda>)] | dict[str, ~typing.Any] | ~pyresample.geometry.AreaDefinition)[source]

Bases: Model

classmethod validate_and_load_area(area: ~typing.Annotated[~pathlib.Path, ~pydantic.types.PathType(path_type=file), ~pydantic.functional_validators.AfterValidator(func=~monkey_wrench.input_output._types.<lambda>)] | dict[str, ~typing.Any] | ~pyresample.geometry.AreaDefinition) AreaDefinition | None[source]
area: AreaDefinition

A filepath, a dictionary, or an object of type AreaDefinition which holds the area information for resampling.

class monkey_wrench.geometry.BoundingBox(north: float = None, south: float = None, west: float = None, east: float = None)[source]

Bases: BaseModel

Pydantic model for a bounding box.

Example

>>> BoundingBox(north=10, south=20, west=30, east=40)
BoundingBox(north=10.0, south=20.0, west=30.0, east=40.0)
>>> BoundingBox(10, 20, 30, 40)
BoundingBox(north=10.0, south=20.0, west=30.0, east=40.0)
serialize(as_string: bool = False, delimiter: str = ' ') list[float] | str[source]

Get the serialized version of the bounding box.

Parameters:
  • as_string – If True, return a string representation of the bounding box.

  • delimiter – The delimiter to use in the serialized version of the bounding box, if as_string is True. Defaults to a blank space.

Returns:

Either a string, or a list of floats as [<North>, <South>, <West>, <East>].

north: float
south: float
west: float
east: float
class monkey_wrench.geometry.Polygon(vertices: list[Vertex] = None)[source]

Bases: BaseModel

The Pydantic model for a polygon.

Example

>>> polygon: Polygon = Polygon(vertices=[
...  Vertex(14.0, 64.0),
...  Vertex(16.0, 64.0),
...  Vertex(16.0, 62.0),
...  Vertex(14.0, 62.0),
...  Vertex(14.0, 64.0),
... ])
serialize(as_string: bool = False) list[list[float]] | str[source]

Get the serialized version of the polygon.

Parameters:

as_string – If True, return a string representation of the polygon.

Returns:

Either a string, or a list of vertices, where each vertex is itself a list of floats.

vertices: list[Vertex]
class monkey_wrench.geometry.Vertex(longitude: float = None, latitude: float = None)[source]

Bases: BaseModel

Pydantic model for a vertex.

Example

>>> Vertex(longitude=10, latitude=20)
Vertex(longitude=10.0, latitude=20.0)
>>> Vertex(10, 20)
Vertex(longitude=10.0, latitude=20.0)
serialize(as_string: bool = False, delimiter: str = ' ') list[float] | str[source]

Get the serialized version of the vertex.

Parameters:
  • as_string – If True, return a string representation of the vertex.

  • delimiter – The delimiter to use in the serialized version of the vertex, if as_string is True. Defaults to a blank space.

Returns:

Either a string, or a list of floats as [<longitude>, <latitude>].

longitude: float
latitude: float

Submodules