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
attributeminPointThe minimum corner (bottom-left) of the bounding box.
attributemaxPointThe maximum corner (top-right) of the bounding box.
Methods
func__init__(min, max) -> NoneCreate a bounding box from two corner points.
paramminPointMinimum corner (bottom-left).
parammaxPointMaximum corner (top-right).
Returns
Nonefuncwidth() -> floatReturn the width of the bounding box (extent along the X axis).
Returns
floatfuncheight() -> floatReturn the height of the bounding box (extent along the Y axis).
Returns
floatfunccenter() -> PointReturn the center point of the bounding box.
Returns
Pointfuncarea() -> floatReturn the area of the bounding box (width * height).
Returns
floatfunccontains(p) -> boolCheck whether a point lies inside (or on the boundary of) the bounding box.
parampPointThe point to test.
Returns
boolfuncmerge(other) -> BBoxReturn a new bounding box that encloses both this box and other.
paramotherBBoxThe other bounding box.
Returns
BBoxA new bounding box covering the union of both boxes.