【问题标题】:Increase area of convex hull by x percentage with lat / lon coordinates使用纬度/经度坐标将凸包面积增加 x 百分比
【发布时间】:2021-03-31 18:21:10
【问题描述】:

我用 scipy.spatial.ConvexHull 计算一些随机坐标的凸包。

现在我想将面积增加给定的百分比。我已经在 scipy 上查找了一种方法,但我找不到任何方法。

【问题讨论】:

    标签: python scipy


    【解决方案1】:

    我建议使用GeoPandas。 GeoPandas 将为您提供比 scipy 更多的地理空间数据选项。

    您可以使用 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,2,origin='center')
    

    例如,您可以使用plotly 绘制数据。该图显示了比例因子为 2 的结果。

    【讨论】:

      猜你喜欢
      • 2010-09-07
      • 1970-01-01
      • 1970-01-01
      • 2012-03-29
      • 2021-06-08
      • 2020-11-24
      • 2016-02-23
      • 2012-03-25
      相关资源
      最近更新 更多