geopandas.GeoSeries.凹壳#
- GeoSeries.concave_hull(ratio=0.0, allow_holes=False)[来源]#
返回一个
GeoSeries,其几何形状表示每个几何体的凹壳顶点。几何体的凹壳是包含每个几何体中所有点的最小凹多边形,除非几何对象中的点数少于三个。对于两个点,凹壳收缩为线串;对于一个点,则为点。
边界由移除输入点的德劳内三角剖分的边界三角形构成,只要它们的“大小”大于最大边长比,并且可以选择性地允许孔。边长因子是输入点的德劳内三角剖分中最长边和最短边之间长度差的一个分数。有关所使用算法的更多信息,请参见 https://libgeos.org/doxygen/classgeos_1_1algorithm_1_1hull_1_1ConcaveHull.html
- Parameters:
- ratiofloat, (optional, default 0.0)
范围在[0, 1]之间的数字。较高的数字将包括更少的顶点在外壳中。
- allow_holesbool, (optional, default False)
如果设置为 True,凹壳可能会有孔。
另请参阅
笔记
这些算法仅考虑每个几何图形的顶点。因此,外壳可能无法完全包围输入几何图形。如果发生这种情况,增加
ratio应该解决这个问题。示例
>>> from shapely.geometry import Polygon, LineString, Point, MultiPoint >>> s = geopandas.GeoSeries( ... [ ... Polygon([(0, 0), (1, 1), (0, 1)]), ... LineString([(0, 0), (1, 1), (1, 0)]), ... MultiPoint([(0, 0), (1, 1), (0, 1), (1, 0), (0.5, 0.5)]), ... MultiPoint([(0, 0), (1, 1)]), ... Point(0, 0), ... ], ... crs=3857 ... ) >>> s 0 POLYGON ((0 0, 1 1, 0 1, 0 0)) 1 LINESTRING (0 0, 1 1, 1 0) 2 MULTIPOINT ((0 0), (1 1), (0 1), (1 0), (0.5 0... 3 MULTIPOINT ((0 0), (1 1)) 4 POINT (0 0) dtype: geometry
>>> s.concave_hull() 0 POLYGON ((0 1, 1 1, 0 0, 0 1)) 1 POLYGON ((0 0, 1 1, 1 0, 0 0)) 2 POLYGON ((0.5 0.5, 0 1, 1 1, 1 0, 0 0, 0.5 0.5)) 3 LINESTRING (0 0, 1 1) 4 POINT (0 0) dtype: geometry