Skip to content

BoundingBox dataclass

Bases: Iterable[Coordinate]

A bounding box specifies the spatial extent of an area of interest.

ATTRIBUTE DESCRIPTION
x_min

minimum x coordinate

TYPE: Coordinate

y_min

minimum y coordinate

TYPE: Coordinate

x_max

maximum x coordinate

TYPE: Coordinate

y_max

maximum y coordinate

TYPE: Coordinate

x_min: Coordinate property writable

RETURNS DESCRIPTION
Coordinate

minimum x coordinate

y_min: Coordinate property writable

RETURNS DESCRIPTION
Coordinate

minimum y coordinate

x_max: Coordinate property writable

RETURNS DESCRIPTION
Coordinate

maximum x coordinate

y_max: Coordinate property writable

RETURNS DESCRIPTION
Coordinate

maximum y coordinate

from_gdf classmethod

Creates a bounding box from a geodataframe.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
BoundingBox

bounding box

buffer

Buffers the bounding box.

Examples:

Assume the area of interest is specified by x_min=363084, y_min=5715326, x_max=363340 and y_max=5715582.

You can expand the area of interest by buffering the bounding box.

>>> bounding_box = BoundingBox(
...     x_min=363084,
...     y_min=5715326,
...     x_max=363340,
...     y_max=5715582,
... )
>>> bounding_box.buffer(buffer_size=64)
BoundingBox(x_min=363020, y_min=5715262, x_max=363404, y_max=5715646)
PARAMETER DESCRIPTION
buffer_size

buffer size in meters

TYPE: BufferSize

inplace

if True, the bounding box is buffered inplace

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
BoundingBox

buffered bounding box

RAISES DESCRIPTION
AviaryUserError

Invalid buffer size (abs(buffer_size) >= half the width or height of the bounding box)

quantize

Quantizes the coordinates to the specified value.

Examples:

Assume the area of interest is specified by x_min=363084, y_min=5715326, x_max=363340 and y_max=5715582.

You can align the area of interest to a grid by quantizing the bounding box.

>>> bounding_box = BoundingBox(
...     x_min=363084,
...     y_min=5715326,
...     x_max=363340,
...     y_max=5715582,
... )
>>> bounding_box.quantize(value=64)
BoundingBox(x_min=363072, y_min=5715264, x_max=363392, y_max=5715584)
PARAMETER DESCRIPTION
value

value to quantize the coordinates to in meters

TYPE: int

inplace

if True, the bounding box is quantized inplace

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
BoundingBox

quantized bounding box

RAISES DESCRIPTION
AviaryUserError

Invalid value (value <= 0)

to_gdf

Converts the bounding box to a geodataframe.

PARAMETER DESCRIPTION
epsg_code

EPSG code

TYPE: EPSGCode

RETURNS DESCRIPTION
gpd.GeoDataFrame

bounding box