Monday 9 January 2017

Distance between GPS coordinates


Given a database of GPS points, a center GPS location, and a radius R (in meters), how can I find all points in the database that are within a distance of R of the center point? Will the distance iso-lines be an ellipse?




Answer



For such short distances and since you are doing the coding yourself, the flat earth equations would probably be a good enough approximation but it depends on your accuracy requirements.


Compute the distance from latp,lonp to lat1/lon1 via the equirectangular projection:


p1 = (lonp - lon1) cos ( 0.5*(latp+lat1) ) //convert lat/lon to radians
p2 = (latp - lat1)
distance = EarthRadius * sqrt( p1*p1 + p2*p2)
use EarthRadius = 6371000 meters and your distance will be in meters

Latp/Lonp will be your reference lat/lon (in radians!). Lat1/Lon1 will be the point you are testing. Once you have distance, it is an easy test to determine if the point lies within your circle.


Reference: section Equirectangular approximation at the site: http://www.movable-type.co.uk/scripts/latlong.html



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...