JacobWeinbren / Israel-Data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Israel-Data

Mapping Israel's Elections 1992-2021

Scripts

These are the scripts required to recreate the project.

Preparation

  1. Clone the repository
git clone https://github.com/JacobWeinbren/Israel-Data/
  1. Create venv and enter to scripts
#Create the venv
python3 -m venv israel_env
#Enter the venv
source israel_env/bin/activate
#Enter scripts
cd scripts
  1. Create folders
python setup.py

Stations

Collects location for all polling stations

  1. Enter Station Scripts
cd stations
  1. The 19th Knesset election is a PDF. Convert it to an xlsx, stored in output/meta.
python 19.py
  1. Reads the data from the station addresses and stores in output/stations.
python process.py
  1. The 19th Knesset election has an incorrect value. This script runs a backup and fixes the error (previously, this was designed to fix more values).
python fix.py
  1. Get a complete list of every polling station and booth and it's respective location, placing it in output/locations.
python positions.py

Geocoding

This is not necessary to the replication of the project. These scripts tabulate the locations of all avaliable station addresses and calculate their distants between Knesset elections.

  1. Enter Station Scripts
cd stations
  1. Geocode every address and store in output/locations
python geocode.py
  1. Calculate the distances between station locations in each Knesset election and store in output/analysis
python analysis.py

You can see the completed version of this analysis on this Google Sheet. The main finding is that there is very little variation of polling station locations between Knesset elections.

Helper Scripts

  • geocode_arcgis.py and geocode_google.py take key.py (in .gitignore) and run a process function. The function takes the address and returns a latitude and longitude in Israel.
    • geocode_test.py tests the google script works
  • variables.py includes variables common the geocoding scripts

Map creation

The scripts create a geojson hexagonal map, containing all knesset election data. This map can be served on a web server.

  1. Create a tessellated geojson file.

  2. Create a new ArcGIS project and load map of Israel, West Bank and Gaza (you can use the one below)

  3. Run Generate Tesselation with the following settings - Shape Hexagon - Extent of Israel Map - Size 5km (squared) - Spatial reference Current Map (Web Coordinates)

  4. Run Features to JSON with WGS_1984 to output/maps/base.geojson.

  5. Now we need to add data to the map

  6. Enter Map Scripts

cd maps
  1. Add stations to on base.geojson to produce output/maps/stations.geojson
python stations.py
  1. Collect election results from all Knesset elections
python politics.py
  1. Apply tallied data to map
python data.py
  1. Afterwards, we need to convert the hexagons to points (to save space)

  2. Run JSON to Features with WGS_1984 on output/maps/stations.geojson

  3. Run Features to Point (calculates centroids)

  4. Run Features to JSON as with WGS_1984to output/maps/points.geojson

  5. Collect election results to produce election data files in elections.

python csv_writer.py

You can find the published map here

Notes

  • Double Envelopes (Military Ballots) are coded seperately, as they have no location data
  • 13th, 16th and 17th Knesset requires dividing by 10 to keep ballot numbers consistent
  • Decimal points suggest multiple booths at one polling station. Though sometimes multiple stations can also be at one address.
  • Default blocs are based on the IDI, the Historic Israeli Elections Project and consideration from myself and those who provided feedback on this project.
  • The 13th Knesset election required some extra transcription of the notes in CBS Series '926', entered on this sheet and saved in 13_Corrected.

Sources

Stations geocoded using ArcGIS, credits provided by Exeter University.

Polling Stations

A small number of polling stations are missing - if you have the addresses to polling stations in the crossed out elections, please let me know.

Knesset Year Polling Stations Station Notes
13th 1992
14th 1996 Knesset
15th 1999
16th 2003
17th 2006 Knesset
18th 2009
19th 2013 Knesset Adobe Converted
20th 2015 Knesset
21st 2019 Knesset Ballot Report
22nd 2019 Knesset Ballot Report
23rd 2020 Knesset Ballot Report
24th 2021 Knesset Ballot Report

Results

Results can generally be found through the most recent Knesset Site.

Knesset Election Year Results Results Notes
13th 1992 Bureau of Statistics This was a request to the ISDC
14th 1996 Knesset
15th 1999 Knesset
16th 2003 Knesset
17th 2006 Knesset
18th 2009 Knesset
19th 2013 Knesset
20th 2015 Knesset
21st 2019 Knesset By Polls
22nd 2019 Knesset By Polls
23nd 2020 Knesset By Polls
24th 2021 Knesset By Polls

Map

Initial map of Israel from Open Source Natural Earth, extracted using Data -> Export Features. Wurman Dots inspired by ArcGIS blog post.

Blocs

I have categorised default blocs for all the Knesset elections in this spreadsheet. This was stored in data/blocs.tsv. This is based on my subjective opinion - feel welcome to offer suggestions or changes.

Thanks

Thanks to the Israeli Election Commision for data and support. And many thanks my relatives in particular Gidi and Michal for helping to retrieve data and explaining how elections worked.

Thank you Hovav Dror at Quantitative and Lior Kaplan at Open Source Consulting for providing location data under CC and much needed advice.

Many thanks to my friends, in particular Chris Terry and T.S. Kovak, for help along the way.

Sources

Hebrew Wikipedia provides the Hebrew symbols for ballots and common English names.

Isael Democracy Institute provided the 12th Knesset Election results (in aggregate).

License

GNU

About


Languages

Language:Python 72.1%Language:HTML 27.9%