locan.data.regions.region.Region¶
- class locan.data.regions.region.Region[source]¶
Bases:
ABCAbstract Region class to define the interface for Region-derived classes that specify geometric objects to represent regions of interest.
Methods
__init__()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.
intersection(other)Returns a region representing the intersection of this region with
other.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, .
Point coordinates for region centroid.
The region dimension.
A 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.
The maximum distance between any two points within the region.
Average of all absolute distances between vertices and centroid.
Region measure, i.e. area (for 2d) or volume (for 3d).
Measure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).
0 - dimensional elements that define the region; also called points.
- abstract property bounding_box: Region¶
A region describing the minimum axis-aligned bounding box that encloses the original region.
- Return type:
- abstract property bounds: ndarray[tuple[int, ...], dtype[float64]] | None¶
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
- abstractmethod 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:
- abstract property centroid: ndarray[tuple[int, ...], dtype[float64]] | None¶
Point coordinates for region centroid.
- Returns:
of shape (dimension,)
- Return type:
npt.NDArray[np.float64] | None
- abstractmethod contains(points)[source]¶
Return list of indices for all points that are inside the region of interest.
- Parameters:
points (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],bool,int,float,complex,str,bytes,_NestedSequence[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]
- abstract property dimension: int | None¶
The region dimension.
- Return type:
int | None
- abstract property elongation: float¶
A measure between 0 and 1 for how elongated the object is. It is computed as: 1 - the ratio of length of minor axis to length of major axis.
- Return type:
float
- abstract property extent: ndarray[tuple[int, ...], dtype[float64]] | None¶
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_intervals(intervals)[source]¶
Constructor for instantiating a line or axis-oriented, box-like Region from list of (min, max) bounds. Takes array-like intervals instead of interval to be consistent with Rectangle.from_intervals.
Note
This function is deprecated.
- Parameters:
intervals (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],bool,int,float,complex,str,bytes,_NestedSequence[bool|int|float|complex|str|bytes]]) – The region bounds for each dimension of shape (dimension, 2).- Return type:
Interval | AxisOrientedRectangle | AxisOrientedCuboid | AxisOrientedHypercuboid
- abstractmethod intersection(other)[source]¶
Returns a region representing the intersection of this region with
other.
- abstract property intervals: ndarray[tuple[int, ...], dtype[float64]] | None¶
Provide bounds in a tuple (min, max) arrangement.
- Returns:
((min_x, max_x), …) of shape(dimension, 2)
- Return type:
npt.NDArray[np.float64]
- abstract property max_distance: float¶
The maximum distance between any two points within the region.
- Return type:
float
- property radial_distance: float¶
Average of all absolute distances between vertices and centroid.
- Return type:
float
- abstract property region_measure: float¶
Region measure, i.e. area (for 2d) or volume (for 3d).
- Return type:
float
- abstract property subregion_measure: float¶
Measure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).
- Return type:
float
- abstractmethod symmetric_difference(other)[source]¶
Returns the union of the two regions minus any areas contained in the intersection of the two regions.
- abstractmethod union(other)[source]¶
Returns a region representing the union of this region with
other.
- abstract property vertices: ndarray[tuple[int, ...], dtype[float64]] | list[ndarray[tuple[int, ...], dtype[float64]]]¶
0 - dimensional elements that define the region; also called points.
- Returns:
of shape (n_vertices, dimension)
- Return type:
npt.NDArray[np.float64] | list[npt.NDArray[np.float64]]