问题描述
我用 scipy.spatial.ConvexHull 计算了一些随机坐标的凸包。
现在我想按给定的百分比增加面积。我已经在 scipy 上找到了一种方法,但找不到任何方法。
解决方法
我建议使用 GeoPandas。 GeoPandas 将为您提供更多的地理空间数据方法/功能,而不是辛辣的。
您可以使用 GeoPandas 轻松计算船体,并执行一些 affine transformations 之类的 scale
。
下面是一个带有随机坐标的简短示例。
import plotly.express as px
import numpy as np
import geopandas as gp
from shapely.geometry import MultiPoint
def get_coordinates():
return [ np.random.uniform(160.3,171.2),np.random.uniform(27.1,36.3) ]
points = [ get_coordinates() for _ in range(50) ]
gdf = gp.GeoDataFrame(index=[0],crs= {'init':'epsg:4326'},geometry=[MultiPoint(points)])
gdf_hull = gdf.convex_hull
gdf_hull_scaled = gdf_hull.scale(2,2,origin='center')
例如,您可以使用 plotly
绘制数据。图像显示了比例因子为 2 的结果。