Ticket #549 (new Task)

Opened 8 years ago

Last modified 6 years ago

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:

ArcGIS Near

ArcGIS NEAR tool distance output from a point in lower left, not respecting dateline

VS.

Python GeographicLib::Geodesic

python geographiclib distance output, respecting dateline, from lower left start point

Attachments

geographiclib_example.zip (1.8 MB) - added by bbest 8 years ago.
zip of toolbox models, python script and map document showing differences
ptdist_ArcGIS_Near.png (68.9 KB) - added by bbest 8 years ago.
ArcGIS NEAR tool distance output from a point in lower left, not respecting dateline
ptdist_Python_Geodetic.png (87.0 KB) - added by bbest 8 years ago.
python geographiclib distance output, respecting dateline, from lower left start point
pt_distances_geodesic.py (1.3 KB) - added by bbest 8 years ago.
python script to generate nearest neighbor distance between all points

Change History

Changed 8 years ago by bbest

zip of toolbox models, python script and map document showing differences

Changed 8 years ago by bbest

ArcGIS NEAR tool distance output from a point in lower left, not respecting dateline

Changed 8 years ago by bbest

python geographiclib distance output, respecting dateline, from lower left start point

Changed 8 years ago by bbest

python script to generate nearest neighbor distance between all points

comment:1 Changed 8 years ago by bbest

  • Description modified (diff)

comment:2 Changed 8 years ago by bbest

  • Description modified (diff)

comment:3 Changed 8 years ago by bbest

  • Description modified (diff)

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:

  1. F. F. Karney, Algorithms for geodesics,
  2. 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

Note: See TracTickets for help on using tickets.