BoundingBox
Bases: Iterable[Coordinate]
A bounding box specifies the spatial extent of an area of interest.
PARAMETER | DESCRIPTION |
---|---|
x_min
|
Minimum x coordinate in meters
TYPE:
|
y_min
|
Minimum y coordinate in meters
TYPE:
|
x_max
|
Maximum x coordinate in meters
TYPE:
|
y_max
|
Maximum y coordinate in meters
TYPE:
|
x_min
property
RETURNS | DESCRIPTION |
---|---|
Coordinate
|
Minimum x coordinate in meters |
y_min
property
RETURNS | DESCRIPTION |
---|---|
Coordinate
|
Minimum y coordinate in meters |
x_max
property
RETURNS | DESCRIPTION |
---|---|
Coordinate
|
Maximum x coordinate in meters |
y_max
property
RETURNS | DESCRIPTION |
---|---|
Coordinate
|
Maximum y coordinate in meters |
area
property
RETURNS | DESCRIPTION |
---|---|
int
|
Area in square meters |
from_gdf
classmethod
Creates a bounding box from a geodataframe.
PARAMETER | DESCRIPTION |
---|---|
gdf
|
Geodataframe
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BoundingBox
|
Bounding box |
__eq__
Compares the bounding boxes.
PARAMETER | DESCRIPTION |
---|---|
other
|
Other bounding box
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the bounding boxes are equal, False otherwise |
__len__
Computes the number of coordinates.
RETURNS | DESCRIPTION |
---|---|
int
|
Number of coordinates |
__getitem__
Returns the coordinate.
PARAMETER | DESCRIPTION |
---|---|
index
|
Index of the coordinate
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Coordinate
|
Coordinate in meters |
__iter__
Iterates over the coordinates.
YIELDS | DESCRIPTION |
---|---|
Coordinate
|
Coordinate in meters |
__and__
Intersects the bounding boxes.
PARAMETER | DESCRIPTION |
---|---|
other
|
Other bounding box
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BoundingBox
|
Bounding box |
__or__
Unions the bounding boxes.
PARAMETER | DESCRIPTION |
---|---|
other
|
Other bounding box
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BoundingBox
|
Bounding box |
buffer
Buffers the bounding box.
Notes
- A positive buffer size expands the bounding box
- A negative buffer size shrinks the bounding box
Example
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 = bounding_box.buffer(buffer_size=64)
print(bounding_box)
BoundingBox(
x_min=363020,
y_min=5715262,
x_max=363404,
y_max=5715646,
)
PARAMETER | DESCRIPTION |
---|---|
buffer_size
|
Buffer size in meters
TYPE:
|
inplace
|
If True, the bounding box is buffered inplace
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BoundingBox
|
Bounding box |
snap
Snaps the bounding box.
Example
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 snapping the bounding box.
bounding_box = BoundingBox(
x_min=363084,
y_min=5715326,
x_max=363340,
y_max=5715582,
)
bounding_box = bounding_box.snap(value=128)
print(bounding_box)
BoundingBox(
x_min=363008,
y_min=5715200,
x_max=363392,
y_max=5715584,
)
PARAMETER | DESCRIPTION |
---|---|
value
|
Value to snap the coordinates to in meters
TYPE:
|
inplace
|
If True, the bounding box is snapped inplace
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BoundingBox
|
Bounding box |