【问题标题】:How to get coordinates of a bounding box at a certain distance from a point in postGIS?如何获取距postGIS中某个点一定距离的边界框坐标?
【发布时间】:2020-05-02 10:42:50
【问题描述】:

我的目标是围绕 postGIS 中的一个点定义一个给定半径的圆的边界框。

点,范围都可以,但是当我这样做时:

select ST_AsGeoJSON( st_extent( st_buffer( ST_SetSRID(ST_MakePoint(11.0120, 49.5897), 4326), 6000 ) ) );

我明白了

{"type":"Polygon","coordinates":[[[-5988.988,-5950.4103],
                                  [-5988.988,6049.5897],
                                  [6011.012,6049.5897],
                                  [6011.012,-5950.4103],
                                  [-5988.988,-5950.4103]]]}

当我期待类似(

{"type":"Polygon","coordinates":[[[10.929017, 49.535753],
                                 [10.929017, 49.643646],
                                 [11.094983, 49.643646],
                                 [11.094983, 49.535753],
                                 [10.929017, 49.535753]]]}

(手工制作的 GeoJSON - 可能包含错误)

那么 - 如何让 postGIS SQL 输出地理坐标而不是几何图形?

【问题讨论】:

    标签: postgis


    【解决方案1】:

    如果几何被传递到ST_Buffer,那么第二个参数是度,而不是米。要将米用于第二个参数,请将第一个参数转换为地理。然后将其转换回几何以与范围一起使用:

    select
      ST_AsGeoJSON(
        st_extent(
          st_buffer(
            ST_SetSRID(
              ST_MakePoint(11.0120, 49.5897),
              4326
            )::geography,
            6000
          )::geometry
        )
      );
    

    【讨论】:

      猜你喜欢
      • 2010-12-13
      • 2021-08-18
      • 1970-01-01
      • 2012-06-12
      • 1970-01-01
      • 1970-01-01
      • 2017-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多