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:
JavaScript
x
2
1
[[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]]
2
Code:
JavaScript
1
20
20
1
from shapely.geometry import LineString
2
from shapely.ops import transform
3
from functools import partial
4
import pyproj
5
path = LineString(path)
6
print(path)
7
# Geometry transform function based on pyproj.transform
8
project = partial(
9
pyproj.transform,
10
pyproj.Proj('EPSG:4326'),
11
pyproj.Proj('EPSG:32633'))
12
13
path = transform(project, path)
14
print(path)
15
distance = path.length/1852
16
17
print(str(path.length) + " METERS")
18
print(str(distance) + " NM")
19
print(str(distance/13) + " Hr will take")
20
Advertisement
Answer
Probably, previous pyproj EPSG was switching the opposite interpretation. So I change the EPSG code with below:
JavaScript
1
5
1
project = partial(
2
pyproj.transform,
3
pyproj.Proj('EPSG:4326'),
4
pyproj.Proj('EPSG:3857'))
5