简体   繁体   中英

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).

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 ?

Thank you very much!

Using Postgis is not necessary just to calculate distance between points.

You can use this gist to have a simple distance computation (distances are in Km). You can also use the earthdistance extension.

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.

Hope this can help others :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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