In [1]:
!pip install folium
!pip install googlemaps
Requirement already satisfied: folium in ./common/.virtualenv/python2/lib/python2.7/site-packages
Requirement already satisfied: Jinja2 in /usr/local/lib/python2.7/dist-packages (from folium)
Requirement already satisfied: MarkupSafe in /usr/local/lib/python2.7/dist-packages (from Jinja2->folium)
Requirement already satisfied: googlemaps in ./common/.virtualenv/python2/lib/python2.7/site-packages
Requirement already satisfied: requests<=2.11.1 in /usr/local/lib/python2.7/dist-packages (from googlemaps)
In [2]:
import folium as fm
import pandas as pd
import numpy as np
import sys
In [3]:
# Get buildings coordinats
df = pd.read_csv('/resources/data/Open Data Day/Bauwerke1.csv')
buildings = pd.DataFrame(df[['Art des Bauwerks', 'Seitenname', 'Koordinaten']])
buildings['Long'] = float(0)
buildings['Lat'] = float(0)
buildings.dropna(axis = 0, inplace = True)
idx = np.arange(len(buildings['Seitenname']))
buildings.index = idx

# Convert buildings coordinats into right format
for i in range(len(buildings)):
    geo = buildings.iloc[i]['Koordinaten']
    string = geo.split(" ")
    t1=48
    m1=string[1]
    m1=float(m1[:-1])
    s1=string[2]
    s1=float(s1[:-2])
    erste=t1+m1/60+s1/3600
    t2=16
    m2=string[4]
    m2=float(m2[:-1])
    s2=string[5]
    s2=float(s2[:-1])
    zweite=str(t2+m2/60+s2/3600)
    buildings.set_value(i, 'Long', erste)
    buildings.set_value(i, 'Lat', zweite)
    
buildings.head()
Out[3]:
Art des Bauwerks Seitenname Koordinaten Long Lat
0 Gebäude 10er Marie 48° 12' 50", 16° 18' 31" 48.213889 16.308611
1 Gebäude AEZ 48° 12' 20", 16° 23' 4" 48.205556 16.384444
2 Gebäude Abdeckerhaus 48° 10' 58", 16° 23' 28" 48.182778 16.391111
3 Gebäude Abensperg-Traun-Palais 48° 12' 40", 16° 21' 55" 48.211111 16.365278
4 Gebäude Abgebranntes Haus 48° 11' 28", 16° 21' 58" 48.191111 16.366111
In [4]:
Vienna=[48.2080555556, 16.3680555556]
map_vienna = fm.Map(location=Vienna,zoom_start=11)
In [5]:
reload(sys)
sys.setdefaultencoding('utf8')
In [6]:
marker_cluster_buildings = fm.MarkerCluster()
for row in range(len(buildings)):
    # Create Marker
    fm.Marker(location=[buildings.iloc[row][3], buildings.iloc[row][4]], 
              popup=(buildings.iloc[row][0] + ": " + buildings.iloc[row][1])).add_to(marker_cluster_buildings)
    
map_vienna.add_children(marker_cluster_buildings)
Out[6]: