[gdal-dev] Ellipsoidal length of a line

Mike Taves mwtoews at gmail.com
Sun Jun 16 14:46:20 PDT 2019

On Sat, 15 Jun 2019 at 03:32, Nicolas Cadieux
<nicolas.cadieux at archeotec.ca> wrote:
> I am trying to get the length of a line in python. (Not just the straight length between the first and last nodes).  Using geopandas, (therefore the Shapely lib) I am getting the euclidien distance even though the dataframe holdings the line geometries has a CRS (WGS84, zone UTM 18 S).  Obviously, the WGS84 Ellipsoid is not taken into account.
> Can I do this with gdal/ogr?

If you are looking for a really precise length (~15 nm) on WGS84, you
can use the Python version of GeographicLib [1].

Note that PROJ incorporates the C library for Geodesics from
GeographicLib [2], and that this is also the same method used in
PostGIS (since version 2.2). I'm not sure how SpatiaLite has
implemented ST_Length, but could be worth checking into.

[1] https://geographiclib.sourceforge.io/html/python/
[2] https://proj.org/geodesic.html#solution-of-geodesic-problems

More information about the gdal-dev mailing list