0

I have data in the cvs files:

ID,   Name,    Address,            Latitude,     Longitude.
FOO   BO    34 Zako, Kost str.55  49.2955102    19.95274595
FOO   B1    55 Vara, Dost str 44  49.4814       20.0303
ZOO   B2    56 XXXX, YYYY str 99  49.5551       21.6766

I would like to visualize this data on the map using folium in python3. The example code for coordinates is:

import folium

logo_url = 'https://upload.wikimedia.org/wikipedia/en/c/c6/Logo_link.png'

start_lat = 52.2138
start_lng = 20.9795
csv_data_lat = 49.2955102
csv_data_lng = 19.95274595

map_1 = folium.Map(location=[start_lat, start_lng], zoom_start=12,control_scale = True)

icon = folium.features.CustomIcon(logo_url, icon_size=(50, 50))

folium.Marker([csv_data_lat, csv_data_lng], popup='PKOBP', icon=icon).add_to(map_1)

map_1.save('map1.html')

How to do it for data from csv files?

BigD
  • 77
  • 10

1 Answers1

0

I guess you could do something like this instead of the folium.Marker line:

def add_marker(row,map,icon):
   folium.Marker([row["latitude"], row["longitude"]], popup='PKOBP', icon=icon).add_to(map)

df = pd.read_csv('your_csv.csv')
df.apply(add_marker,axis=1,args=(map_1,icon,))
hanego
  • 1,595
  • 1
  • 14
  • 27