Region#
- class lsst.images.Region(geometry: Polygon | MultiPolygon)#
Bases:
objectA 2-d Euclidean region represented as one or more polygons with optional holes.
Parameters#
- geometry
A polygon or multi-polygon from the Shapely library.
Attributes Summary
The area of the region (
float).The integer-coordinate bounding box of the region (
Box).The 'Well-Known Text' representation of this region (
str).Methods Summary
contains()Test whether the geometry contains the given points or another geometry.
difference(other)Compute the point-set difference of this region with another.
from_wkt(wkt)Construct from a 'Well-Known Text' string.
intersection(other)Compute the intersection of this region with a
Boundsobject.Serialize the region to a Pydantic model.
Convert to a
shapely.Polygonorshapely.MultiPolygonobject.If the underlying geometry is a rectangle that fully covers integer pixels (i.e. has all vertices at half-integer positions), return the equivalent
Box.If the underlying geometry is a single polygon with no holes, return a
Polygoninstance holding it.union(other)Compute the point-set union of this region with another.
Attributes Documentation
- area#
The area of the region (
float).
- bbox#
The integer-coordinate bounding box of the region (
Box).Because a
Boxlogically contains the entirety of the pixels on its boundary, but the centers of those pixels are the numerical values of its bounds, the region may contain vertices that are up to 0.5 beyond the integer box coordinates in either dimension.
- wkt#
The ‘Well-Known Text’ representation of this region (
str).
Methods Documentation
- contains(other: Polygon) bool#
- contains(*, x: int, y: int) bool
- contains(*, x: float, y: float) bool
- contains(*, x: ndarray, y: ndarray) ndarray
Test whether the geometry contains the given points or another geometry.
Parameters#
- other
Another geometry to compare to. Not compatible with the
yandxarguments.- x
One or more floating-point or integer X coordinates to test for containment. If an array, an array of results will be returned.
- y
One or more floating-point or integer Y coordinates to test for containment. If an array, an array of results will be returned.
- intersection(other: Bounds) Bounds#
Compute the intersection of this region with a
Boundsobject.Notes#
Because
Regionimplements theBoundsinterface, its intersections need to support all otherBoundsobjects. This is not true of otherRegionpoint-set operations likeunionanddifference.
- serialize() RegionSerializationModel#
Serialize the region to a Pydantic model.
Region serialization uses a subset of the GeoJSON specification (IETF RFC 7946).
- to_shapely() Polygon | MultiPolygon#
Convert to a
shapely.Polygonorshapely.MultiPolygonobject.
- try_to_box() Region | Box#
If the underlying geometry is a rectangle that fully covers integer pixels (i.e. has all vertices at half-integer positions), return the equivalent
Box.In all other cases
selfis returned.