简体   繁体   English

在PostGIS中哪一个是计算两点之间距离的最准确方法?

[英]In PostGIS which one is the most accurate way to calculate distance between two points?

I'm having problems with st_distance function in postgis. 我在postgis中遇到st_distance函数问题。 I have three ways to calculate the distance, but I don't know which one is the most accurate. 我有三种计算距离的方法,但我不知道哪一种最准确。

SELECT ST_Distance('POINT(115.25 39.26)'::geography, 'POINT(117.30 41.04)'::geography) as distance;
--result is 263753.911823565
SELECT ST_Distance_Sphere(ST_GeomFromText('POINT(115.25 39.26)',4326), ST_GeomFromText('POINT(117.30 41.04)',4326)) as distance;
--result is 263674.468686404
SELECT ST_Distance( ST_Transform(ST_GeomFromText('POINT(115.25 39.26)',4326),32650),ST_Transform(ST_GeomFromText('POINT(117.30 41.04)', 4326),32650)) as distance;
--result is 263669.651755417

The difference between the 3 measurement calculations is the following: 3次测量计算之间的差异如下:

  1. The distance is calculated over the spheroid, a mathematical approximation of the earth's surface taking the flattening at the poles into consideration. 在球体上计算距离,这是地球表面的数学近似,考虑了极点的平坦化。 This is also called the "great arc distance". 这也称为“大弧距离”。 In this case the default spheroid is WGS84, which is also used by the GPS system and satellite imagery. 在这种情况下,默认的椭球体是WGS84,它也被GPS系统和卫星图像使用。
  2. The distance is calculated over a sphere, which does not considering flattening (the shape is effectively like a ball). 距离是在球体上计算的,不考虑展平(形状实际上像球一样)。 Usually the sphere has the same volume as some spheroid so it is slightly smaller at the equator and slightly bulging at the poles. 通常球体具有与某些球体相同的体积,因此它在赤道处略小,在极点处略微凸出。 It is mathematically much simpler than the spheroid and therefore lots faster to calculate. 这是数学上比球体更简单,因此许多更快的计算。
  3. The distance is calculated on a cartesian coordinate reference system (a plane) established by transforming from geographic coordinates, in this case UTM50N from a WGS84 spheroid. 在通过从地理坐标变换建立的笛卡尔坐标参考系统(平面)上计算距离,在这种情况下,UTM50N来自WGS84球体。

The first method usually gives the best result (of these 3), but for coordinates that are close together or close to the Equator, the difference would be negligible compared to the faster second method. 第一种方法通常给出最好的结果(这3种),但对于靠近或接近赤道的坐标,与更快的第二种方法相比,差异可以忽略不计。

The third method is not particularly accurate with the UTM50N(WGS84) coordinate reference system, but a cartesian coordinate system has important other benefits, such as calculating angles between triplets of points or areas of polygons. 第三种方法对于UTM50N(WGS84)坐标参考系统并不是特别准确,但是笛卡尔坐标系具有重要的其他好处,例如计算点的三元组或多边形区域之间的角度。 Also note that some datums in use with local CRSes give a much better local representation of the earth's irregular surface than WGS84 does, in which case a local CRS becomes much more accurate than a great-arc calculation. 还要注意,与WGS84相比,使用局部CRS的一些基准给出了地球不规则表面的更好的局部表示,在这种情况下,局部CRS变得比大弧计算更准确。 You would have to look up all the geodetic details of your area to assess that. 您必须查找您所在区域的所有大地测量细节才能对其进行评估。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM