来自坐标的 LineString folium
LineString folium from coordinates
我有一个数据集,我的所有坐标都在 ['dep'] 列
109 [3.6962692140575397, 49.15078065211988]
112 [3.9507668707665, 49.247604323738]
我想获取从一个点到下一个点的线串,以便打印 folium 地图。
谢谢
我的代码:
proj = pyproj.Transformer.from_crs(2154, 4326, always_xy=True)
def transfodep(x):
x2, y2 = proj.transform(x["longitude_depart"], x["latitude_depart"])
return [x2,y2]
data_loc["dep"] = data_loc.apply(transfo, axis = 1 )
从你离开的地方开始
data_loc
longitude_depart latitude_depart dep
0 3.696269 49.150781 [3.6962692140575397, 49.15078065211988]
1 3.950767 49.247604 [3.9507668707665, 49.247604323738]
创建一个地图,x,y 到 y,x,然后创建一条线
# create a folium map
m = folium.Map([data_loc['latitude_depart'].mean(), data_loc['longitude_depart'].mean()])
# data_loc["dep"] is x,y but folium likes y,x so we flip them
s = data_loc["dep"].apply(lambda x: x[::-1])
# create a PolyLine from the flipped series
folium.PolyLine(s).add_to(m)
m
我有一个数据集,我的所有坐标都在 ['dep'] 列
109 [3.6962692140575397, 49.15078065211988]
112 [3.9507668707665, 49.247604323738]
我想获取从一个点到下一个点的线串,以便打印 folium 地图。
谢谢 我的代码:
proj = pyproj.Transformer.from_crs(2154, 4326, always_xy=True)
def transfodep(x):
x2, y2 = proj.transform(x["longitude_depart"], x["latitude_depart"])
return [x2,y2]
data_loc["dep"] = data_loc.apply(transfo, axis = 1 )
从你离开的地方开始
data_loc
longitude_depart latitude_depart dep
0 3.696269 49.150781 [3.6962692140575397, 49.15078065211988]
1 3.950767 49.247604 [3.9507668707665, 49.247604323738]
创建一个地图,x,y 到 y,x,然后创建一条线
# create a folium map
m = folium.Map([data_loc['latitude_depart'].mean(), data_loc['longitude_depart'].mean()])
# data_loc["dep"] is x,y but folium likes y,x so we flip them
s = data_loc["dep"].apply(lambda x: x[::-1])
# create a PolyLine from the flipped series
folium.PolyLine(s).add_to(m)
m