stimmenfryslan/notebooks/Show Province Segmentations...

2.0 MiB

Show province segmentation

In gemeentes and wijken as calculated in Segment Provinces in Wijken and Gemeentes.ipynb.

In [2]:
%load_ext autoreload

%autoreload 2
In [3]:
import sys
sys.path.append('../')
import json

from stimmen.latitude_longitude import reverse_latitude_longitude
import folium

from stimmen.cbs import get_available_provinces, province_geojson
from shapely.geometry import shape

import folium
from IPython.display import display
In [4]:
for province in ['Groningen', 'Friesland', 'Zeeland']:
    center = shape(province_geojson(province, with_water=True)['geometry']).centroid

    m = folium.Map((center.y, center.x), tiles='stamentoner', zoom_start=9)
    
    with open('../data/{}_gemeentes.geojson'.format(province), 'r') as f:
        gemeentes = json.load(f)
    with open('../data/{}_wijken.geojson'.format(province), 'r') as f:
        wijken = json.load(f)
        
    for feature in wijken['features']:
        coordinates = reverse_latitude_longitude(feature['geometry']['coordinates'])
        polygon = folium.Polygon(coordinates, fill_color=None, color='blue').add_to(m)
        
    for feature in gemeentes['features']:
        coordinates = reverse_latitude_longitude(feature['geometry']['coordinates'])
        polygon = folium.Polygon(coordinates, fill_color=None, color='red').add_to(m)
    
    print(province)
    display(m)
Groningen
Friesland
Zeeland