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
Attachments
Change History
Changed 8 years ago by bbest
- Attachment geographiclib_example.zip added
Changed 8 years ago by bbest
- Attachment ptdist_ArcGIS_Near.png added
ArcGIS NEAR tool distance output from a point in lower left, not respecting dateline
Changed 8 years ago by bbest
- Attachment ptdist_Python_Geodetic.png added
python geographiclib distance output, respecting dateline, from lower left start point
Changed 8 years ago by bbest
- Attachment pt_distances_geodesic.py added
python script to generate nearest neighbor distance between all points
comment:4 Changed 8 years ago by bbest
Just wanted to point out how simple it is to get true area:
Geodesic.WGS84.Area([p(0, 0), p(0, 90), p(90, 0)])
Might be useful for chores like getting the convex hull using the Minimum Bounding Geometry tool and feed these points into this area function.
comment:5 Changed 8 years ago by bbest
- Description modified (diff)
From: Charles Karney <charles.karney@sri.com> Date: Sat, Jul 21, 2012 at 3:53 AM Subject: Algorithms for geodesics To: Charles Karney <charles.karney@sri.com>
Dear Colleague:
My paper on geodesics has now appeared in the Journal of Geodesy. Thanks to my employer, SRI, you do not need to be a subscriber to download a copy of the paper; just follow the link to the DOI below:
- F. F. Karney, Algorithms for geodesics,
- Geodesy, 2012, DOI: http://dx.doi.org/10.1007/s00190-012-0578-z
As always, comments are welcome!
comment:6 Changed 6 years ago by jjr8
Shaun Walbridge mentioned that the Near tool in ArcGIS 10.3 can perform geodesic distance calculations, as linked to in this NIM: http://support.esri.com/en/bugs/nimbus/role/beta10_1/TklNMTAwOTM3
zip of toolbox models, python script and map document showing differences