简体   繁体   English

在postgis / postgresql中计算点距离

[英]Calculate point distance in postgis/postgresql

I am trying to calculate the distances between points in PostgreSQL, and now I have the longitude and latitude value for each point, and I know it's from GPS(WGS84). 我正在尝试计算PostgreSQL中点之间的距离,现在我有每个点的经度和纬度值,我知道它来自GPS(WGS84)。

Because all the points are in same city, and not very far from each other, so I know that use geometry with a local cartesian projection is better, because compared with using geography, it needs less calculation. 因为所有的点都在同一个城市,并且相距不太远,所以我知道使用具有局部笛卡尔投影的几何更好,因为与使用地理相比,它需要更少的计算。

My question is how can I find the suitable cartesian projection for my data? 我的问题是如何才能为我的数据找到合适的笛卡尔投影? If I can find one, is it the SRID value which should be used in ST_Transform ? 如果我能找到一个,是否应该在ST_Transform使用SRID值?

Thank you very much! 非常感谢你!

Using Postgis is not necessary just to calculate distance between points. 使用Postgis不仅仅是计算点之间的距离。

You can use this gist to have a simple distance computation (distances are in Km). 您可以使用此要点进行简单的距离计算(距离以Km为单位)。 You can also use the earthdistance extension. 您也可以使用earthdistance扩展。

I have found the SRID I need in this page: http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/pcs.html and this page: http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/gcs.html , and use ST_Transform to transfer the WGS84 coordinate to local cartesian coordinate, and can get the distance result in Unit meter. 我在此页面中找到了我需要的SRID: http//help.arcgis.com/en/arcgisserver/10.0/apis/rest/pcs.html和此页面: http//help.arcgis.com/en/ arcgisserver / 10.0 / apis / rest / gcs.html ,并使用ST_Transform将WGS84坐标传递到本地笛卡尔坐标,并可以得到单位米的距离结果。

Hope this can help others :) 希望这可以帮助别人:)

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

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