*Geographica just released a new version of its PostGIS Docker: **Breezy Badger**, based on the new PostgreSQL, 9.6. It has inherit all the features of the previous one but with much more functionalities extra. Find out what can it do for you.*

# Open source

## Computing the shortest path on an ellipsoid with Python

# Geodesic lines & GIS

A geodesic (aka geodesic line) is the shortest path between two points located on a given surface. In the world of cartography and geodesy, figure out the shortest path between two locations on an ellipsoid of revolution involves compute a geodesic line joining them (see more in Wikipedia). Consider the Earth as a sphere makes calculations easier, being the shortest path a great circle arc between the points (more on Wikipedia).

For some time, one of the main open source libraries from geo ecosystem, Proj.4, has been introducing major changes in its algorithms for geodetic computations. Specifically, since version 4.9 has been ported to C (inside Proj.4) part of the C ++ library GeographicLib written by Charles Karney (more on algorithms of C. Karney).

Until version 4.8 this library had been using Paul D. Thomas algorithms for Geodesy. The heavy use I make of this library every day has led me to do some testings on geodesic distance calculations. In this link you can access a benchmark I did with several libraries to calculate the geodesic distance between different locations, knowing the coordinates of these locations (which involves figure out the inverse geodetic problem): https://github.com/cayetanobv/GeodeticMusings

Thereafter, and in support of other tasks I was undertaking, I developed a small application which solves inverse geodetic problem based on the above algorithms and computes a geodesic line between start and end points in GIS format directly (Shapefile and/or GeoJSON): GeodesicLinesToGIS.

Is important to highlight that the program efficiently solves the problem of geodesic lines crossing antimeridian (180º) when generating geometries in GIS format. This library is builded on top of three excellent libraries: Pyproj, Fiona and Shapely.

In the examples below you can see the difference between computed geodesic line (shortest path; green line), rhumb line (or loxodromic; red line) and straight line between two points (black dashed line). The maximum differences, as you can expect, occurring between Mercator projection (see Fig 1; loxodromic is a straight line) and Gnomonic projection (see Fig 2; geodesic is a straight line). The problem of geodesic lines crossing 180º is solved, as you can see in Fig 3 and Fig 4.

You can install this package from PYPI (Python Package Index):

https://pypi.python.org/pypi/GeodesicLinesToGIS

Of course, sources are on GiHub:

https://github.com/GeographicaGS/GeodesicLinesToGIS

See you soon!