我正在尝试使用python follium在Python中进行映射
root = r'testfolder'
fstem = 'sample1'
fname = fstem+'.csv'
f = open(os.path.join(root,fname))
df= pd.read_csv(f)
df.signal = df.signal.astype('int64', copy=False)
df = df.dropna(how='any',axis=0)
df.long = df.long.astype(float)
df.lat = df.lat.astype(float)
df['t']=[(i,j) for i,j in zip(df.lat,df.long)]
df_1=df.groupby(['event_id']).agg(lambda x: list(x))
for col in df_1.columns:
print(col)
df_1['new_col'] = df_1['signal'].astype(str).str[1]
df_1.new_col = df_1.new_col.astype('int64', copy=False)
my_map = folium.Map(location=[39.381266, -97.922211], zoom_start=4)
my_PolyLine=folium.PolyLine(locations=df_1['t'],weight=5,color='red',opacity=1)
my_map.add_children(my_PolyLine)
my_map
数据如下
event_id signal long lat
a 1 -84.52694 46.931625
a 1 -84.52684 46.931725
a 1 -94.25526333 42.71689167
a 1 -94.25524667 42.71689333
a 1 -94.25519167 42.716895
b 1 -94.25505167 42.71690833
b 1 -94.25531167 42.71687167
b 0 -94.255205 42.71689
b 0 -94.25515 42.7169
c 0 -94.25507 42.71691167
c 0 -94.25507167 42.71691167
c 0 -94.25511 42.716905
c 0 -94.25514667 42.71689833
d 0 -94.25515667 42.71689667
d 0 -94.255165 42.716895
d 0 -94.25518167 42.71689
d 0 -94.25519167 42.71688833
我正在尝试根据信号中的值对叶多义线进行颜色编码。我尝试了不同的方法,但仍然没有运气。预先谢谢你