【问题标题】:ST_Buffer in PostGIS produces different results for the same set of linesPostGIS 中的 ST_Buffer 对同一组行产生不同的结果
【发布时间】:2019-07-21 03:15:59
【问题描述】:

我们有一个由多个点(蓝线)组成的 LineString(地图上的一条路线),然后我们对其进行缓冲以在其周围生成一个区域。我们发现一切看起来都符合预期除非路线与自身相交,此时缓冲区域会获得相当大的纵向曲率。

一个例子展示了不同的结果:http://geojson.io/#id=gist:jgwconsulting/1e2a6e8bad9f018f2c6321016a527bef&map=6/55.621/-3.618

  • 灰色:整个路线被缓冲为单个 LineString,导致缓冲区域的曲率。
    SELECT ST_AsGeoJSON(
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[-14.466666666666667,55.25],[7.233333333333333,54],[0,58.86666666666667],[-11.7,52.06666666666667],[-12.6,56.55]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')
    );
    
  • 红/橙: LineString 被分割成由两个点组成的单独的直线,然后每个点都被缓冲并使用 ST_Union 合并生成的多边形。
    SELECT ST_AsGeoJSON(
    ST_Union(
    ARRAY[
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[-14.466666666666667,55.25],[7.233333333333333,54]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')::geometry,
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[7.233333333333333,54],[0,58.86666666666667]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')::geometry,
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[0,58.86666666666667],[-11.7,52.06666666666667]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')::geometry,
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[-11.7,52.06666666666667],[-12.6,56.55]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')::geometry
    ]
    ));
  • 黄色: LineString 被分成由两个点组成的单独的直线,然后使用 ST_Collect 将每个点包裹成一个 MultiPolygon。
    SELECT ST_AsGeoJSON(
    ST_Collect(
    ARRAY[
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[-14.466666666666667,55.25],[7.233333333333333,54]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')::geometry,
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[7.233333333333333,54],[0,58.86666666666667]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')::geometry,
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[0,58.86666666666667],[-11.7,52.06666666666667]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')::geometry,
    ST_Buffer(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[-11.7,52.06666666666667],[-12.6,56.55]]}')::geography, 9260, 'quad_segs=30 endcap=round join=round')::geometry
    ]
    ));

是否有人能够解释我们看到的不同结果,表面上使用相同的坐标集,特别是为什么相交线会如此显着地改变缓冲区?

这是一个创建(不同)路线的示例,展示了在添加一条与路线的另一部分相交的线后,缓冲区几何形状如何发生显着变化。

点击此链接:https://vimeo.com/320203046

【问题讨论】:

    标签: google-maps geometry geospatial postgis geo


    【解决方案1】:
    猜你喜欢
    • 2023-01-21
    • 2018-05-23
    • 2017-09-11
    • 2020-03-14
    • 2020-01-28
    • 2015-10-31
    • 2019-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多