Importation et utilisation des contours des arrondissements

In [6]:
import folium
import json

geo = json.load(open("paris-arrondissements.geojson"))

centre = [48.86, 2.35]
carte = folium.Map(location = centre, zoom_start = 12)
carte.choropleth(geo_data = geo)
carte
Out[6]:
In [10]:
import pymongo
import pandas

con = pymongo.MongoClient("mongodb://193.51.82.104:2343/")
horo = con.horodateurs
mob = horo.mobiliers

res = mob.aggregate([
    { "$group" : { "_id" : "$fields.arrondt", "nb" : { "$sum" : 1}}},
    { "$sort" : { "_id": 1}}
])
df = pandas.DataFrame(list(res)) 
df.columns = ["Arrondissement", "Effectif"]
df.head()
Out[10]:
Arrondissement Effectif
0 1 87
1 2 67
2 3 133
3 4 135
4 5 267
In [19]:
carte = folium.Map(location = centre, zoom_start = 12)
carte.choropleth(geo_data = geo, key_on = "feature.properties.c_ar",
                 data = df, columns = ["Arrondissement", "Effectif"],
                 fill_color= "YlGn",
                 legend_name = "Nombre de mobiliers par quartier")
carte
Out[19]: