pointpats.minimum_bounding_circle¶
- pointpats.minimum_bounding_circle(points)[source]¶
- pointpats.minimum_bounding_circle(points: ndarray) tuple[tuple[float, float], float]
- pointpats.minimum_bounding_circle(points: GeoPandasBase) Polygon
Implements Skyum (1990)’s algorithm for the minimum bounding circle in R^2.
Store points clockwise. Find p in S that maximizes angle(prec(p), p, succ(p) THEN radius(prec( p), p, succ(p)). This is also called the lexicographic maximum, and is the last entry of a list of (radius, angle) in lexicographical order.
If angle(prec(p), p, succ(p)) <= 90 degrees, then finish.
If not, remove p from set.
- Parameters:
- pointsarraylike
array representing a point pattern
- Returns:
- circle
minimum bounding circle
Examples
>>> import numpy as np >>> import geopandas as gpd
Create an array of point coordinates.
>>> coords = np.array( ... [ ... [66.22, 32.54], ... [22.52, 22.39], ... [31.01, 81.21], ... [9.47, 31.02], ... [30.78, 60.10], ... [75.21, 58.93], ... [79.26, 7.68], ... [8.23, 39.93], ... [98.73, 77.17], ... [89.78, 42.53], ... [65.19, 92.08], ... ] ... )
Passing an array of coordinates returns an tuple of (x, y), radius.
>>> minimum_bounding_circle(coords) ((55.244520477497474, 51.88135107645883), np.float64(50.304102155590726))
Passing a GeoPandas object returns a shapely geometry.
>>> geoms = gpd.GeoSeries.from_xy(*coords.T) >>> minimum_bounding_circle(geoms) <POLYGON ((105.549 51.881, 105.306 46.951, 104.582 42.068, 103.383 37.279, 1...>