Search code examples
javageospatialgeotools

What distance calculation (longitude, latitude) is more precise?


I am comparing two different ways of calculating a distance between two Points.

  1. Haversine formula found on the page: http://www.movable-type.co.uk/scripts/latlong.html

  2. The following functionality of the geotools library:

GeodeticCalculator geodeticCalculator = new GeodeticCalculator(); geodeticCalculator.setStartingGeographicPoint(lng1, lat1); geodeticCalculator.setDestinationGeographicPoint(lng2, lat2); double distance = geodeticCalculator.getOrthodromicDistance();

The result for two coordinates in a range of about 100 meter differs by about 3 meters. And for longer distances (some 1000 km) even more (some kilometers). But it is also hard to check which one is more precise since you don't have a reference that you can really trust. (Don't know for example if google maps is that precise)

Any idea?


Solution

  • Just to answer my own question after some more research:

    Geotools library is more precise here, since it uses the WGS84 Model by default if instantiated with an empty constructor.

    The other formula uses an inacurate spherical model of the earth.