Resources for Making Sri Lankan Polling Division Shapefiles by Merging

The case study

In last week’s post, we used open source shapefiles and folium base maps to create choropleth maps. But this is not always possible. In my work, I found open source shapefiles for Sri Lanka’s provinces, districts, and administrative divisions, but not the country’s polling divisions. Luckily for us, the 323 administrative divisions of Sri Lanka can be merged into around 160 polling divisions, using the map below as the basis. The final shapefiles and intermediate geojson file can be found in my GitHub repository.

Sri_Lankan_parliamentary_election,_2015_-_polling_divisions

Merging

The first step is to download a .kml file of Sri Lanka’s 323 administrative divisions, which we will use to merge and create the shapefile of the country’s polling divisions. Go to http://www.gadm.org/country, and choose the Google Earth .kmz option. On the following screen, download the level 2 data. Use an online converter to convert the .kmz file to a .kml file.

Screenshot 2017-07-26 16.12.58

Next, go to geojson.io. Click “Open” on the left top corner, and select your file. After opening your file, geojson.io will plot the shapefile for you. Go to the right side of the screen, and click on “Table.”

Navigate back to the map and click on any shape on the map. A mini table will pop up, as the image below shows. Click on “Add row”. In the new row, type “polling_division” for the header, and the number corresponding to that polling division in the image above. This creates a new column in the right-hand-side table, called “polling_division”. Fill in this column for all 323 administrative divisions.

Screenshot 2017-07-24 11.21.14

Worth mentioning is that this process is made easier if you load a .kml file for the districts on top or below the administrative division file. This makes it easier to distinguish the divisions and not get mixed up, since you’ll be doing one block of land at a time.

After you are done with filling in the “polling_division” column, double check to make sure that all admin divisions with the same polling division number are contiguous. Polling division 96, for instance, shouldn’t appear both in Batticaloa and Colombo.

After double checking for contiguity, click “Save” on the top left and save the file as a GeoJSon file (also in my GitHub repository).

Dissolve

Go to mapshaper.org and select the GeoJSon file you just saved. Go to the top right corner and click “Console”. Click on the “i” below the top bar — when you hover over each region, you can see the information pertaining to that administrative division.

In the console on your left, type “dissolve polling_division”. The contiguous admin divisions you specified earlier as belonging to the same polling division will be merged into a single feature.  In the map below, the tiny blue lines are the original admin divisions, and the black lines demarcate the polling divisions.

Screenshot 2017-07-24 11.23.39

From this shapefile, we can see patterns of SLA deaths and electoral turnout, which is available by polling divisions. We can see that, unsurprisingly, regions with greater violence saw lower electoral turnout.

Document1

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s