locan.data.regions.region.LineSegment2D¶
- class locan.data.regions.region.LineSegment2D(points, is_directed=True)[source]¶
Bases:
Region2DRegion class to define a line.
The line is constructed from a list of two points. A direction is given by the order of points with the first point as origin.
- Parameters:
points (npt.ArrayLike) – Points with shape (2, dimension)
Methods
__init__(points[, is_directed])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 Line from list of (min, max) bounds.
from_shapely(line)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
bounding_boxA region describing the minimum axis-aligned bounding box that encloses the original region.
boundsRegion bounds min_x, min_y, ..., max_x, max_y, .
Point coordinates for region centroid.
dimensionThe region dimension.
A measure between 0 and 1 for how elongated the object is.
extentThe extent (max_x - min_x), (max_y - min_y), .
intervalsProvide bounds in a tuple (min, max) arrangement.
isoperimetric_quotientRatio of the area of a region to the area of a circle with the same perimeter:
The maximum distance between any two points within the region.
The starting point of a directed line.
radial_distanceAverage of all absolute distances between vertices and centroid.
Region measure, i.e. area (for 2d) or volume (for 3d).
Geometric object as defined in shapely.
Measure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).
Terminal points of line.
- 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 centroid: ndarray[tuple[int, ...], 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[_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]
- 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
- classmethod from_intervals(intervals)[source]¶
Constructor for instantiating Line from list of (min, max) bounds.
- 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:
- classmethod from_shapely(line)[source]¶
Constructor for instantiating Region from shapely object.
Note
This function is deprecated.
- Parameters:
shapely_object – Geometric object to be converted into Region
- Return type:
- property max_distance: float¶
The maximum distance between any two points within the region.
- Return type:
float
- property origin: ndarray[tuple[int, ...], dtype[float64]] | None¶
The starting point of a directed line.
- Returns:
of shape(dimension)
- Return type:
npt.NDArray[np.float64] | None
- property region_measure: float¶
Region measure, i.e. area (for 2d) or volume (for 3d).
- Return type:
float
- property shapely_object: LineString¶
Geometric object as defined in shapely.
- Return type:
Shapely object
- property subregion_measure: float¶
Measure of the sub-dimensional region, i.e. perimeter length (for 2d) or surface area (for 3d).
- Return type:
float
- property vertices: ndarray[tuple[int, ...], dtype[float64]]¶
Terminal points of line.
- Returns:
of shape(2, dimension)
- Return type:
npt.NDArray[np.float64]