alphashape package¶
Module contents¶
Top-level package for Alpha Shape Toolbox.
-
alphashape.
alphashape
(points: Union[List[Tuple[float]], numpy.ndarray], alpha: Union[None, float] = None)[source]¶ Compute the alpha shape (concave hull) of a set of points. If the number of points in the input is three or less, the convex hull is returned to the user. For two points, the convex hull collapses to a LineString; for one point, a Point.
- Parameters
points (list or
shapely.geometry.MultiPoint
orgeopandas.GeoDataFrame
) – an iterable container of pointsalpha (float) – alpha value
- Returns
shapely.geometry.Polygon
orshapely.geometry.LineString
orshapely.geometry.Point
orgeopandas.GeoDataFrame
: the resulting geometry
-
alphashape.
alphasimplices
(points: Union[List[Tuple[float]], numpy.ndarray]) → Union[List[Tuple[float]], numpy.ndarray][source]¶ Returns an iterator of simplices and their circumradii of the given set of points.
- Parameters
points – An N`x`M array of points.
- Yields
A simplex, and its circumradius as a tuple.
-
alphashape.
circumcenter
(points: Union[List[Tuple[float]], numpy.ndarray]) → numpy.ndarray[source]¶ Calculate the circumcenter of a set of points in barycentric coordinates.
- Parameters
points – An N`x`K array of points which define an (N-1) simplex in K dimensional space. N and K must satisfy 1 <= N <= K and K >= 1.
- Returns
The circumcenter of a set of points in barycentric coordinates.
-
alphashape.
circumradius
(points: Union[List[Tuple[float]], numpy.ndarray]) → float[source]¶ Calculte the circumradius of a given set of points.
- Parameters
points – An N`x`K array of points which define an (N-1) simplex in K dimensional space. N and K must satisfy 1 <= N <= K and K >= 1.
- Returns
The circumradius of a given set of points.
-
alphashape.
optimizealpha
(points: Union[List[Tuple[float]], numpy.ndarray], max_iterations: int = 10000, lower: float = 0.0, upper: float = 1.7976931348623157e+308, silent: bool = False)[source]¶ Solve for the alpha parameter.
Attempt to determine the alpha parameter that best wraps the given set of points in one polygon without dropping any points.
Note: If the solver fails to find a solution, a value of zero will be returned, which when used with the alphashape function will safely return a convex hull around the points.
- Parameters
points – an iterable container of points
max_iterations (int) – maximum number of iterations while finding the solution
lower – lower limit for optimization
upper – upper limit for optimization
silent – silence warnings
- Returns
The optimized alpha parameter
- Return type
float