首页 > 解决方案 > 球面几何和地理上的 ST_Intersect 有什么区别?

问题描述

我遇到了一种特殊情况,我试图找到(部分)位于多边形中的任何地理空间对象。当我使用WGS84 SRIDST_Intersect在两个几何图形上应用该函数时,多边形和多边形以北的点的交集按预期返回:FALSE

SELECT ST_Intersects(
    ST_GeomFromText('POLYGON((-12 0,12 0,12 50.7,-12 50.7,-12 0))', 4326), 
    ST_GeomFromText('POINT(6.0 50.9)', 4326)
);


现在,当我运行相同的查询时,查询返回的是两个地理而不是几何TRUE

SELECT ST_Intersects( 
    ST_GeogFromText('POLYGON((-12 0,12 0,12 50.7,-12 50.7,-12 0))'),
    ST_GeogFromText('POINT(6 50.9)')
);

我希望地理版本使用最短的大圆距离来创建多边形,而几何版本在平面上创建多边形,然后才将其投影到WGS84椭圆上。

有人可以验证或揭穿我的怀疑吗?

我正在使用 PostGis 2.4.4 运行 postgresql 9.6

标签: geospatialpostgis

解决方案


Operations on geography data type are done over a sphere. Operations on geometry data type are done over a plane.

The shortest line joining two points on a plane is a straight line.

The shortest line joining two points on a sphere is an arc. This arc is called the great circle arc and is build by intersecting the sphere with a plan going through the 2 points and the center of the earth.

Consequently, the arc going through -12;50.7N and +12;50.7N with pass through a point near 0;51.3N. This holds true for lines but also for polygon boundaries.

This doc has some interesting graphics to understand the concepts behind the geography type


推荐阅读