I have a list of coordinates, knowing that I am working using EPSG:4326 and using Python I would like to calculate the length in kilometres of the polyline defined by these coordinates.
Coords = [(0.0, 50.787944),
(0.0, 50.787944),
(-0.20159865271498856, 50.824569950535725),
(-0.40044683717220364, 50.803694),
(-0.599761967889834, 50.78975316549538)]
I've tried with GeoPandas and shapely but reading the documentation I can't find an easy way to do it. Is there any function that allows me to calculate the length in kilometre knowing Coords and the reference system used?
Best Answer
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.
After converting the list of coordinates to a shapely
LineString
I usedpyproj
for computing the transformation. I had initially aattributeError : module 'pyproj' has no attribute 'CRS'
because I was using an old version.If using pyproj < 2.1: