{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.append('../')\n", "import json\n", "\n", "from stimmen.latitude_longitude import reverse_latitude_longitude\n", "import folium\n", "\n", "from stimmen.cbs import get_available_provinces, province_geojson\n", "from shapely.geometry import shape\n", "\n", "import folium\n", "from IPython.display import display" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Groningen\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Friesland\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Zeeland\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "for province in ['Groningen', 'Friesland', 'Zeeland']:\n", " center = shape(province_geojson(province, with_water=True)['geometry']).centroid\n", "\n", " m = folium.Map((center.y, center.x), tiles='stamentoner', zoom_start=9)\n", " \n", " with open('../data/{}_gemeentes.geojson'.format(province), 'r') as f:\n", " gemeentes = json.load(f)\n", " with open('../data/{}_wijken.geojson'.format(province), 'r') as f:\n", " wijken = json.load(f)\n", " \n", " for feature in wijken['features']:\n", " coordinates = reverse_latitude_longitude(feature['geometry']['coordinates'])\n", " polygon = folium.Polygon(coordinates, fill_color=None, color='blue').add_to(m)\n", " \n", " for feature in gemeentes['features']:\n", " coordinates = reverse_latitude_longitude(feature['geometry']['coordinates'])\n", " polygon = folium.Polygon(coordinates, fill_color=None, color='red').add_to(m)\n", " \n", " print(province)\n", " display(m)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }