stembureau-meting/jupyter/stembureau_data.ipynb

2506 lines
729 KiB
Plaintext
Raw Normal View History

2022-03-29 17:09:40 +02:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Data gemeenteraadsverkiezingen 2022 Nederland\n",
"\n",
"Dit notebook is voor het verwerken van de data van de gemeenteraadsverkiezingen van 2022. Er zal hier stap voor stap door de data gelopen worden om het proces reproduceerbaar te maken voor latere verkiezingen. De eerste stap was de data ophalen van de bronnen, zowel de overheid als waar is mijn stemlokaal (voor geografische data van de stemlokalen). De bronnen gebruikt voor de data zijn voor de verkiezingen van 2022 is als volgt:\n",
2022-03-29 17:09:40 +02:00
"\n",
2022-04-12 16:39:06 +02:00
"- [Verkiezingsuitslagen Gemeenteraad 2022](https://data.overheid.nl/dataset/08b04bec-3332-4c76-bb0c-68bfaeb5df43)\n",
" - [Directe link naar uitslagen per gemeente CSV](https://data.overheid.nl/sites/default/files/dataset/08b04bec-3332-4c76-bb0c-68bfaeb5df43/resources/GR2022_2022-03-29T15.14.zip)\n",
" - [Directe link naar kandidatenlijst met uitslagen CSV](https://data.overheid.nl/sites/default/files/dataset/08b04bec-3332-4c76-bb0c-68bfaeb5df43/resources/GR2022_alle-kandidaten_2022-02-22T08.34.csv)\n",
2022-03-29 17:09:40 +02:00
"- [Waar is mijn stemlokaal stembureau data](https://waarismijnstemlokaal.nl/data)\n",
" - [Directe link naar waar is mijn stemlokaal gemeenteraad 2022 CSV (CKAN)](https://ckan.dataplatform.nl/datastore/dump/d6a1b4c4-73c8-457b-9b75-a38428bded68)\n",
" - [Verkiezingsuitslagen gemeenteraadsverkiezingen 2022 geodata (Volkskrant)](https://data.openstate.eu/dataset/verkiezingsuitslagen-gemeenteraadsverkiezingen-2022)\n",
" - [Directe link naar GEOJSON bestand](https://data.openstate.eu/dataset/a1767f1b-bf0c-409b-b3b1-3af9954b57f4/resource/413be255-5070-48f4-b631-895097976abb/download/2022gr.geo.json)\n",
"- [CBS Wijk- en buurtkaart 2021](https://www.cbs.nl/nl-nl/dossier/nederland-regionaal/geografische-data/wijk-en-buurtkaart-2021)\n",
" - [Directe link naar zip bestand met SHP bestand er in](https://www.cbs.nl/-/media/cbs/dossiers/nederland-regionaal/wijk-en-buurtstatistieken/wijkbuurtkaart_2021_v1.zip)\n",
2022-04-12 16:39:06 +02:00
"- [CBS bevolkingsdichtheid kaart 100 bij 100 meter](https://www.cbs.nl/nl-nl/dossier/nederland-regionaal/geografische-data/kaart-van-100-meter-bij-100-meter-met-statistieken)\n",
" - [Directe link naar 7z bestand met SHP bestand er in](https://www.cbs.nl/-/media/cbs/dossiers/nederland-regionaal/vierkanten/100/nl_vierkant_100meter_bij_100meter.7z)\n",
2022-04-12 16:39:06 +02:00
"- [CBS bevolkingsdichtheid kaart 500 bij 500 meter](https://www.cbs.nl/nl-nl/dossier/nederland-regionaal/geografische-data/kaart-van-500-meter-bij-500-meter-met-statistieken)\n",
" - [Directe link naar 7z bestand met SHP bestand er in](https://www.cbs.nl/-/media/cbs/dossiers/nederland-regionaal/vierkanten/500/2021-cbs_vk500_2020_v1.zip)\n",
2022-03-29 17:09:52 +02:00
"\n",
"De eerste stap die we moeten maken is de data importeren voor de analyse, daarna kunnen we kijken hoe goed de data is, hoe we het aan kunnen vullen, en wat er mee te doen. De makkelijkste structuur die we vonden was het geojson bestand van open state en de Volkskrant, daar staan alle stembureaus al in een lijst, en we hebben een makkelijk framework om het te importeren; geopandas. We laden deze dan ook als eerste in."
2022-03-29 17:09:52 +02:00
]
},
{
"cell_type": "code",
2022-04-12 16:39:06 +02:00
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/lillian/.local/lib/python3.9/site-packages/fiona/collection.py:208: FeatureWarning: Empty field name at index 61\n",
" self._schema = self.session.get_schema()\n",
"/home/lillian/anaconda3/lib/python3.9/site-packages/geopandas/geodataframe.py:600: UserWarning: Empty field name at index 61\n",
" for feature in features_lst:\n"
]
}
],
"source": [
"import pandas as pd\n",
"import geopandas as gpd\n",
"\n",
"crs = {'init':'EPSG:4326'}\n",
"df_geojson = gpd.read_file(r'../data/2022gr.geo.json', crs=crs)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We importeren nu de gemeente shapefile kaart van het CBS, om de overlay van onze stemlokalen eroverheen te kunnen doen. "
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:>"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAOQAAAD4CAYAAAD8Q0ptAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAACE4ElEQVR4nO29d3xj6V3v/1avli3JlizLXS7j8Xjs8ZTtm4SUTVhICIQQCOSXQgIJCTWQCxcIhBIIF24ul3BJIbmXkA4khIRks4Sw2ZLdtce927Jc5Kpiq3fp98exzliWXGZnZ8ezo/frpddrLJ1z9Eij73me51s+XwmQo0yZMqcC6a0eQJkyZa5RNsgyZU4RZYMsU+YUUTbIMmVOEWWDLFPmFCG/1QMoxfb2NsvLy7d6GGXK3DSampqwWCxFz59Kg1xeXuby5cu3ehhlytw0BgYGSj5fXrKWKXOKKBtkmTKniLJBlilziigbZJkyp4iyQZYpc4ooG2SZMqeIskGWKXOKKBtkmTKniLJBlnlRIJFIkMnlSCSSQ1//oXe8hfqznS/wyK6PU5mpU6bM9dB25SKv/c1fxn6mg0w6jX9tHVNdHdlMhkwmTTaTAUBrMPDKX3gbX/3wX/HsV//tFo+6NCcySJfLRSgUIpPJkE6nuXz5Mh/60Id43eteRzabZXt7m7e+9a1sbGyc6NwyZZ4PzA12Xvubv8y5lz0oPrcyPoVar8O/vkFNUwNxXwTvihulRo3WYECpUfNTH/oduh68l3/60J8T2dm9dR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VFpq9v7OFBxbKqaYTiQBxGvsx1QnzPy
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nl_map = gpd.read_file(r'../data/shape/Netherlands_shapefile/gemeente_2021_v1.shp')\n",
"nl_map.to_crs(epsg=4326).plot()\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
2022-04-12 16:39:06 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" GM_CODE GM_NAAM H2O OAD STED BEV_DICHTH AANT_INW \\\n",
"0 GM0034 Almere JA -99999999 -99999999 -99999999 -99999999 \n",
"1 GM0050 Zeewolde JA -99999999 -99999999 -99999999 -99999999 \n",
"2 GM0060 Ameland JA -99999999 -99999999 -99999999 -99999999 \n",
"3 GM0072 Harlingen JA -99999999 -99999999 -99999999 -99999999 \n",
"4 GM0088 Schiermonnikoog JA -99999999 -99999999 -99999999 -99999999 \n",
".. ... ... ... ... ... ... ... \n",
"430 GM1966 Het Hogeland NEE 414 5 99 47834 \n",
"431 GM1969 Westerkwartier NEE 476 5 176 63678 \n",
"432 GM1970 Noardeast-Fryslân NEE 463 5 120 45481 \n",
"433 GM1978 Molenlanden NEE 393 5 243 44130 \n",
"434 GM1979 Eemsdelta NEE 692 4 170 45587 \n",
"\n",
" AANT_MAN AANT_VROUW P_00_14_JR ... P_TURKIJE P_OVER_NW OPP_TOT \\\n",
"0 -99999999 -99999999 -99999999 ... -99999999 -99999999 -99999999 \n",
"1 -99999999 -99999999 -99999999 ... -99999999 -99999999 -99999999 \n",
"2 -99999999 -99999999 -99999999 ... -99999999 -99999999 -99999999 \n",
"3 -99999999 -99999999 -99999999 ... -99999999 -99999999 -99999999 \n",
"4 -99999999 -99999999 -99999999 ... -99999999 -99999999 -99999999 \n",
".. ... ... ... ... ... ... ... \n",
"430 24052 23782 15 ... 0 3 90308 \n",
"431 32034 31644 17 ... 0 3 36887 \n",
"432 22879 22602 17 ... 0 2 51645 \n",
"433 22317 21813 18 ... 0 2 19158 \n",
"434 22841 22746 14 ... 2 5 36407 \n",
"\n",
" OPP_LAND OPP_WATER JRSTATCODE JAAR Shape_Leng Shape_Area \\\n",
"0 -99999999 -99999999 2021GM0034 2021 122665.358635 1.095623e+08 \n",
"1 -99999999 -99999999 2021GM0050 2021 83290.773617 1.633050e+07 \n",
"2 -99999999 -99999999 2021GM0060 2021 156406.894023 2.085914e+08 \n",
"3 -99999999 -99999999 2021GM0072 2021 104274.683035 3.618323e+08 \n",
"4 -99999999 -99999999 2021GM0088 2021 152568.858991 1.624101e+08 \n",
".. ... ... ... ... ... ... \n",
"430 48249 42059 2021GM1966 2021 321301.166576 4.875998e+08 \n",
"431 36269 618 2021GM1969 2021 99030.762281 3.688457e+08 \n",
"432 37783 13862 2021GM1970 2021 238426.959926 3.837930e+08 \n",
"433 18173 986 2021GM1978 2021 88570.376691 1.915841e+08 \n",
"434 26789 9618 2021GM1979 2021 173966.493452 2.727771e+08 \n",
"\n",
" geometry \n",
"0 MULTIPOLYGON (((150213.998 479503.726, 150087.... \n",
"1 MULTIPOLYGON (((170588.413 486792.192, 170570.... \n",
"2 POLYGON ((196000.000 610000.000, 196000.000 60... \n",
"3 MULTIPOLYGON (((158392.775 580357.500, 158387.... \n",
"4 POLYGON ((219000.000 616567.418, 219000.000 61... \n",
".. ... \n",
"430 MULTIPOLYGON (((217037.735 601967.991, 217043.... \n",
"431 POLYGON ((215186.661 595044.495, 215190.788 59... \n",
"432 MULTIPOLYGON (((207769.575 603284.528, 207773.... \n",
"433 POLYGON ((123569.533 440132.167, 123576.153 44... \n",
"434 MULTIPOLYGON (((269190.000 594253.046, 269190.... \n",
"\n",
"[435 rows x 38 columns]\n"
]
2022-04-12 16:39:06 +02:00
}
],
"source": [
"print(nl_map)"
2022-04-12 16:39:06 +02:00
]
},
{
"cell_type": "code",
"execution_count": 5,
2022-03-29 17:09:52 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:>"
2022-03-29 17:09:52 +02:00
]
},
"execution_count": 5,
2022-03-29 17:09:52 +02:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAGMAAAI/CAYAAABj6GcwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAP0klEQVR4nO3cXWxTZ4LG8ceOM3QCGmIw9mmTKlSrZhZ6UXLhtLPRTtUqgdBe0NkuGjSjlaUiZy9a9WOqEmsqbTsabSfA7LY3vdhGVI2QogotSmPU3eYkrqpFGQQHYT4icsalskIi4phI3aqbnaVA3r3oJMNHEjsOdp7az086Umyf4/eV/5wvwPEAMBAK3tWegPyFYhBRDCKKQUQxiCgGEV8pB8tmsxgbGyvlkHQaGhoQDAYXfK2kMcbGxhAOh0s5JB3HcRZ9TYcpIopBRDGIKAYRxSCiGEQUg4hiEFEMIopBRDGIKAYRxSCiGEQUg4hiEFEMIopBRDGIKAYRxSBS0v8d8n3W9PR27PntG6iqrp5/bvbmTfzpm//B2vU/wleZKawPboK3quq27YY/Ooq+t/8lrzEUYxHRf3sXP/5J823PeTye2x5X+XxY568FAGx44H4YY+5ap2XPcwCQVxAdphYwF8Lj8dy25LLQOh6PBy17nsOB5HE0Pb19ye21Z9yi6ent+Plvfg3fmh/k9eHny+PxoMrnwy9+9yZqfvijRddTjD9reno7ftn11j2NcCev14sNdQ8s/nrRRv6e+cXv3ixqiHwoxp+tdghAMQAg54m1VBQDwN//0z7tGSzW1NSs9hQAKEZJGWPwfzMzi75e8TEOnhsu6XjTY+OLvlbRMQ6eG8777roUKjYGWwigQmMwhgAqMMYbdh9lCKDC/m5qNfcIYwyMWfoXGFXEnvGro4fx+/N/WPUQrz/asuR6Zb9n/Oa//hNra9ev+mEpVwigzPeMn/36tVUPYYzBH0+cymvdst4z/ubnf7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RxSCiGEQUg4hiEFEMIopBRDGIKAYRxSCiGEQUg4hiEFEMIopBRDGIKAYRxSCiGEQUg4hiEFEMIopBRDGIKAYRxSCiGEQUg4hiEFEMIopBRDGIKAYRxSCiGEQUg4hiEFEMIopBRDGIKAYRxSCiGEQUg4hiEFEMIopBRDGIKAYRxSCiGEQUg4hiEFEMIopBRDGIKAYRxSCiGEQUg0jOGPX19fjss89w8eJFjIyM4KWXXgIA+P1+2LaNVCoF27ZRW1tb7LmWvZwxbty4gddeew1bt27F448/jhdeeAFbtmxBLBZDIpFAY2MjEokEYrFYKeZb9sxylo8//ti0trYa13WNZVkGgLEsy7ium3Nbx3GWNVY5Lkt9Bss6ZzQ0NKCpqQknT55EKBRCJpMBAGQyGQSDweW8lSzAl++Ka9euxdGjR/HKK6/gm2++yXuAaDSKjo4OAEAgEFj+DCtMzl3L5/OZTz/91Lz66qvzz+kwtUqHqUOHDmF0dBTvvPPO/HPxeByRSAQAEIlE0N/fn89bSQ5LlmxpaTHGGHPu3DmTTCZNMpk0O3fuNBs2bDBDQ0MmlUqZoaEh4/f7tWescM/Iec4YHh6Gx+NZ8LXW1tZcm8sy6A6ciGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiikFEMYgoBhHFIKIYRBSDiGIQUQwiOWMcOnQIU1NTuHD
"text/plain": [
"<Figure size 720x720 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"fig, ax = plt.subplots(figsize = (10,10))\n",
"nl_map.to_crs(epsg=4326).plot(ax=ax, color='lightgrey')\n",
"df_geojson.plot(ax=ax)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We hebben hier een probleem dat sommige punten de coördinaten 0,0 hebben, dit is niet iets wat we willen weergeven. Laten we eerst kijken waarom dit het geval is in de data voordat we het er helemaal uithalen."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Stembureau 32\n",
"Adres \n",
"Locatie SB32\n",
"description Stembureau Mobiel Stembureau 1\n",
"Geldige stemmen 99\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 2520, Length: 973, dtype: object\n",
"Stembureau 33\n",
"Adres \n",
"Locatie SB33\n",
"description Stembureau Mobiel Stembureau 2\n",
"Geldige stemmen 115\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 2521, Length: 973, dtype: object\n",
"Stembureau 157\n",
"Adres \n",
"Locatie SB157\n",
"description Stembureau Stembureau Stembus\n",
"Geldige stemmen 72\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 2918, Length: 973, dtype: object\n",
"Stembureau 171\n",
"Adres \n",
"Locatie SB171\n",
"description Stembureau Stembureau Stembureau op locatie al...\n",
"Geldige stemmen 174\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 3579, Length: 973, dtype: object\n",
"Stembureau 172\n",
"Adres \n",
"Locatie SB172\n",
"description Stembureau Stembureau Stembureau op locatie al...\n",
"Geldige stemmen 66\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 3580, Length: 973, dtype: object\n",
"Stembureau 173\n",
"Adres \n",
"Locatie SB173\n",
"description Stembureau Stembureau Stembureau op locatie al...\n",
"Geldige stemmen 162\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 3581, Length: 973, dtype: object\n",
"Stembureau 174\n",
"Adres \n",
"Locatie SB174\n",
"description Stembureau Stembureau Stembureau op locatie al...\n",
"Geldige stemmen 65\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 3582, Length: 973, dtype: object\n",
"Stembureau 175\n",
"Adres \n",
"Locatie SB175\n",
"description Stembureau Stembureau Stembureau op locatie al...\n",
"Geldige stemmen 121\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 3583, Length: 973, dtype: object\n",
"Stembureau 39\n",
"Adres \n",
"Locatie SB39\n",
"description Stembureau Mobiel stembureau met beperkte toeg...\n",
"Geldige stemmen 56\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 5494, Length: 973, dtype: object\n",
"Stembureau 34\n",
"Adres \n",
"Locatie SB34\n",
"description Stembureau Stembureau Mobiel stembureau verzor...\n",
"Geldige stemmen 119\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 5784, Length: 973, dtype: object\n",
"Stembureau 35\n",
"Adres \n",
"Locatie SB35\n",
"description Stembureau Stembureau Mobiel stembureau verzor...\n",
"Geldige stemmen 151\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 5785, Length: 973, dtype: object\n",
"Stembureau 11\n",
"Adres \n",
"Locatie SB11\n",
"description Stembureau Mobiel stembureau Ommedijk\n",
"Geldige stemmen 14\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 6260, Length: 973, dtype: object\n",
"Stembureau 12\n",
"Adres \n",
"Locatie SB12\n",
"description Stembureau Mobiel stembureau Van Alphenstaete ...\n",
"Geldige stemmen 68\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 6261, Length: 973, dtype: object\n",
"Stembureau 70\n",
"Adres \n",
"Locatie SB70\n",
"description Stembureau Mobiel stembureau\n",
"Geldige stemmen 34\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 6738, Length: 973, dtype: object\n",
"Stembureau 71\n",
"Adres \n",
"Locatie SB71\n",
"description Stembureau Mobiel stembureau\n",
"Geldige stemmen 43\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 6739, Length: 973, dtype: object\n",
"Stembureau 699\n",
"Adres \n",
"Locatie SB699\n",
"description Stembureau Stembureau Mobiel stembureau\n",
"Geldige stemmen 59\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 6863, Length: 973, dtype: object\n",
"Stembureau 32\n",
"Adres \n",
"Locatie SB32\n",
"description Stembureau Mobielstembureau\n",
"Geldige stemmen 63\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7348, Length: 973, dtype: object\n",
"Stembureau 90\n",
"Adres \n",
"Locatie SB90\n",
"description Stembureau Roll and Vote\n",
"Geldige stemmen 339\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7364, Length: 973, dtype: object\n",
"Stembureau 19\n",
"Adres \n",
"Locatie SB19\n",
"description Stembureau Mobiel stembureau\n",
"Geldige stemmen 77\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7857, Length: 973, dtype: object\n",
"Stembureau 1428\n",
"Adres \n",
"Locatie SB1428\n",
"description Stembureau Drive-thru parkeerplaats Rusheuvel 1\n",
"Geldige stemmen 163\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7912, Length: 973, dtype: object\n",
"Stembureau 1437\n",
"Adres \n",
"Locatie SB1437\n",
"description Stembureau Drive-thru parkeerplaats Rusheuvel 2\n",
"Geldige stemmen 239\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7913, Length: 973, dtype: object\n",
"Stembureau 1528\n",
"Adres \n",
"Locatie SB1528\n",
"description Stembureau Drive-thru parkeerplaats Rusheuvel 1\n",
"Geldige stemmen 323\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7923, Length: 973, dtype: object\n",
"Stembureau 1537\n",
"Adres \n",
"Locatie SB1537\n",
"description Stembureau Drive-thru parkeerplaats Rusheuvel 2\n",
"Geldige stemmen 208\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7924, Length: 973, dtype: object\n",
"Stembureau 1541\n",
"Adres \n",
"Locatie SB1541\n",
"description Stembureau Mobiel stembureau\n",
"Geldige stemmen 125\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7926, Length: 973, dtype: object\n",
"Stembureau 200\n",
"Adres \n",
"Locatie SB200\n",
"description Stembureau Mobiel stembureau Ma\n",
"Geldige stemmen 30\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7958, Length: 973, dtype: object\n",
"Stembureau 201\n",
"Adres \n",
"Locatie SB201\n",
"description Stembureau Mobiel stembureau Di\n",
"Geldige stemmen 30\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7959, Length: 973, dtype: object\n",
"Stembureau 202\n",
"Adres \n",
"Locatie SB202\n",
"description Stembureau Mobiel stembureau Woe\n",
"Geldige stemmen 44\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 7960, Length: 973, dtype: object\n",
"Stembureau 30\n",
"Adres \n",
"Locatie SB30\n",
"description Stembureau Stembureau voor de telling stembure...\n",
"Geldige stemmen 2004\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 8108, Length: 973, dtype: object\n",
"Stembureau 40\n",
"Adres \n",
"Locatie SB40\n",
"description Stembureau Stembureau voor de telling stembure...\n",
"Geldige stemmen 2953\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 8109, Length: 973, dtype: object\n",
"Stembureau 990\n",
"Adres \n",
"Locatie SB990\n",
"description Stembureau Mobiel stembureau (meerdere plaatsen)\n",
"Geldige stemmen 47\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 8161, Length: 973, dtype: object\n",
"Stembureau 991\n",
"Adres \n",
"Locatie SB991\n",
"description Stembureau Mobiel stembureau (meerdere plaatsen)\n",
"Geldige stemmen 70\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 8162, Length: 973, dtype: object\n",
"Stembureau 992\n",
"Adres \n",
"Locatie SB992\n",
"description Stembureau Mobiel stembureau (meerdere plaatsen)\n",
"Geldige stemmen 39\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 8163, Length: 973, dtype: object\n",
"Stembureau 17\n",
"Adres \n",
"Locatie SB17\n",
"description Stembureau Mobiel Stembureau dinsdag\n",
"Geldige stemmen 115\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 8318, Length: 973, dtype: object\n",
"Stembureau 228\n",
"Adres \n",
"Locatie SB228\n",
"description Stembureau Stembureau Drive-in\n",
"Geldige stemmen 80\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 9093, Length: 973, dtype: object\n",
"Stembureau 30\n",
"Adres \n",
"Locatie SB30\n",
"description Stembureau Mobiel stembureau\n",
"Geldige stemmen 25\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 9151, Length: 973, dtype: object\n",
"Stembureau 31\n",
"Adres \n",
"Locatie SB31\n",
"description Stembureau Mobiel stembureau\n",
"Geldige stemmen 8\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 9152, Length: 973, dtype: object\n",
"Stembureau 32\n",
"Adres \n",
"Locatie SB32\n",
"description Stembureau Mobiel stembureau\n",
"Geldige stemmen 24\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 9153, Length: 973, dtype: object\n",
"Stembureau 76\n",
"Adres \n",
"Locatie SB76\n",
"description Stembureau Rondvaartboot Toerist VI\n",
"Geldige stemmen 148\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 9661, Length: 973, dtype: object\n",
"Stembureau 68\n",
"Adres \n",
"Locatie SB68\n",
"description Stembureau Drive Inn (evenemententerrein Het L...\n",
"Geldige stemmen 285\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 9853, Length: 973, dtype: object\n",
"Stembureau 14\n",
"Adres \n",
"Locatie SB14\n",
"description Stembureau Mobiel Stembureau\n",
"Geldige stemmen 24\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10427, Length: 973, dtype: object\n",
"Stembureau 18\n",
"Adres \n",
"Locatie SB18\n",
"description Stembureau Mobiel stembureau\n",
"Geldige stemmen 50\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10431, Length: 973, dtype: object\n",
"Stembureau 23\n",
"Adres \n",
"Locatie SB23\n",
"description Stembureau Stembureau Mobiel: Wkp Zout Veere\n",
"Geldige stemmen 55\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10497, Length: 973, dtype: object\n",
"Stembureau 24\n",
"Adres \n",
"Locatie SB24\n",
"description Stembureau Stembureau Mobiel: Okp Dom\n",
"Geldige stemmen 35\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10498, Length: 973, dtype: object\n",
"Stembureau 115\n",
"Adres \n",
"Locatie SB115\n",
"description Stembureau Tent Nijverheidslaan\n",
"Geldige stemmen 258\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10525, Length: 973, dtype: object\n",
"Stembureau 116\n",
"Adres \n",
"Locatie SB116\n",
"description Stembureau Tent Nijverheidslaan\n",
"Geldige stemmen 377\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10526, Length: 973, dtype: object\n",
"Stembureau 117\n",
"Adres \n",
"Locatie SB117\n",
"description Stembureau Tent Peter Benenson park\n",
"Geldige stemmen 285\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10527, Length: 973, dtype: object\n",
"Stembureau 118\n",
"Adres \n",
"Locatie SB118\n",
"description Stembureau Tent Peter Benenson park\n",
"Geldige stemmen 329\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10528, Length: 973, dtype: object\n",
"Stembureau 310\n",
"Adres \n",
"Locatie SB310\n",
"description Stembureau Mobiel Bijzonder stembureau 1\n",
"Geldige stemmen 26\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10623, Length: 973, dtype: object\n",
"Stembureau 311\n",
"Adres \n",
"Locatie SB311\n",
"description Stembureau Mobiel Bijzonder stembureau 2\n",
"Geldige stemmen 55\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10624, Length: 973, dtype: object\n",
"Stembureau 88\n",
"Adres \n",
"Locatie SB88\n",
"description Stembureau Mobiel stembureau 1\n",
"Geldige stemmen 78\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10894, Length: 973, dtype: object\n",
"Stembureau 89\n",
"Adres \n",
"Locatie SB89\n",
"description Stembureau Mobiel stembureau 2\n",
"Geldige stemmen 35\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 10895, Length: 973, dtype: object\n",
"Stembureau 31\n",
"Adres \n",
"Locatie SB31\n",
"description Stembureau Stembureau Mobiel Stembureau\n",
"Geldige stemmen 32\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 11032, Length: 973, dtype: object\n",
"Stembureau 0\n",
"Adres \n",
"Locatie SB0\n",
"description Stembureau -\n",
"Geldige stemmen 0\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 11101, Length: 973, dtype: object\n",
"Stembureau 132\n",
"Adres \n",
"Locatie SB132\n",
"description Stembureau Stembureau IJsselhallen drive thoug...\n",
"Geldige stemmen 52\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 12038, Length: 973, dtype: object\n",
"Stembureau 133\n",
"Adres \n",
"Locatie SB133\n",
"description Stembureau Stembureau IJsselhallen drive throu...\n",
"Geldige stemmen 48\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 12039, Length: 973, dtype: object\n",
"Stembureau 232\n",
"Adres \n",
"Locatie SB232\n",
"description Stembureau Stembureau IJsselhallen drive thoug...\n",
"Geldige stemmen 113\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 12053, Length: 973, dtype: object\n",
"Stembureau 233\n",
"Adres \n",
"Locatie SB233\n",
"description Stembureau Stembureau IJsselhallen drive throu...\n",
"Geldige stemmen 73\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 12054, Length: 973, dtype: object\n",
"Stembureau 358\n",
"Adres \n",
"Locatie SB358\n",
"description Stembureau Stembureau Mobiel stembureau 1\n",
"Geldige stemmen 70\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 12118, Length: 973, dtype: object\n",
"Stembureau 359\n",
"Adres \n",
"Locatie SB359\n",
"description Stembureau Stembureau Mobiel stembureau 2\n",
"Geldige stemmen 169\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 12119, Length: 973, dtype: object\n",
"Stembureau 360\n",
"Adres \n",
"Locatie SB360\n",
"description Stembureau Stembureau Mobiel stembureau 3\n",
"Geldige stemmen 89\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 12120, Length: 973, dtype: object\n",
"Stembureau 361\n",
"Adres \n",
"Locatie SB361\n",
"description Stembureau Stembureau Mobiel stembureau 4\n",
"Geldige stemmen 36\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie NaN\n",
"RAADSGROEPERING ''BOSCH-BELANG'' NaN\n",
"gewoon ge-DREVEN NaN\n",
"VOOR Den Bosch Joep Gersjes NaN\n",
"geometry POINT (0 0)\n",
"Name: 12121, Length: 973, dtype: object\n",
"Stembureau 114\n",
"Adres \n",
"Locatie SB114\n",
"description Stembureau Stembureau Mobiel stembureau (beper...\n",
"Geldige stemmen 109\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie 11.0\n",
"RAADSGROEPERING ''BOSCH-BELANG'' 8.0\n",
"gewoon ge-DREVEN 0.0\n",
"VOOR Den Bosch Joep Gersjes 1.0\n",
"geometry POINT (0 0)\n",
"Name: 12504, Length: 973, dtype: object\n",
"Stembureau 115\n",
"Adres \n",
"Locatie SB115\n",
"description Stembureau Stembureau Mobiel Stembureau (beper...\n",
"Geldige stemmen 80\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie 9.0\n",
"RAADSGROEPERING ''BOSCH-BELANG'' 5.0\n",
"gewoon ge-DREVEN 0.0\n",
"VOOR Den Bosch Joep Gersjes 3.0\n",
"geometry POINT (0 0)\n",
"Name: 12505, Length: 973, dtype: object\n",
"Stembureau 116\n",
"Adres \n",
"Locatie SB116\n",
"description Stembureau Stembureau Mobiel Stembureau (beper...\n",
"Geldige stemmen 119\n",
" ... \n",
"\"Leefbaar 's-Hertogenbosch\" Paul Kagie 3.0\n",
"RAADSGROEPERING ''BOSCH-BELANG'' 3.0\n",
"gewoon ge-DREVEN 20.0\n",
"VOOR Den Bosch Joep Gersjes 3.0\n",
"geometry POINT (0 0)\n",
"Name: 12506, Length: 973, dtype: object\n"
]
2022-03-29 17:09:52 +02:00
}
],
"source": [
"for index, row in df_geojson.iterrows():\n",
" if (row.geometry.centroid.x == 0.00000):\n",
" print(row)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Het zijn dus duidelijk allemaal mobiele stembureaus, die kunnen we in een aparte dataset houden voor later, voor nu zijn ze onbelangrijk voor de kaartweergave, laten we de dataset dus opsplitsen in drie dataframes, de originele, één frame zonder de mobiele stembureaus, en de mobiele stembureaus alleen."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_11867/291552514.py:3: UserWarning: Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.\n",
"\n",
" mobiel_mask = df_geojson['geometry'].centroid.x == 0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"2520\n",
"2521\n",
"2918\n",
"3579\n",
"3580\n",
"3581\n",
"3582\n",
"3583\n",
"5494\n",
"5784\n",
"5785\n",
"6260\n",
"6261\n",
"6738\n",
"6739\n",
"6863\n",
"7348\n",
"7364\n",
"7857\n",
"7912\n",
"7913\n",
"7923\n",
"7924\n",
"7926\n",
"7958\n",
"7959\n",
"7960\n",
"8108\n",
"8109\n",
"8161\n",
"8162\n",
"8163\n",
"8318\n",
"9093\n",
"9151\n",
"9152\n",
"9153\n",
"9661\n",
"9853\n",
"10427\n",
"10431\n",
"10497\n",
"10498\n",
"10525\n",
"10526\n",
"10527\n",
"10528\n",
"10623\n",
"10624\n",
"10894\n",
"10895\n",
"11032\n",
"11101\n",
"12038\n",
"12039\n",
"12053\n",
"12054\n",
"12118\n",
"12119\n",
"12120\n",
"12121\n",
"12504\n",
"12505\n",
"12506\n"
]
}
],
"source": [
"#de waarschuwing over de projectie die niet klopt kan genegeerd worden, we zoeken naar data die x = 0 is, de projectie gaat geen effect hebben op die data in Nederland\n",
"#filter de data en print welke waardes 0 hebben op x\n",
"mobiel_mask = df_geojson['geometry'].centroid.x == 0\n",
"i = 0\n",
"for item in mobiel_mask:\n",
" if item:\n",
" print(i)\n",
" i = i + 1"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Stembureau Adres Locatie \\\n",
"0 1 9461BH SB1 \n",
"1 2 9461DA SB2 \n",
"2 3 9461JA SB3 \n",
"3 4 9451KD SB4 \n",
"4 6 9454PL SB6 \n",
"... ... ... ... \n",
"12591 703 5391AR SB703 \n",
"12592 705 5391AR SB705 \n",
"12593 750 5382KE SB750 \n",
"12594 751 5382KE SB751 \n",
"12595 752 5283KE SB752 \n",
"\n",
" description Geldige stemmen \\\n",
"0 Stembureau Gemeentehuis Gieten (postcode: 9461... 784 \n",
"1 Stembureau OBS Gieten (postcode: 9461 DA) 562 \n",
"2 Stembureau Zorgcentrum Dekelhem (postcode: 946... 566 \n",
"3 Stembureau Ontmoetingscentrum Boerhorn Rolde (... 1495 \n",
"4 Stembureau Dropshuis de Eekhof (postcode: 9454... 347 \n",
"... ... ... \n",
"12591 Stembureau Stembureau Gemeenschapshuis de Meen... 268 \n",
"12592 Stembureau Stembureau Gemeenschapshuis De Meen... 398 \n",
"12593 Stembureau Stembureau Gemeenschapshuis 't Zijl... 663 \n",
"12594 Stembureau Stembureau Gemeenschapshuis 't Zijl... 170 \n",
"12595 Stembureau Stembureau Gemeenschapshuis 't Zijl... 222 \n",
"\n",
" Opgeroepen Ongeldig Blanco Geldige stempassen \\\n",
"0 2780 3 3 700 \n",
"1 1396 0 0 518 \n",
"2 1409 2 2 516 \n",
"3 2209 2 4 1335 \n",
"4 477 0 2 298 \n",
"... ... ... ... ... \n",
"12591 0 0 1 237 \n",
"12592 0 1 0 359 \n",
"12593 2321 2 0 552 \n",
"12594 0 0 0 151 \n",
"12595 0 0 0 193 \n",
"\n",
" Geldige volmachtbewijzen ... \\\n",
"0 90 ... \n",
"1 44 ... \n",
"2 54 ... \n",
"3 166 ... \n",
"4 51 ... \n",
"... ... ... \n",
"12591 32 ... \n",
"12592 40 ... \n",
"12593 113 ... \n",
"12594 19 ... \n",
"12595 29 ... \n",
"\n",
" Nationale Bond tegen Overheidszaken - DH Haags Belang INL Den Haag \\\n",
"0 NaN NaN NaN \n",
"1 NaN NaN NaN \n",
"2 NaN NaN NaN \n",
"3 NaN NaN NaN \n",
"4 NaN NaN NaN \n",
"... ... ... ... \n",
"12591 NaN NaN NaN \n",
"12592 NaN NaN NaN \n",
"12593 NaN NaN NaN \n",
"12594 NaN NaN NaN \n",
"12595 NaN NaN NaN \n",
"\n",
" Rosmalens Belang De Bossche Groenen \\\n",
"0 NaN NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 NaN NaN \n",
"... ... ... \n",
"12591 105.0 2.0 \n",
"12592 174.0 6.0 \n",
"12593 47.0 19.0 \n",
"12594 8.0 11.0 \n",
"12595 10.0 2.0 \n",
"\n",
" \"Leefbaar 's-Hertogenbosch\" Paul Kagie \\\n",
"0 NaN \n",
"1 NaN \n",
"2 NaN \n",
"3 NaN \n",
"4 NaN \n",
"... ... \n",
"12591 6.0 \n",
"12592 2.0 \n",
"12593 53.0 \n",
"12594 13.0 \n",
"12595 22.0 \n",
"\n",
" RAADSGROEPERING ''BOSCH-BELANG'' gewoon ge-DREVEN \\\n",
"0 NaN NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 NaN NaN \n",
"... ... ... \n",
"12591 0.0 33.0 \n",
"12592 3.0 31.0 \n",
"12593 2.0 62.0 \n",
"12594 1.0 22.0 \n",
"12595 2.0 28.0 \n",
"\n",
" VOOR Den Bosch Joep Gersjes geometry \n",
"0 NaN POINT (6.75899 53.00524) \n",
"1 NaN POINT (6.75990 52.99975) \n",
"2 NaN POINT (6.76600 53.00494) \n",
"3 NaN POINT (6.64736 52.98281) \n",
"4 NaN POINT (6.60459 52.95269) \n",
"... ... ... \n",
"12591 0.0 POINT (5.43290 51.72810) \n",
"12592 2.0 POINT (5.43290 51.72810) \n",
"12593 5.0 POINT (5.45919 51.70595) \n",
"12594 1.0 POINT (5.45919 51.70595) \n",
"12595 0.0 POINT (5.45919 51.70595) \n",
"\n",
"[12532 rows x 973 columns]\n"
]
}
],
"source": [
"df_geojson_clean = df_geojson[~mobiel_mask]\n",
"df_geojson_mobiel = df_geojson[mobiel_mask]\n",
"print(df_geojson_clean)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAuIAAANOCAYAAABUSmkeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOy9eXQraXnn/63SLtnyvsnyvi/X9vW1u2n60jRN08lAQieBQELC0iEhMKEhDAyHOSQkwwAn6x+Z5I8kEObMmYSBTOYHmRnoQyeTZJqwNPa9tq/3fZMty6ssay+p6veHXHVLpVpl+dr39vs550JbKlW9VSpJ3/d5n+f7UAA4EAgEAoFAIBAIhAcKfdUDIBAIBAKBQCAQXosQIU4gEAgEAoFAIFwBRIgTCAQCgUAgEAhXABHiBAKBQCAQCATCFUCEOIFAIBAIBAKBcAWYr3oAcuzv72Nzc/Oqh0EgEAgEAoFAIFyIpqYmVFdXyz53LYX45uYmRkdHr3oYBAKBQCAQCATChRgbG1N8jqSmEAgEAoFAIBAIVwAR4gQCgUAgEAgEwhVAhDiBQCAQCAQCgXAFECFOIBAIBAKBQCBcAUSIEwgEAoFAIBAIVwAR4gQCgUAgEAgEwhVAhDiBQCAQCAQCgXAFECFOIBAIBAKBQCBcAUSIEwgEAoFAIBAIVwAR4gQCgUAgEAgEwhVAhDiBQCAQCAQCgXAFECFOIBAIBAKBQCBcAUSIEwgEAoFAIBAIVwAR4gQCgUAgEAgEwhVAhDiBQCAQCAQCgXAFECFOIBAIBAKBQCBcAUSIEwgEAoFAIBAIVwAR4gQCgUAgEAgEwhVAhDiBQCAQCAQCgXAFECFOIBAIBAKBQCBcAUSIEwgEAoFAIBAIVwAR4gQCgUAgEAgEwhVAhDiBQCAQCAQCgXAFECFOI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fx8f+MAH4Pf7db32IgMmEAgEAoFw+Xi9Xrz00ksP9JjpdBr7+/s4OjpCLBaD1WqFx+NRFNInJycIh8PY29tDeXk52trahOd++MMf4oknnnhQQ78yotEovvSlL+Hv//7vr3ooBAUKIsRHRkZwdHQkPFZcXIyzszMAwIsvvoje3l585CMf0fXaiwyYQCAQCATC5fPrv/7r+OhHP1qw/TEMg2AwiGAwiGQyKXSlpGkaJpMJRUVFqKurk+0qmUgkcHZ2BoZhYLPZcHBwAIZh0N/fL+SJS0kmk6Ao6lLTRK4Tf//3f48vfvGLJFXlGqKma/POEedFOJAxwed9NwkEAoFAIDz8vO1tb9O9bTqdRjAYxOHhIeLxOJLJJMxmM5xOJ0pLSwWXkaqqqrzSRO7du5clZMrLy4X/lhPhAGC1WhEOh18zQvz555/HwMAAPvOZz2Bubu6qh0PQiS4hznEcXn75ZXAch7/4i7/Al7/8ZQDAF77wBbzvfe/D6ekp3vSmNxl6LYFAIBAIhOtJT0+PrE1eKBTC/v4+gsEgSkpK4HA44HK54Ha7UVFRgYqKioKN4fj4GKurq7BarZrt5uUIBAKoqakp2HgeBlpaWvDXf/3X+LM/+zP8l//yX0iQ9CFAV2pKXV0d/H4/qqqq8A//8A948cUX8b3vfU94/jOf+Qzsdjt+93d/1/BreX7t134NH/rQhwAAlZWVxCeTQCAQCIQHgNlsRk1NDWpqalBbW4uamhq84Q1vyFlK39vbw+npKSwWC1pbWy90zHQ6DZPJlPM4y7I4Pj7G+vo6urq6ZJ1VxsbG4HA4wLIsEokESkpKYDKZYLFYUF1dDbvdjo2NDXAc95rWEq+++io++9nPIhAIXPVQXvNcOEdczO/8zu8gHA7jj//4j4XHGhsb8e1vfxs3btww/FqjAyYQCAQCQY2f/umfxi/8wi/g5Zdfxre+9S2cnp5e9ZAeCDRNY2hoCH19faisrAT
"text/plain": [
"<Figure size 1080x1080 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(figsize = (15,15))\n",
"nl_map.to_crs(epsg=4326).plot(ax=ax, color='lightgrey')\n",
"df_geojson_clean.plot(ax=ax)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Nu we een mooie kaart hebben van nederland met de stemlokalen erop, kunnen we gaan kijken naar hoe dit verhoud met de bevolkingsdichtheid als eerste voorbeeld. De kaart is opgehaald van het CBS, eerst gaan we kijken hoe de kaart er op zichzelf met dezelfde projectie uitziet."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAOQAAAD4CAYAAAD8Q0ptAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAB9p0lEQVR4nO29ebjd5XHn+an3d+6qfd8XhARiB4NkdowXMMFbbCfGSxzHbrJMnMlk8kzcyXSn+/Gke55Jd097Os2kHRwnmcTEiR3jhcVAjINZjQCJVUIChBYktKAVrfe8b80fVfU7VyBA2+VeoVP2fZCu7jnnd8791VtV3/rWtwRQ2ta2tg0JS4N9AW1rW9ta1nbItrVtCFnbIdvWtiFkbYdsW9uGkLUdsm1tG0LWGOwLOJht3LiRVatWDfZltK1tA2KzZs1i4sSJB/23IemQq1atYsGCBYN9GW1r24DYokWL3vDf2ilr29o2hKztkG1r2xCytkO2rW1DyNoO2ba2DSFrO2Tb2jaErO2QbWvbELK2Q7atbUPI2g7ZtrYNIRuSxIC2te1wbfTUySz8xEfQvj7uu+m77Nmxk9SoaHR00uzrozSbg32Jh2SH5JArV65k586d5JxpNpssWLCAr371q3z0ox+llMLGjRv5whe+wPr16w/psW1r27G2yXPmMGbyJETgok9/gru//tdc+MmPMf30+ezbtYe7v/HX7Hxly2Bf5iGZvtX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JiDWLRUqHyMqllAhFRBUbvBKYqSUUmtdBGLbJIULalFJXOHqdk20RV
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2022-04-12 16:39:06 +02:00
"nl_map_cbs = gpd.read_file(r'../data/shape/Netherlands_shapefile/CBS_vk500_2020_v1.shp')\n",
"nl_map_cbs.to_crs(epsg=4326).plot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Het verwerken van de 500m bij 500m vierkanten kaar duurde heel lang (langer dan een half uur) op de laptop, en is dus niet ideaal tenzij we dit niveau van detail écht nodig hebben. Er is namelijk nog een andere kaart met dezelfde gegevens beschikbaar, maar met een grid van 500 bij 500 meter in plaats van 100 bij 100. Laten we dus kijken hoe vaak een stemlokaal dichterbij dan 100 meter van de dichtstbijzijnde andere is. De makkelijkste manier om dat te doen zonder alle punten met alle andere te vergelijken (heel veel moeite), is een extra dataframe maken als een kopie, alle indexen 1 opschuiven (want alle stemlokalen zijn al in een volgorde van clustering), en dan de laagste afstand bekijken."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-04-12 16:39:06 +02:00
"11165 0.002608\n",
"1021 0.004853\n",
"3196 0.004875\n",
"1923 2.693202\n",
"3757 3.609362\n",
" ... \n",
"7444 253385.654588\n",
"9711 263408.187856\n",
"4392 266925.200994\n",
"9297 271954.076837\n",
"0 NaN\n",
"Name: distance, Length: 11670, dtype: float64\n"
]
}
],
"source": [
"df_shifted = df_geojson_clean.to_crs('EPSG:28992')\n",
"\n",
"df_shifted['geometry (shifted)'] = df_shifted['geometry'].shift(periods=1)\n",
"df_shifted['distance'] = df_shifted['geometry'].distance(df_shifted['geometry (shifted)'])\n",
"df_shifted.sort_values(['distance'], inplace=True, ascending=True)\n",
"zero_mask_booth = df_shifted['distance'] == 0.000000\n",
"df_shifted = df_shifted[~zero_mask_booth]\n",
"print(df_shifted['distance'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We kunnen dus vaststellen dat afstanden van onder de 500 meter waarschijnlijk zeldzaam zijn, en we verder kunnen gaan met de 500 meter bij 500 meter kaart. Laten we nu dus een projectie proberen te maken met de bevolkingsdichtheid erop om het te vergelijken met de stemlokalen en hun posities en clustering."
]
},
{
"cell_type": "code",
"execution_count": 12,
2022-04-12 16:39:06 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['c28992r500', 'INWONER', 'MAN', 'VROUW', 'INW_014', 'INW_1524', 'INW_2544', 'INW_4564', 'INW_65PL', 'P_NL_ACHTG', 'P_WE_MIG_A', 'P_NW_MIG_A', 'AANTAL_HH', 'TOTHH_EENP', 'TOTHH_MPZK', 'HH_EENOUD', 'HH_TWEEOUD', 'GEM_HH_GR', 'WONING', 'WONVOOR45', 'WON_4564', 'WON_6574', 'WON_7584', 'WON_8594', 'WON_9504', 'WON_0514', 'WON_1524', 'WON_MRGEZ', 'P_KOOPWON', 'P_HUURWON', 'WON_HCORP', 'WON_NBEW', 'WOZWONING', 'UITKMINAOW', 'OAD', 'STED', 'geometry']\n"
]
2022-04-12 16:39:06 +02:00
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>c28992r500</th>\n",
" <th>INWONER</th>\n",
" <th>geometry</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>267</th>\n",
" <td>E2050N6110</td>\n",
" <td>5</td>\n",
" <td>POLYGON ((205000.000 611500.000, 205500.000 61...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>269</th>\n",
" <td>E2060N6110</td>\n",
" <td>15</td>\n",
" <td>POLYGON ((206000.000 611500.000, 206500.000 61...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>292</th>\n",
" <td>E2055N6105</td>\n",
" <td>20</td>\n",
" <td>POLYGON ((205500.000 611000.000, 206000.000 61...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>293</th>\n",
" <td>E2060N6105</td>\n",
" <td>185</td>\n",
" <td>POLYGON ((206000.000 611000.000, 206500.000 61...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>294</th>\n",
" <td>E2065N6105</td>\n",
" <td>340</td>\n",
" <td>POLYGON ((206500.000 611000.000, 207000.000 61...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151071</th>\n",
" <td>E1970N3075</td>\n",
" <td>10</td>\n",
" <td>POLYGON ((197000.000 308000.000, 197500.000 30...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151073</th>\n",
" <td>E1980N3075</td>\n",
" <td>90</td>\n",
" <td>POLYGON ((198000.000 308000.000, 198500.000 30...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151074</th>\n",
" <td>E1985N3075</td>\n",
" <td>15</td>\n",
" <td>POLYGON ((198500.000 308000.000, 199000.000 30...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151100</th>\n",
" <td>E1980N3070</td>\n",
" <td>5</td>\n",
" <td>POLYGON ((198000.000 307500.000, 198500.000 30...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>151106</th>\n",
" <td>E1920N3065</td>\n",
" <td>20</td>\n",
" <td>POLYGON ((192000.000 307000.000, 192500.000 30...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>70656 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" c28992r500 INWONER geometry\n",
"267 E2050N6110 5 POLYGON ((205000.000 611500.000, 205500.000 61...\n",
"269 E2060N6110 15 POLYGON ((206000.000 611500.000, 206500.000 61...\n",
"292 E2055N6105 20 POLYGON ((205500.000 611000.000, 206000.000 61...\n",
"293 E2060N6105 185 POLYGON ((206000.000 611000.000, 206500.000 61...\n",
"294 E2065N6105 340 POLYGON ((206500.000 611000.000, 207000.000 61...\n",
"... ... ... ...\n",
"151071 E1970N3075 10 POLYGON ((197000.000 308000.000, 197500.000 30...\n",
"151073 E1980N3075 90 POLYGON ((198000.000 308000.000, 198500.000 30...\n",
"151074 E1985N3075 15 POLYGON ((198500.000 308000.000, 199000.000 30...\n",
"151100 E1980N3070 5 POLYGON ((198000.000 307500.000, 198500.000 30...\n",
"151106 E1920N3065 20 POLYGON ((192000.000 307000.000, 192500.000 30...\n",
"\n",
"[70656 rows x 3 columns]"
]
},
"execution_count": 12,
2022-04-12 16:39:06 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2022-04-12 16:39:06 +02:00
"print(list(nl_map_cbs))\n",
"nl_map_dst = nl_map_cbs.drop(columns=['MAN', 'VROUW', 'INW_014', 'INW_1524', 'INW_2544', 'INW_4564', 'INW_65PL', 'P_NL_ACHTG', 'P_WE_MIG_A', 'P_NW_MIG_A', 'AANTAL_HH', 'TOTHH_EENP', 'TOTHH_MPZK', 'HH_EENOUD', 'HH_TWEEOUD', 'GEM_HH_GR', 'WONING', 'WONVOOR45', 'WON_4564', 'WON_6574', 'WON_7584', 'WON_8594', 'WON_9504', 'WON_0514', 'WON_1524', 'WON_MRGEZ', 'P_KOOPWON', 'P_HUURWON', 'WON_HCORP', 'WON_NBEW', 'WOZWONING', 'UITKMINAOW', 'OAD', 'STED'])\n",
"zero_mask_pop = nl_map_dst['INWONER'] == -99997\n",
"nl_map_dst = nl_map_dst[~zero_mask_pop]\n",
"nl_map_dst"
]
},
{
"cell_type": "code",
"execution_count": 13,
2022-04-12 16:39:06 +02:00
"metadata": {},
"outputs": [],
"source": [
"import folium\n",
"from folium import plugins\n",
"\n",
"map = folium.Map(location = [52.155, 5.3875], zoom_start = 9, tiles=\"cartodbdark_matter\", prefer_canvas=True)\n",
"\n",
"nl_map_dst.to_crs(epsg=4326)\n",
"#Make sure the index is a string so folium can read it correctly as a key.\n",
"nl_map_dst['c28992r500'] = nl_map_dst['c28992r500'].apply(lambda x: str(x))\n",
"\n",
"folium.Choropleth(\n",
" geo_data = nl_map_dst,\n",
" name=\"Bevolkingsdichtheid\",\n",
" data = nl_map_dst,\n",
" columns = [\"c28992r500\", \"INWONER\"],\n",
" key_on = 'feature.properties.c28992r500',\n",
" fill_color = 'RdPu',\n",
" nan_fill_color= 'white',\n",
" fill_opacity = 0.7,\n",
" nan_fill_opacity = 0.7,\n",
" line_opacity = 0,\n",
" legend_name = 'Bevolkingsdichtheid',\n",
" smooth_factor = 1.0,\n",
" show=False\n",
").add_to(map)\n",
"\n",
"# Renders the map to an HTML file and displays it in an embed.\n",
"def embed_map(m):\n",
" #from IPython.display import IFrame\n",
" m.save('index.html')\n",
" #return IFrame('index.html', width='100%', height='750px')"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
2022-04-12 16:39:06 +02:00
"source": [
"df_geojson_clean_hmp = [[point.xy[1][0], point.xy[0][0]] for point in df_geojson_clean.geometry]\n",
"\n",
"plugins.HeatMap(df_geojson_clean_hmp, name=\"Stemlokalen Heatmap\").add_to(map)\n",
"\n",
"folium.LayerControl().add_to(map)\n",
"\n",
"\n",
"\n",
"embed_map(map)\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We kunnen zien dat er gemeente zijn die geen stemlokalen hebben, dit klopt. [In de verkiezingen van 2022 hebben 12 gemeentes niet meegedaan](https://nl.wikipedia.org/wiki/Nederlandse_gemeenteraadsverkiezingen_2022). Er zijn dus in totaal 333 gemeentes met stemlokalen. We willen de bevolkingsdichtheiddata van de gemeentes die niet meededen dus weggooien, hiervoor moeten we eerst kijken welke alleen binnen de gemeentes vallen die we niet willen houden."
]
},
2022-04-12 16:39:06 +02:00
{
"cell_type": "code",
"execution_count": 39,
2022-04-12 16:39:06 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 Gemeenteraad Aa en Hunze 2022\n",
"1 Gemeenteraad Aa en Hunze 2022\n",
"2 Gemeenteraad Aa en Hunze 2022\n",
"3 Gemeenteraad Aa en Hunze 2022\n",
"4 Gemeenteraad Aa en Hunze 2022\n",
" ... \n",
"12591 Gemeenteraad 's-Hertogenbosch 2022\n",
"12592 Gemeenteraad 's-Hertogenbosch 2022\n",
"12593 Gemeenteraad 's-Hertogenbosch 2022\n",
"12594 Gemeenteraad 's-Hertogenbosch 2022\n",
"12595 Gemeenteraad 's-Hertogenbosch 2022\n",
"Name: electionName, Length: 12596, dtype: object\n",
"0 Aa en Hunze\n",
"27 Aalsmeer\n",
"46 Aalten\n",
"74 Achtkarspelen\n",
"95 Alblasserdam\n",
" ... \n",
"11976 Zwartewaterland\n",
"11997 Zwijndrecht\n",
"12031 Zwolle\n",
"12122 's-Gravenhage\n",
"12495 's-Hertogenbosch\n",
"Name: electionName, Length: 333, dtype: object\n"
2022-04-12 16:39:06 +02:00
]
}
],
2022-03-29 17:09:52 +02:00
"source": [
"print(df_geojson['electionName'])\n",
"\n",
"#get all municipalities that are in the election\n",
"gemeentes = df_geojson['electionName'].str.slice(13, -5).drop_duplicates()\n",
"print(gemeentes)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Shape of clean: (333, 38)\n",
"Shape of election: (330, 38)\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>GM_CODE</th>\n",
" <th>GM_NAAM</th>\n",
" <th>H2O</th>\n",
" <th>OAD</th>\n",
" <th>STED</th>\n",
" <th>BEV_DICHTH</th>\n",
" <th>AANT_INW</th>\n",
" <th>AANT_MAN</th>\n",
" <th>AANT_VROUW</th>\n",
" <th>P_00_14_JR</th>\n",
" <th>...</th>\n",
" <th>P_TURKIJE</th>\n",
" <th>P_OVER_NW</th>\n",
" <th>OPP_TOT</th>\n",
" <th>OPP_LAND</th>\n",
" <th>OPP_WATER</th>\n",
" <th>JRSTATCODE</th>\n",
" <th>JAAR</th>\n",
" <th>Shape_Leng</th>\n",
" <th>Shape_Area</th>\n",
" <th>geometry</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>113</th>\n",
" <td>GM0164</td>\n",
" <td>Hengelo</td>\n",
" <td>NEE</td>\n",
" <td>1845</td>\n",
" <td>2</td>\n",
" <td>1332</td>\n",
" <td>81049</td>\n",
" <td>40776</td>\n",
" <td>40273</td>\n",
" <td>15</td>\n",
" <td>...</td>\n",
" <td>6</td>\n",
" <td>7</td>\n",
" <td>6183</td>\n",
" <td>6084</td>\n",
" <td>99</td>\n",
" <td>2021GM0164</td>\n",
" <td>2021</td>\n",
" <td>47510.255914</td>\n",
" <td>6.183056e+07</td>\n",
" <td>POLYGON ((251978.591 481220.258, 251979.382 48...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>191</th>\n",
" <td>GM0373</td>\n",
" <td>Bergen (NH.)</td>\n",
" <td>NEE</td>\n",
" <td>819</td>\n",
" <td>4</td>\n",
" <td>300</td>\n",
" <td>29715</td>\n",
" <td>14317</td>\n",
" <td>15398</td>\n",
" <td>12</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>12023</td>\n",
" <td>9896</td>\n",
" <td>2127</td>\n",
" <td>2021GM0373</td>\n",
" <td>2021</td>\n",
" <td>57488.474563</td>\n",
" <td>9.987418e+07</td>\n",
" <td>POLYGON ((105976.650 529056.951, 106002.347 52...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>328</th>\n",
" <td>GM0893</td>\n",
" <td>Bergen (L.)</td>\n",
" <td>NEE</td>\n",
" <td>318</td>\n",
" <td>5</td>\n",
" <td>127</td>\n",
" <td>13108</td>\n",
" <td>6568</td>\n",
" <td>6540</td>\n",
" <td>13</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>10850</td>\n",
" <td>10324</td>\n",
" <td>525</td>\n",
" <td>2021GM0893</td>\n",
" <td>2021</td>\n",
" <td>61497.563571</td>\n",
" <td>1.084951e+08</td>\n",
" <td>POLYGON ((199768.270 409749.960, 199758.060 40...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>3 rows × 38 columns</p>\n",
"</div>"
],
"text/plain": [
" GM_CODE GM_NAAM H2O OAD STED BEV_DICHTH AANT_INW AANT_MAN \\\n",
"113 GM0164 Hengelo NEE 1845 2 1332 81049 40776 \n",
"191 GM0373 Bergen (NH.) NEE 819 4 300 29715 14317 \n",
"328 GM0893 Bergen (L.) NEE 318 5 127 13108 6568 \n",
"\n",
" AANT_VROUW P_00_14_JR ... P_TURKIJE P_OVER_NW OPP_TOT OPP_LAND \\\n",
"113 40273 15 ... 6 7 6183 6084 \n",
"191 15398 12 ... 0 3 12023 9896 \n",
"328 6540 13 ... 0 3 10850 10324 \n",
"\n",
" OPP_WATER JRSTATCODE JAAR Shape_Leng Shape_Area \\\n",
"113 99 2021GM0164 2021 47510.255914 6.183056e+07 \n",
"191 2127 2021GM0373 2021 57488.474563 9.987418e+07 \n",
"328 525 2021GM0893 2021 61497.563571 1.084951e+08 \n",
"\n",
" geometry \n",
"113 POLYGON ((251978.591 481220.258, 251979.382 48... \n",
"191 POLYGON ((105976.650 529056.951, 106002.347 52... \n",
"328 POLYGON ((199768.270 409749.960, 199758.060 40... \n",
"\n",
"[3 rows x 38 columns]"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#First let's remove the municipalities that don't have an Election from the municipality map\n",
"remove_lst = [\"Boxtel\", \"Eemsdelta\", \"Oisterwijk\", \"Vught\", \"Heerhugowaard\", \"Langedijk\", \"Boxmeer\", \"Cuijk\", \"Sint Anthonis\", \"Mill en Sint Hubert\", \"Grave\", \"Landerd\", \"Uden\", \"Brielle\", \"Hellevoetsluis\", \"Westvoorne\", \"Purmerend\", \"Beemster\", \"Weesp\"]\n",
"\n",
"nl_map_clean = nl_map[~nl_map[\"GM_NAAM\"].isin(remove_lst)]\n",
"nl_map_clean = nl_map_clean.query(\"H2O != 'JA'\")\n",
"nl_map_clean = nl_map_clean.query(\"GM_NAAM != 'Buitenland'\")\n",
"\n",
"nl_map_election = nl_map[nl_map[\"GM_NAAM\"].isin(gemeentes)]\n",
"nl_map_election = nl_map_election.query(\"H2O != 'JA'\")\n",
"\n",
"print(\"Shape of clean: {}\".format(nl_map_clean.shape))\n",
"print(\"Shape of election: {}\".format(nl_map_election.shape))\n",
"\n",
"diff = pd.concat([nl_map_election, nl_map_clean]).drop_duplicates(keep=False)\n",
"diff"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Nu we dezelfde lijst hebben van gemeentes die in de verkiezingen meededen kunnen we verder."
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:>"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAt4AAANOCAYAAAAmhQuoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOydeXxcdbn/32e2TPZ9T5q9aZN0SZOwlkIRChQRFPWKiOKCoqB471U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FxcdTU1GC323n99dfPmF4TVVVV3H777ZSWljIwMEBPTw8TExP85je/YefOnZr75efn8/bbb9PU1ERraytVVVXYkVTF99TIKPc/+ghOp5O//e1vIpItEESAEN4CgUAgOK246qqruOuuu0hMTATgnXfe4Re/+AVvvvkmLpdrwcZlNptJS0sjOTmZxMRE4uPjiY+PJzY2lvj4eOLi4rDb7ciyzNjYGJOTk5jNZrq6uvjXv/4V9vhnnXUWDz30EHa7nddee43//M//xOPxYLfbKSws1N131apV/OpXv2JycpIvfvGLXhOFc+polR14JMm33fTkJE/f/yDbnt+E2WwmJSVFCG+BIAKE8BYIBALBaYHZbObLX/4y119/fcDrZ511FmeddRbj4+Ns2bKFtrY2hoeH6e/vZ//+/fT19UWdEqF0crTZbCQmJpKcnEx6ejpZWVlkZmYG/JeWlobJZIrqPD//+c91uznm5+fzyCOP8NZbb3H//ffT39/ve89sNrNv3z7d4+fk5PD0008D3lqtm266ie985zv8rekdLvjE9aTmZDN0pI/nH36cbc9vArxpJqKN++wxm83k5uayZMkSlixZQmFhIYW
"text/plain": [
"<Figure size 1080x1080 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(figsize = (15,15))\n",
"nl_map_clean.to_crs(epsg=4326).plot(ax=ax, color='lightgrey')\n",
"df_geojson_clean.plot(ax=ax)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>c28992r500</th>\n",
" <th>INWONER</th>\n",
" <th>geometry</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>267</th>\n",
" <td>E2050N6110</td>\n",
" <td>5</td>\n",
" <td>POINT (205250.000 611250.000)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>269</th>\n",
" <td>E2060N6110</td>\n",
" <td>15</td>\n",
" <td>POINT (206250.000 611250.000)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>292</th>\n",
" <td>E2055N6105</td>\n",
" <td>20</td>\n",
" <td>POINT (205750.000 610750.000)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>293</th>\n",
" <td>E2060N6105</td>\n",
" <td>185</td>\n",
" <td>POINT (206250.000 610750.000)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>294</th>\n",
" <td>E2065N6105</td>\n",
" <td>340</td>\n",
" <td>POINT (206750.000 610750.000)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" c28992r500 INWONER geometry\n",
"267 E2050N6110 5 POINT (205250.000 611250.000)\n",
"269 E2060N6110 15 POINT (206250.000 611250.000)\n",
"292 E2055N6105 20 POINT (205750.000 610750.000)\n",
"293 E2060N6105 185 POINT (206250.000 610750.000)\n",
"294 E2065N6105 340 POINT (206750.000 610750.000)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nl_map_dst_points = nl_map_dst\n",
"nl_map_dst_points['geometry'] = nl_map_dst_points['geometry'].centroid\n",
"nl_map_dst_points.head()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>c28992r500</th>\n",
" <th>INWONER</th>\n",
" <th>geometry</th>\n",
" <th>Stembureau</th>\n",
" <th>Adres</th>\n",
" <th>Locatie</th>\n",
" <th>description</th>\n",
" <th>Geldige stemmen</th>\n",
" <th>Opgeroepen</th>\n",
" <th>Ongeldig</th>\n",
" <th>...</th>\n",
" <th>Nationale Bond tegen Overheidszaken - DH</th>\n",
" <th>Haags Belang</th>\n",
" <th>INL Den Haag</th>\n",
" <th>Rosmalens Belang</th>\n",
" <th>De Bossche Groenen</th>\n",
" <th>\"Leefbaar 's-Hertogenbosch\" Paul Kagie</th>\n",
" <th>RAADSGROEPERING ''BOSCH-BELANG''</th>\n",
" <th>gewoon ge-DREVEN</th>\n",
" <th>VOOR Den Bosch Joep Gersjes</th>\n",
" <th>dist</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>E2050N6110</td>\n",
" <td>5</td>\n",
" <td>POINT (205250.000 611250.000)</td>\n",
" <td>1</td>\n",
" <td>9166LX</td>\n",
" <td>SB1</td>\n",
" <td>Stembureau Gemeentehuis (postcode: 9166 LX)</td>\n",
" <td>655</td>\n",
" <td>827</td>\n",
" <td>4</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1331.950309</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>E2060N6110</td>\n",
" <td>15</td>\n",
" <td>POINT (206250.000 611250.000)</td>\n",
" <td>1</td>\n",
" <td>9166LX</td>\n",
" <td>SB1</td>\n",
" <td>Stembureau Gemeentehuis (postcode: 9166 LX)</td>\n",
" <td>655</td>\n",
" <td>827</td>\n",
" <td>4</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>688.536284</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>E2055N6105</td>\n",
" <td>20</td>\n",
" <td>POINT (205750.000 610750.000)</td>\n",
" <td>1</td>\n",
" <td>9166LX</td>\n",
" <td>SB1</td>\n",
" <td>Stembureau Gemeentehuis (postcode: 9166 LX)</td>\n",
" <td>655</td>\n",
" <td>827</td>\n",
" <td>4</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>672.375861</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>E2060N6105</td>\n",
" <td>185</td>\n",
" <td>POINT (206250.000 610750.000)</td>\n",
" <td>1</td>\n",
" <td>9166LX</td>\n",
" <td>SB1</td>\n",
" <td>Stembureau Gemeentehuis (postcode: 9166 LX)</td>\n",
" <td>655</td>\n",
" <td>827</td>\n",
" <td>4</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>228.220493</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>E2065N6105</td>\n",
" <td>340</td>\n",
" <td>POINT (206750.000 610750.000)</td>\n",
" <td>1</td>\n",
" <td>9166LX</td>\n",
" <td>SB1</td>\n",
" <td>Stembureau Gemeentehuis (postcode: 9166 LX)</td>\n",
" <td>655</td>\n",
" <td>827</td>\n",
" <td>4</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>389.974214</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 976 columns</p>\n",
"</div>"
],
"text/plain": [
" c28992r500 INWONER geometry Stembureau Adres \\\n",
"0 E2050N6110 5 POINT (205250.000 611250.000) 1 9166LX \n",
"1 E2060N6110 15 POINT (206250.000 611250.000) 1 9166LX \n",
"2 E2055N6105 20 POINT (205750.000 610750.000) 1 9166LX \n",
"3 E2060N6105 185 POINT (206250.000 610750.000) 1 9166LX \n",
"4 E2065N6105 340 POINT (206750.000 610750.000) 1 9166LX \n",
"\n",
" Locatie description Geldige stemmen \\\n",
"0 SB1 Stembureau Gemeentehuis (postcode: 9166 LX) 655 \n",
"1 SB1 Stembureau Gemeentehuis (postcode: 9166 LX) 655 \n",
"2 SB1 Stembureau Gemeentehuis (postcode: 9166 LX) 655 \n",
"3 SB1 Stembureau Gemeentehuis (postcode: 9166 LX) 655 \n",
"4 SB1 Stembureau Gemeentehuis (postcode: 9166 LX) 655 \n",
"\n",
" Opgeroepen Ongeldig ... Nationale Bond tegen Overheidszaken - DH \\\n",
"0 827 4 ... NaN \n",
"1 827 4 ... NaN \n",
"2 827 4 ... NaN \n",
"3 827 4 ... NaN \n",
"4 827 4 ... NaN \n",
"\n",
" Haags Belang INL Den Haag Rosmalens Belang De Bossche Groenen \\\n",
"0 NaN NaN NaN NaN \n",
"1 NaN NaN NaN NaN \n",
"2 NaN NaN NaN NaN \n",
"3 NaN NaN NaN NaN \n",
"4 NaN NaN NaN NaN \n",
"\n",
" \"Leefbaar 's-Hertogenbosch\" Paul Kagie RAADSGROEPERING ''BOSCH-BELANG'' \\\n",
"0 NaN NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 NaN NaN \n",
"\n",
" gewoon ge-DREVEN VOOR Den Bosch Joep Gersjes dist \n",
"0 NaN NaN 1331.950309 \n",
"1 NaN NaN 688.536284 \n",
"2 NaN NaN 672.375861 \n",
"3 NaN NaN 228.220493 \n",
"4 NaN NaN 389.974214 \n",
"\n",
"[5 rows x 976 columns]"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"\n",
"from scipy.spatial import cKDTree\n",
"from shapely.geometry import Point\n",
"#Found on https://gis.stackexchange.com/questions/222315/finding-nearest-point-in-other-geodataframe-using-geopandas\n",
"def ckdnearest(gdA, gdB):\n",
"\n",
" nA = np.array(list(gdA.geometry.apply(lambda x: (x.x, x.y))))\n",
" nB = np.array(list(gdB.geometry.apply(lambda x: (x.x, x.y))))\n",
" btree = cKDTree(nB)\n",
" dist, idx = btree.query(nA, k=1)\n",
" gdB_nearest = gdB.iloc[idx].drop(columns=\"geometry\").reset_index(drop=True)\n",
" gdf = pd.concat(\n",
" [\n",
" gdA.reset_index(drop=True),\n",
" gdB_nearest,\n",
" pd.Series(dist, name='dist')\n",
" ], \n",
" axis=1)\n",
"\n",
" return gdf\n",
"\n",
"#error bar is +- sqrt(250²*2)m ≈ +-353.553390593m\n",
"df_nearest = ckdnearest(nl_map_dst_points.to_crs(epsg=28992), df_geojson_clean.to_crs(epsg=28992))\n",
"df_nearest.head()\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Text(0, 0.5, 'Bevolking')"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA3gAAANZCAYAAABdnpzdAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAl60lEQVR4nO3de7CnB13f8c/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AAADvItgVeVZ2f5Lok39bd79muOQAAAKZY7BLNqromyZOSnF1VB5K8JMm9kqS7r0zyA0kenOSVVZUkh7p7z1LzAAAATLfkXTQvO8725yV53lK/HwAA4ExzutxFEwAAgJMk8AAAAIYQeAAAAEMIPAAAgCEEHgAAwBACDwAAYAiBBwAAMITAAwAAGELgAQAADCHwAAAAhhB4AAAAQwg8AACAIQQeAADAEAIPAABgCIEHAAAwhMADAAAYQuABAAAMIfAAAACGEHgAAABDCDwAAIAhBB4AAMAQAg8AAGAIgQcAADCEwAMAABhC4AEAAAwh8AAAAIYQeAAAAEMIPAAAgCEEHgAAwBACDwAAYAiBBwAAMITAAwAAGELgAQAADCHwAAAAhhB4AAAAQwg8AACAIQQeAADAEAIPAABgCIEHAAAwhMADAAAYQuABAAAMIfAAAACGEHgAAABDCDwAAIAhBB4AAMAQAg8AAGAIgQcAADCEwAMAABhC4AEAAAwh8AAAAIYQeAAAAEMIPAAAgCEEHgAAwBACDwAAYAiBBwAAMITAAwAAGELgAQAADCHwAAAAhhB4AAAAQwg8AACAIQQeAADAEAI
"text/plain": [
"<Figure size 1080x1080 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"\n",
"#TODO: filter out municipalities that don't have an election in 2022\n",
"df_nearest['dist'].plot(kind=\"hist\", weights=df_nearest['INWONER'], figsize=(15,15), density=False).set_ylabel('Bevolking')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Het was mooier geweest als we het konden filteren op alleen stemgerechtigden en niet op de gehele populatiedichtheid, maar het CBS geeft geen data vrij die daarbij helpt. Er is een categorie voor 0-14 jaar oude mensen, maar niet alle minderjarigen of niet stemgerechtigde. Het moet dus maar met totale bevolkingsdichtheid om een idee te krijgen."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" _id Gemeente CBS gemeentecode Nummer stembureau \\\n",
"0 1 Valkenswaard GM0858 1 \n",
"1 2 Valkenswaard GM0858 2 \n",
"2 3 Valkenswaard GM0858 3 \n",
"3 4 Valkenswaard GM0858 4 \n",
"4 5 Valkenswaard GM0858 5 \n",
"... ... ... ... ... \n",
"9236 38711 Putten GM0273 3 \n",
"9237 38712 Putten GM0273 10 \n",
"9238 38713 Putten GM0273 8 \n",
"9239 38714 Putten GM0273 13 \n",
"9240 38715 Putten GM0273 6 \n",
"\n",
" Naam stembureau \\\n",
"0 Zorgcentrum Kempenhof \n",
"1 Buurtgebouw De Horizon \n",
"2 Speeltuin Geenhoven \n",
"3 Ontmoetingscentrum De zoete inval \n",
"4 Gymnastiekzaal 't Gegraaf \n",
"... ... \n",
"9236 Nieuwe Kerk \n",
"9237 Sporthal de Meeuwen \n",
"9238 School de Pelikaan \n",
"9239 De Samaritaan \n",
"9240 Verenigingsgebouw Stenenkamer \n",
"\n",
" Gebruiksdoel van het gebouw \\\n",
"0 gezondheidszorgfunctie \n",
"1 bijeenkomstfunctie \n",
"2 bijeenkomstfunctie \n",
"3 bijeenkomstfunctie \n",
"4 sportfunctie \n",
"... ... \n",
"9236 bijeenkomstfunctie \n",
"9237 sportfunctie \n",
"9238 onderwijsfunctie \n",
"9239 bijeenkomstfunctie,gezondheidszorgfunctie \n",
"9240 bijeenkomstfunctie \n",
"\n",
" Website locatie Wijknaam \\\n",
"0 https://www.valkenhof.nl/ NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 NaN NaN \n",
"... ... ... \n",
"9236 https://www.hervormdputten.nl/ NaN \n",
"9237 https://www.kvdemeeuwen.nl/ NaN \n",
"9238 https://www.pcbdepelikaan.nl/ NaN \n",
"9239 https://www.desamaritaanputten.nl/ NaN \n",
"9240 https://verenigingsgebouwsteenenkamer.jouwweb.nl/ NaN \n",
"\n",
" CBS wijknummer Buurtnaam ... Visuele hulpmiddelen \\\n",
"0 NaN NaN ... leesloep \n",
"1 NaN NaN ... leesloep \n",
"2 NaN NaN ... leesloep \n",
"3 NaN NaN ... leesloep \n",
"4 NaN NaN ... leesloep \n",
"... ... ... ... ... \n",
"9236 NaN NaN ... leesloep \n",
"9237 NaN NaN ... leesloep \n",
"9238 NaN NaN ... leesloep \n",
"9239 NaN NaN ... leesloep \n",
"9240 NaN NaN ... leesloep \n",
"\n",
" Gehandicaptentoilet Kieskring ID Hoofdstembureau Tellocatie \\\n",
"0 ja Valkenswaard Valkenswaard NaN \n",
"1 NaN Valkenswaard Valkenswaard NaN \n",
"2 NaN Valkenswaard Valkenswaard NaN \n",
"3 NaN Valkenswaard Valkenswaard NaN \n",
"4 NaN Valkenswaard Valkenswaard NaN \n",
"... ... ... ... ... \n",
"9236 ja Putten Putten ja \n",
"9237 NaN Putten Putten ja \n",
"9238 NaN Putten Putten ja \n",
"9239 ja Putten Putten ja \n",
"9240 NaN Putten Putten ja \n",
"\n",
" Contactgegevens gemeente Verkiezingswebsite gemeente \\\n",
"0 verkiezingen@valkenswaard.nl http://www.valkenswaard.nl/verkiezingen \n",
"1 verkiezingen@valkenswaard.nl http://www.valkenswaard.nl/verkiezingen \n",
"2 verkiezingen@valkenswaard.nl http://www.valkenswaard.nl/verkiezingen \n",
"3 verkiezingen@valkenswaard.nl http://www.valkenswaard.nl/verkiezingen \n",
"4 verkiezingen@valkenswaard.nl http://www.valkenswaard.nl/verkiezingen \n",
"... ... ... \n",
"9236 verkiezingen@putten.nl http://www.putten.nl \n",
"9237 verkiezingen@putten.nl http://www.putten.nl \n",
"9238 verkiezingen@putten.nl http://www.putten.nl \n",
"9239 verkiezingen@putten.nl http://www.putten.nl \n",
"9240 verkiezingen@putten.nl http://www.putten.nl \n",
"\n",
" Verkiezingen ID \\\n",
"0 NaN NLODSGM0858stembureaus20220316009 \n",
"1 NaN NLODSGM0858stembureaus20220316009 \n",
"2 NaN NLODSGM0858stembureaus20220316009 \n",
"3 NaN NLODSGM0858stembureaus20220316009 \n",
"4 NaN NLODSGM0858stembureaus20220316009 \n",
"... ... ... \n",
"9236 NaN NLODSGM0273stembureaus20220316009 \n",
"9237 NaN NLODSGM0273stembureaus20220316009 \n",
"9238 NaN NLODSGM0273stembureaus20220316009 \n",
"9239 NaN NLODSGM0273stembureaus20220316009 \n",
"9240 NaN NLODSGM0273stembureaus20220316009 \n",
"\n",
" UUID \n",
"0 3a612b2151fa4ab491b9e331355e6258 \n",
"1 9a01d765af0a467ea37f08d92db114ba \n",
"2 fc5869d33fbc4b06be659149fa615f4c \n",
"3 4427cc0b39e040ba8f75c333f19d66f0 \n",
"4 a893bb9add324ce29769f1c39afcc48d \n",
"... ... \n",
"9236 5ce3ef64ced64343b09f03a95d09d275 \n",
"9237 03b7138951f1475b9ca8328ee7365491 \n",
"9238 25eb2c3d547a420094ee2f691e8bd383 \n",
"9239 8bc3926806a74105a593e6a133b1306f \n",
"9240 609fd2e24c5b40b394174a84f7ca91af \n",
"\n",
"[9241 rows x 39 columns]\n"
]
}
],
"source": [
"df_wims = pd.read_csv(r'../data/wims.csv')\n",
"print(df_wims)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0 1 2 3 4 \\\n",
"0 Lijstnummer Aanduiding Volgnummer Naam kandidaat Totaal \n",
"1 Gebiednummer NaN NaN NaN NaN \n",
"2 Postcode NaN NaN NaN NaN \n",
"3 NaN opgeroepenen NaN NaN 194113 \n",
"4 NaN geldige stempas NaN NaN 96830 \n",
".. ... ... ... ... ... \n",
"445 NaN NaN 5 Oetomo, A.D. 38 \n",
"446 NaN NaN 6 Smid, D. 25 \n",
"447 NaN NaN 7 van Welij, P.Z. 10 \n",
"448 16 Blanco (Dokter, T.) NaN NaN 100 \n",
"449 NaN NaN 1 Dokter, T. 100 \n",
"\n",
" 5 \\\n",
"0 GRID Grafisch Museum Groningen \n",
"1 101 \n",
"2 9712 JN \n",
"3 1396 \n",
"4 560 \n",
".. ... \n",
"445 0 \n",
"446 0 \n",
"447 0 \n",
"448 0 \n",
"449 0 \n",
"\n",
" 6 \\\n",
"0 Gemeente Groningen (locatie Kreupelstraat) \n",
"1 102 \n",
"2 9712 HW \n",
"3 1311 \n",
"4 469 \n",
".. ... \n",
"445 0 \n",
"446 0 \n",
"447 0 \n",
"448 0 \n",
"449 0 \n",
"\n",
" 7 8 9 \\\n",
"0 Gemeente Groningen (locatie Kreupelstraat) Der Aa-kerk Der Aa-kerk \n",
"1 103 104 105 \n",
"2 9712 HW 9711 JB 9711 JB \n",
"3 1311 1311 1311 \n",
"4 491 595 607 \n",
".. ... ... ... \n",
"445 0 0 0 \n",
"446 0 0 0 \n",
"447 0 0 0 \n",
"448 0 0 0 \n",
"449 0 0 0 \n",
"\n",
" ... 175 176 177 178 \\\n",
"0 ... MFC 't Vinkhuys De Fontein Trefpunt Beijum Wijkcentrum Het Dok \n",
"1 ... 827 828 829 830 \n",
"2 ... 9743 BJ 9741 EZ 9737 AB 9733 CA \n",
"3 ... 0 0 0 0 \n",
"4 ... 369 503 367 537 \n",
".. ... ... ... ... ... \n",
"445 ... 0 0 0 0 \n",
"446 ... 0 2 0 0 \n",
"447 ... 0 0 0 0 \n",
"448 ... 2 2 1 0 \n",
"449 ... 2 2 1 0 \n",
"\n",
" 179 180 \\\n",
"0 PKN Blister Ten Boer Buurtcentrum Stadspark \n",
"1 831 832 \n",
"2 9791 CP 9727 HW \n",
"3 0 0 \n",
"4 218 283 \n",
".. ... ... \n",
"445 0 0 \n",
"446 0 0 \n",
"447 0 0 \n",
"448 0 2 \n",
"449 0 2 \n",
"\n",
" 181 182 \\\n",
"0 Kerk van J.C. van de H. der Laatste Dagen Maranathakerk \n",
"1 833 834 \n",
"2 9728 AR 9721 PE \n",
"3 0 0 \n",
"4 302 473 \n",
".. ... ... \n",
"445 0 0 \n",
"446 3 0 \n",
"447 0 1 \n",
"448 0 0 \n",
"449 0 0 \n",
"\n",
" 183 184 \n",
"0 Tennispark Vorenkamp (GLTB) Gemeentehuis Haren \n",
"1 835 836 \n",
"2 9722 HJ 9751 AN \n",
"3 0 0 \n",
"4 495 815 \n",
".. ... ... \n",
"445 0 0 \n",
"446 0 0 \n",
"447 0 0 \n",
"448 0 0 \n",
"449 0 0 \n",
"\n",
"[450 rows x 185 columns]\n"
]
}
],
"source": [
"#de eerste vijf rijen zijn meta-data en kunnen we gerust weghalen voor nu \n",
"df_gr_gr = pd.read_csv(r'../data/stemmen/01_Groningen/osv4-3_telling_gr2022_groningen.csv', skiprows=5, header=None, delimiter=';')\n",
"print(df_gr_gr)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"De data is heel gecompliceerd, dus we moeten het bruikbaar maken in pandas. Met hoe de data eruit ziet in een CSV in libre office willen we een constructie maken van de verschillende onderdelen. We hebben de data van de stemlokalen apart al, die kunnen we dus negeren. We willen de data van de lijsten apart hebben. "
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"\n",
"#TODO:mobiele stemlokalen eruit filteren die NIET 0,0 zijn\n",
"#TODO:datastandaard duitse verkiezingen stemlokaalafstand opzoeken"
]
}
],
"metadata": {
"interpreter": {
"hash": "3d1ccb9efb47efc90847d5703ae4e5663eea6663e461c6dfd943b50a653adc65"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9.11"
}
2022-03-29 17:09:40 +02:00
},
"nbformat": 4,
"nbformat_minor": 2
}