H. Dave
H. Dave

Reputation: 599

Folium and the meridians 180 & -180

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.

Fig.1: enter image description here

Fig.2: enter image description here

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

Answers (1)

H. Dave
H. Dave

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")

enter image description here

Upvotes: 3

Related Questions