【问题标题】:Lat/Long spatial reference纬度/经度空间参考
【发布时间】:2020-07-19 00:01:45
【问题描述】:

我是 PostGIS 新手,没有正确获取多边形的面积,我的示例数据来自谷歌地图,我知道多边形的面积是 11 英亩,但 st_area 返回的面积不匹配, 我已经参考了下面的一些链接,但无法解决问题,互联网上说 google 遵循 4326 Spatial references,我尝试了很多,能否请您帮忙,图片是来自谷歌地图的多边形。

我期待用户提供一个这样的坐标数组,我必须从 PostGIS 计算面积,如果输入的面积与计算面积不近似,我必须向用户返回一个错误。

https://gis.stackexchange.com/questions/169422/how-does-st-area-in-postgis-work

How do I convert a latitude/longitude pair into a PostGIS geography type?

https://gis.stackexchange.com/questions/56862/what-spatial-reference-system-do-i-store-google-maps-lat-lng-in/56925

17.475197 78.389024 17.4771 78.39044 17.475657 78.391652 17.474408 78.390847 17.475197 78.389024

l_polygon_text='MULTIPOLYGON((( 17.4771000000000001 78.3904399999999981, 17.4751970000000014 78.3890240000000063, 17.4756570000000018 78.3916519999999934, 17.4751970000000014 78.3890240000000063, 17.4744080000000004 78.3908469999999937, 17.4771000000000001 78.3904399999999981)))';

st_area(ST_GeometryFromText(l_polygon_text,4326))
st_area(ST_GeometryFromText(l_polygon_text,2163));
st_area(ST_GeometryFromText(l_polygon_text,2249));
st_area(ST_GeometryFromText(l_polygon_text,3859));

ST_AREA(ST_Transform(ST_GeomFromText(l_polygon_text,4326),31467));
ST_Area(ST_Transform(ST_SetSRID(ST_GeomFromText(l_polygon_text),4326),900913));

polygon

【问题讨论】:

    标签: postgresql google-maps postgis


    【解决方案1】:

    在 PostGIS 中,坐标必须先表示为经度,再表示为纬度。谷歌则相反。

    坐标换好顺序后,不能直接调用st_area,否则会得到一个“平方度”的面积,这是没有意义的。您必须投影到合适的局部坐标系,或者您可以使用 geography 类型,该类型将返回以 m2 为单位的面积。

    select st_area(st_geogFromText('MULTIPOLYGON(((78.3904399999999981 17.4771000000000001, 78.3890240000000063 17.4751970000000014,78.3916519999999934 17.4756570000000018,78.3890240000000063 17.4751970000000014,78.3908469999999937 17.4744080000000004,78.3904399999999981 17.4771000000000001)))'));
          st_area
    --------------------
     26956.897848576307
    

    话虽如此,您提供的示例大约是 6.5 英亩,而不是 11 英亩,因为多边形没有正确定义:

    【讨论】:

      猜你喜欢
      • 2011-07-06
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多