locan.data.region.MultiPolygon#
- class locan.data.region.MultiPolygon(polygons)[source]#
Bases:
Region2D
Region class to define a region that represents the union of multiple polygons.
- Parameters:
polygons (list[Polygon]) – Polygons that define the individual polygons.
Methods
__init__
(polygons)as_artist
([origin])Matplotlib 2D patch object for this region (e.g. matplotlib.patches.Ellipse).
buffer
(distance, **kwargs)Extend the region perpendicular by a distance.
contains
(points)Return list of indices for all points that are inside the region of interest.
from_intervals
(intervals)Constructor for instantiating axis-oriented, box-like Region from list of (min, max) bounds.
from_shapely
(multipolygon)Constructor for instantiating Region from shapely object.
intersection
(other)Returns a region representing the intersection of this region with
other
.plot
([ax])Provide plot of region as
matplotlib.axes.Axes
object.symmetric_difference
(other)Returns the union of the two regions minus any areas contained in the intersection of the two regions.
union
(other)Returns a region representing the union of this region with
other
.Attributes
bounding_box
A region describing the minimum axis-aligned bounding box that encloses the original region.
bounds
Region bounds min_x, min_y, ..., max_x, max_y, .
Point coordinates for region centroid.
dimension
The region dimension.
extent
The extent (max_x - min_x), (max_y - min_y), .
Points defining holes.
The maximum distance between any two points within the region.
Exterior polygon points.
All polygons that make up the MultiPolygon
Region measure, i.e. area (for 2d) or volume (for 3d).
Legacy interface to serve legacy RoiRegion.
Geometric object as defined in shapely.
Measure of the sub-dimensional region, i.e. circumference (for 2d) or surface (for 3d).
- as_artist(origin=(0, 0), **kwargs)[source]#
Matplotlib 2D patch object for this region (e.g. matplotlib.patches.Ellipse).
- Parameters:
origin (
Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – The (x, y) pixel position of the origin of the displayed image. Default is (0, 0).kwargs (
Any
) – Other parameters passed to the matplotlib.patches object.
- Returns:
Matplotlib patch for the specified region.
- Return type:
matplotlib.patches.Patch
- property centroid: ndarray[Any, dtype[float64]]#
Point coordinates for region centroid.
- Returns:
of shape (dimension,)
- Return type:
npt.NDArray[np.float64] | None
- contains(points)[source]#
Return list of indices for all points that are inside the region of interest.
- Parameters:
points (
Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – Coordinates of points that are tested for being inside the specified region.- Returns:
Array with indices for all points in original point array that are within the region.
- Return type:
npt.NDArray[np.int64]
- classmethod from_shapely(multipolygon)[source]#
Constructor for instantiating Region from shapely object.
- Parameters:
shapely_object – Geometric object to be converted into Region
- Return type:
- property holes: list[list[ndarray[Any, dtype[float64]]] | None]#
Points defining holes.
- Returns:
list of polygon holes
- Return type:
list[list[npt.NDArray[np.float64]] | None]
- property max_distance: float#
The maximum distance between any two points within the region.
- Return type:
float
- property points: list[ndarray[Any, dtype[float64]]]#
Exterior polygon points.
- Returns:
n_polygons of shape(n_points, dimension)
- Return type:
list[npt.NDArray[np.float64]]
- property polygons: list[Polygon]#
All polygons that make up the MultiPolygon
- Return type:
list[Polygon]
- property region_measure: float#
Region measure, i.e. area (for 2d) or volume (for 3d).
- Return type:
float
- property region_specs#
Legacy interface to serve legacy RoiRegion.
Warning
Do not use - will be deprecated.
- Return type:
dict
- property shapely_object: MultiPolygon#
Geometric object as defined in shapely.
- Return type:
Shapely object
- property subregion_measure: float#
Measure of the sub-dimensional region, i.e. circumference (for 2d) or surface (for 3d).
- Return type:
float