Reputation: 599
I would like to plot with Folium a flight between Tokyo and Los Angeles over the Pacific ocean and centre the map on the Pacific ocean. But between the meridians 180 and -180, the points are not properly connected (see fig. 1). What I want is illustrated in Fig. 2.
Code:
import folium
points = [[35.7652, 140.3855], [40, 180], [40, -180], [33.9425, -118.4080]]
map = folium.Map(location=[0, 180], zoom_start=2)
folium.PolyLine(points, color="red", weight=2.5).add_to(map)
map.save("myMap.html")
Upvotes: 2
Views: 800
Reputation: 599
Thanks to @Bob Haffner for his useful help. The trick consists to add 360
for negative longitudes.
import folium
points = [[35.7652, 140.3855], [40, 180], [40, 360 -180], [33.9425, 360 -118.4080]]
map = folium.Map(location=[0, 180], zoom_start=2)
folium.PolyLine(points, color="red", weight=2.5).add_to(map)
map.save("myMap.html")
Upvotes: 3