locan.data.regions.region.Region2D¶
- class locan.data.regions.region.Region2D[source]¶
Bases:
RegionAbstract Region class to define the interface for 2-dimensional Region classes.
Methods
__init__()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 a line or axis-oriented, box-like Region from list of (min, max) bounds.
from_shapely(shapely_object)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.Axesobject.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
A region describing the minimum axis-aligned bounding box that encloses the original region.
Region bounds min_x, min_y, ..., max_x, max_y, .
centroidPoint coordinates for region centroid.
The region dimension.
elongationA measure between 0 and 1 for how elongated the object is.
The extent (max_x - min_x), (max_y - min_y), .
Provide bounds in a tuple (min, max) arrangement.
Ratio of the area of a region to the area of a circle with the same perimeter:
max_distanceThe maximum distance between any two points within the region.
radial_distanceAverage of all absolute distances between vertices and centroid.
region_measureRegion measure, i.e. area (for 2d) or volume (for 3d).
Geometric object as defined in shapely.
subregion_measureMeasure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).
vertices0 - dimensional elements that define the region; also called points.
- abstractmethod as_artist(origin=(0, 0), **kwargs)[source]¶
Matplotlib 2D patch object for this region (e.g. matplotlib.patches.Ellipse).
- Parameters:
origin (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],bool,int,float,complex,str,bytes,_NestedSequence[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 bounding_box: AxisOrientedRectangle¶
A region describing the minimum axis-aligned bounding box that encloses the original region.
- Return type:
- property bounds: ndarray[tuple[int, ...], dtype[float64]]¶
Region bounds min_x, min_y, …, max_x, max_y, … for each dimension.
- Returns:
of shape (2 * dimension,)
- Return type:
npt.NDArray[np.float64] | None
- buffer(distance, **kwargs)[source]¶
Extend the region perpendicular by a distance.
- Parameters:
distance (
float) – Distance by which the region is extended.- Returns:
The extended region.
- Return type:
- property dimension: int¶
The region dimension.
- Return type:
int | None
- property extent: ndarray[tuple[int, ...], dtype[float64]]¶
The extent (max_x - min_x), (max_y - min_y), … for each dimension.
- Returns:
of shape (dimension,)
- Return type:
npt.NDArray[np.float64] | None
- static from_shapely(shapely_object)[source]¶
Constructor for instantiating Region from shapely object.
Note
This function is deprecated.
- Parameters:
shapely_object (
LineString|Polygon|MultiPolygon) – Geometric object to be converted into Region- Return type:
- intersection(other)[source]¶
Returns a region representing the intersection of this region with
other.
- property intervals: ndarray[tuple[int, ...], dtype[float64]]¶
Provide bounds in a tuple (min, max) arrangement.
- Returns:
((min_x, max_x), …) of shape(dimension, 2)
- Return type:
npt.NDArray[np.float64]
- property isoperimetric_quotient: float¶
Ratio of the area of a region to the area of a circle with the same perimeter:
isoperimetric_quotient = 4 * pi * area / perimeter^2.
Sometimes called circularity in 2d and sphericity in 3d.
- Return type:
float
- plot(ax=None, **kwargs)[source]¶
Provide plot of region as
matplotlib.axes.Axesobject.- Parameters:
ax (
Axes|None) – The axes on which to show the imagekwargs (
Any) – Other parameters passed to the matplotlib.patches object.
- Returns:
Axes object with the plot.
- Return type:
matplotlib.axes.Axes
- abstract property shapely_object: Any¶
Geometric object as defined in shapely.
- Return type:
Shapely object