pointpats.hull

pointpats.hull(points)[source]
pointpats.hull(points: ndarray) ndarray[tuple[Any, ...], dtype[float64]]
pointpats.hull(points: GeoPandasBase) Polygon

Find convex hull of a point array.

Parameters:
pointsarraylike

array representing a point pattern

Returns:
rectangle

convex hull of a given point pattern

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],
...         [54.46, 8.48],
...     ]
... )

Passing an array of coordinates returns an array capturing the vertices.

>>> hull(coords)
array([[31.01, 81.21],
       [ 8.23, 39.93],
       [ 9.47, 31.02],
       [22.52, 22.39],
       [54.46,  8.48],
       [79.26,  7.68],
       [89.78, 42.53],
       [98.73, 77.17],
       [65.19, 92.08]])

Passing a GeoPandas object returns a shapely geometry.

>>> geoms = gpd.GeoSeries.from_xy(*coords.T)
>>> hull(geoms)
<POLYGON ((79.26 7.68, 54.46 8.48, 22.52 22.39, 9.47 31.02, 8.23 39.93, 31.0...>