Eventually, I have understood the steps to follow I had to convert the EPSG:4326 which has degrees as for units to a coordinate system in meters as EPSG:32618. So eventually I have end up following the instructions in the shapely documentation for transformations.
Coords = [(0.0, 50.787944),
(0.0, 50.787944),
(-0.20159865271498856, 50.824569950535725),
(-0.40044683717220364, 50.803694),
(-0.599761967889834, 50.78975316549538)]
polyline = LineString(Coords)
After converting the list of coordinates to a shapely LineString
I used pyproj
for computing the transformation. I had initially a attributeError : module 'pyproj' has no attribute 'CRS'
because I was using an old version.
import pyproj
from shapely.geometry import Point
from shapely.ops import transform
wgs84 = pyproj.CRS('EPSG:4326')
utm = pyproj.CRS('EPSG:32618')
utm_polyline = transform(project, wgs84_pt)
length_km = utm_polyline.length/1000
If using pyproj < 2.1:
from functools import partial
import pyproj
from shapely.ops import transform
wgs84 = pyproj.Proj(init='epsg:4326')
utm = pyproj.Proj(init='epsg:32618')
project = partial(
pyproj.transform,
wgs84,
utm)
utm_polyline = transform(project, polyline)
length_km = utm_polyline.length/1000