forked from zelzhan/railway_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution2.py
31 lines (23 loc) · 841 Bytes
/
solution2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Exercise 2: Draw coordinates
Draw the coordinates from data/exercise2.txt
using bare Python
"""
import folium
f = open('../data/exercise2.txt') # <- if this doesnt work try full path
coord = [] # prepare an empty list in which we collect entries
for line in f: # go through file line by line
columns = line.split(',') # separate columns
district = columns[0]
lat = float(columns[1]) # convert to float number
lon = float(columns[2])
coord .append((lat, lon)) # append coordinate tuple
print(coord) # see what we got
print(len(coord))
# create a map
berlin = folium.Map(location=[52.50, 13.35],
zoom_start=10, tiles='stamenterrain')
for c in coord: # go through all coordinates
mark = folium.Marker(c) # icon + popup are optional
mark.add_to(berlin)
berlin.save('map.html')