Ticket #549 (new Task)
Use geographiclib for accurate geodesic distance and area calcuations
| Reported by: | bbest | Owned by: | jjr8 |
|---|---|---|---|
| Priority: | Medium | Milestone: | 0.8 |
| Component: | Tools - Spatial Analysis | Version: | |
| Keywords: | Cc: |
Description (last modified by bbest) (diff)
Recently bumped into an excellent Python module to very accurately calculate distance and area from geographic points: geographiclib. Unlike the distance functions in ArcGIS like Near, this library calculates shortest geodesic distance between any two points on the globe without suffering issues around the dateline. Attached are images showing the difference, both calculating nearest neighbor distance from the star point in the lower left. I include the toolbox models and Python script for generating both in the zip.
# import library
from geographiclib.geodesic import Geodesic
# The geodesic inverse problem
Geodesic.WGS84.Inverse(-41.32, 174.81, 40.96, -5.50)
# The geodesic direct problem
Geodesic.WGS84.Direct(40.6, -73.8, 45, 10000e3)
# How to obtain several points along a geodesic
line = Geodesic.WGS84.Line(40.6, -73.8, 45)
line.Position( 5000e3)
line.Position(10000e3)
# Computing the area of a geodesic polygon
def p(lat,lon): return {'lat': lat, 'lon': lon}
Geodesic.WGS84.Area([p(0, 0), p(0, 90), p(90, 0)])
Note that interpolating along a line is done with the direct geodesic function from a starting point and by azimuth and distance, which you can get between two points using the inverse geodesic function. I do this in another script with a list comprehension on a PANDAS data frame:
d['km'] = [geod.Inverse(r['lat1'], r['lon1'], r['lat2'], r['lon2'])['s12'] / 1000 for i,r in d.iterrows()]
I also like that these techniques are supported by very recent peer reviewed publications:
- C. F. F. Karney, Geodesics on an ellipsoid of revolution, Feb. 2011; resource page geod.html.
- C. F. F. Karney (2012) Algorithms for geodesics. Journal of Geodesy.
ArcGIS Near
VS.
Python GeographicLib::Geodesic



