Skip to content
Advertisement

Receiving Infinity Infinity in LineString

I am try get linestring so I can measure the distance and time. Here in this linestring I am getting nan distance and time. Also, pleased to hear any of your suggestion on my code or logic. Thanks data:

[[29.87819, 121.54944999999998], [24.23111845, 119.02311485000001], [5.402576549999999, 106.87891215000002], [1.367889, 104.27658300000002], [4.65750565, 98.40456015000001], [5.93498595, 82.50298040000001], [6.895460999999999, 75.83849285000002], [11.087761, 55.21659015], [11.986111, 50.79761100000002], [12.57124165, 44.563427950000005], [15.262399899999998, 41.828814550000004], [27.339266099999996, 34.20131845], [29.927166, 32.566855000000004], [32.36497615, 28.787162800000004], [36.25582884999999, 14.171143199999989], [37.089583, 11.039139000000006], [36.98901405, 4.773231850000002], [36.139162799999994, -4.182775300000003], [36.86918755, -8.487389949999994], [42.41353785, -9.331828900000005], [47.68888635, -5.458406800000006], [50.7011586, 1.0547821000000113], [52.84235105, -6.168939849999987], [53.33306, -6.248889999999989]]

Code:

from shapely.geometry import LineString
from shapely.ops import transform
from functools import partial
import pyproj    
path  = LineString(path)
print(path)
# Geometry transform function based on pyproj.transform
project = partial(
    pyproj.transform,
    pyproj.Proj('EPSG:4326'),
    pyproj.Proj('EPSG:32633'))

path = transform(project, path)
print(path)
distance = path.length/1852

print(str(path.length) + " METERS")
print(str(distance) + " NM")
print(str(distance/13) + " Hr will take")

Output: enter image description here

Advertisement

Answer

Probably, previous pyproj EPSG was switching the opposite interpretation. So I change the EPSG code with below:

project = partial(
        pyproj.transform,
        pyproj.Proj('EPSG:4326'),
        pyproj.Proj('EPSG:3857'))
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement