【问题标题】:Split Up Big Polygon Into Smaller Ones By Condition按条件将大多边形分成较小的多边形
【发布时间】:2017-11-16 18:24:58
【问题描述】:

我有一些大多边形。在其中收集传单层(点)。每个点都有一些数字属性。我想要的是将大多边形分成较小的多边形。 每个较小的多边形都应包含点属性总和约等于(+-200 ok)的点。在我的示例页面的左侧,我添加了理想结果的图像。 Here is my simplified example 有足够的代码和 cmets。

  1. 所以我的第一步是在大多边形中找到一些起点。它应该是多边形边缘附近的点 - 例如最北端。

    var nothernmostPoint= 0;
    var nothernmostLayer= 0;
    L.geoJSON(features, {
        pointToLayer: function (feature) {
            return L.circleMarker(feature.geometry.coordinates.reverse(), defaultPointStyle);
        },
        onEachFeature: function (feature, layer) {
            if (feature.geometry.coordinates[0] > nothernmostPoint) {
                nothernmostPoint = feature.geometry.coordinates[0];
                nothernmostLayer = feature;
            }
        }
    }).addTo(map);
    

  1. 第二步是找到离我的起点最近的点。

     var geoJ = L.GeometryUtil.nClosestLayers(map, features, nothernmostLayer.geometry.coordinates, 5);
    

  1. 然后总结它们的属性。如果总和小于需要,我转到第 2 步并重复,如果总和满足条件,则我绘制多边形,其中包含选定的点,并找到离我最后一个点最近的点,然后重复搜索下一个较小多边形的点。

我目前的困难是找到离我的起点最近的点。为此,我使用 GeometryUtil Leaflet 插件。红点是 GeometryUtil 发现离我的起点最近的点(绿色点)。这当然不是我所期望的。我究竟做错了什么?也许我应该为该任务使用不同的算法和/或工具?非常感谢任何有用的建议。

如果有帮助的话 - 我存储在 PostgreSQL 中的所有数据都带有 PostGIS 扩展名。也许这可以在数据库级别完成。

【问题讨论】:

    标签: algorithm split leaflet polygon postgis


    【解决方案1】:

    如果你的数据集比较小,你可以在 PostGIS 中使用蛮力:

    • 对于每个点,使用select geom, generate_series(0, weight) 生成代表“权重”的 N 个点;
    • 决定你想要获得的集群数量,大约sum(weight)/desired_sum
    • 在数据集上运行 K-Means 聚类,https://postgis.net/docs/manual-2.3/ST_ClusterKMeans.html
    • 使用 ST_ConvexHull(ST_Collect(geom)) 在每个集群周围绘制一个多边形。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-19
      • 2012-06-11
      • 1970-01-01
      • 2016-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-02
      相关资源
      最近更新 更多