BBox

An axis-aligned bounding box defined by minimum and maximum corner points.

Bounding boxes are used to query the spatial extent of geometry. They are returned by Polygon.bbox() and Cell.bbox(), and can be merged to compute the bounds of composite shapes.

box = BBox(Point(0, 0), Point(10, 5))
box.width()     # 10.0
box.height()    # 5.0
box.center()    # Point(5.0, 2.5)
box.area()      # 50.0

# Merge two bounding boxes
other = BBox(Point(8, 3), Point(15, 9))
combined = box.merge(other)  # BBox(Point(0, 0), Point(15, 9))

Attributes

attributeminPoint

The minimum corner (bottom-left) of the bounding box.

attributemaxPoint

The maximum corner (top-right) of the bounding box.

Methods

func__init__(min, max) -> None

Create a bounding box from two corner points.

paramminPoint

Minimum corner (bottom-left).

parammaxPoint

Maximum corner (top-right).

Returns

None
funcwidth() -> float

Return the width of the bounding box (extent along the X axis).

Returns

float
funcheight() -> float

Return the height of the bounding box (extent along the Y axis).

Returns

float
funccenter() -> Point

Return the center point of the bounding box.

Returns

Point
funcarea() -> float

Return the area of the bounding box (width * height).

Returns

float
funccontains(p) -> bool

Check whether a point lies inside (or on the boundary of) the bounding box.

parampPoint

The point to test.

Returns

bool
funcmerge(other) -> BBox

Return a new bounding box that encloses both this box and other.

paramotherBBox

The other bounding box.

Returns

BBox

A new bounding box covering the union of both boxes.

On this page