Reputation: 154
I would like to display informations from 2 distinct databases "df" and "df3" on folium. When I launch my following code, I only obtain the information from "df" database but do not see "df3". Then, I would like to know if I've missed a specific command for adding multiple and distinct databases on a same map.
import folium
m = folium.Map(location=[20,0], tiles="OpenStreetMap", zoom_start=2)
for i in range(0,len(df)):
folium.Circle(
location=[df.iloc[i]['Lati'], df.iloc[i]['Long']],
popup=df.iloc[i]['S'],
radius=float(df.iloc[i]['[kg]')*15,
color='crimson',
fill=True,
fill_color='crimson'
).add_to(m)
for j in range(0,len(df3)):
folium.CircleMarker(
location=[df3.iloc[j]['lat'], df3.iloc[j]['lon']],
popup=df3.iloc[j]['type'],
radius=5,
color="#3186cc",
fill=True,
fill_color="#3186cc",
).add_to(m)
# Show the map again
m
Upvotes: 0
Views: 706
Reputation: 35135
I was unable to reproduce the problem because I did not have any data to present. I created dummy data and applied your code. I have modified some of the column names, but I think the data structure is close. It seems to be a problem on the code so it may be caused by the data. Please get some hints on how to fix it from my answer.
import pandas as pd
import folium
import numpy as np
df = pd.DataFrame({'lat': np.random.rand(20)+40, 'lon': np.random.rand(20)-76, 'km': np.random.randint(1,10, 20)})
df3 = pd.DataFrame({'lat': np.random.rand(20)+41, 'lon': np.random.rand(20)-73, 'type': np.random.choice(['A','B','C'], 20)})
import folium
m = folium.Map(location=[41,-74], tiles="OpenStreetMap", zoom_start=8)
for i in range(0,len(df)):
folium.Circle(
location=[df.iloc[i]['lat'], df.iloc[i]['lon']],
popup=df.iloc[i]['km'],
radius=float(df.iloc[i]['km'])*15,
color='crimson',
fill=True,
fill_color='crimson'
).add_to(m)
for j in range(0,len(df3)):
folium.CircleMarker(
location=[df3.iloc[j]['lat'], df3.iloc[j]['lon']],
popup=df3.iloc[j]['type'],
radius=5,
color="#3186cc",
fill=True,
fill_color="#3186cc",
).add_to(m)
# Show the map again
m
Upvotes: 1