0

I just made a shapely Linestring with multiple points of GPS coordinate, and I want the total length in meters.

Exemple of coordinates : [ -0.113623333333333, 44.911787333333336 ]

How can i achieve that?

remc
  • 161
  • 1
  • 2
  • 10
  • Does this answer your question? [Length of LineString in Miles](https://stackoverflow.com/questions/30020930/length-of-linestring-in-miles) – Georgy Jul 28 '21 at 08:25
  • @Georgy yes indeed, just needed time to try it. – remc Jul 28 '21 at 08:29

1 Answers1

2

You can use pyproj to measure geodesic line length.

>>> from pyproj import Geod
>>> from shapely.geometry import Point, LineString
>>> line_string = LineString([Point(1, 2), Point(3, 4)]))
>>> geod = Geod(ellps="WGS84")
>>> total_length = geod.geometry_length(line_string)
>>> f"{total_length:.3f}"
'313588.397'

See more in the documentation: https://pyproj4.github.io/pyproj/stable/examples.html#geodesic-line-length

martinfleis
  • 7,124
  • 2
  • 22
  • 30