Maps Without Expensive Software

Apr 1, 2018 00:00 · 327 words · 2 minute read

Musical chairs with polling stations

Introduction

Despite living in Hawaii, I finally had experienced the madness that is the 2018 election. While at the polling station, I had saw a handful of people who, after filling out their ballot, learned that they were at the wrong place. Some had mentioned ‘living up the street’ or ‘in the area’. Curious about what I had heard, I went home to map polling precints and stations.

Data

Our generous state of Hawaii’s GIS program has provided machine-ready shapefiles on state polling stations and precints.

Code

The code is quite simple, but renders a map leveraging the Leaflet JavaScript library. This makes it possible for the map to be easily reproducible. See a live demo here

library(data.table)
library(leaflet)
library(sf)
library(randomcoloR)

# data-----#
poll <- st_read('input/polling_places.shp')
poll <- st_transform(poll, 4326)

poll2 <- data.table(poll)
poll2 <- poll2[, .(DP_N = paste0(DP, collapse = ', ')), by=.(Name)]

poll <- merge(poll, poll2, by='Name')

# leaflet-----#
labels <- sprintf(
  "<strong>%s</strong><br/>%s<br/>%s<br/>",
  poll$DP_N, poll$Name, paste(poll$Address, poll$CityZip)) %>% lapply(htmltools::HTML)

precint <- st_read('input/precincts.shp')
precint <- st_transform(precint, 4326)

labels2 <- sprintf("<strong>%s</strong>",
  precint$DP) %>% lapply(htmltools::HTML)

x <- leaflet(precint) %>% 
  addTiles() %>%
  addPolygons(fillOpacity = 0.45,       
              weight = 3,  
              stroke = T,
              fill=T,
              fillColor = distinctColorPalette(length(unique(precint$DP))),
              color = '#FFF',
              popup = labels2) %>%
  addMarkers(data=poll, popup = labels, label = labels)

library(htmlwidgets)
saveWidget(x, file="index.html")

Findings

After reviewing the map, I now understand how easily one can arrive at the wrong polling station. The polling station I visited did not serve the precinct that it resided in. Instead, the station was setup for adjacent precints. The correct polling station for those residents would have been the high school located down the road. This issue, however, was not unique to my neighborhood. In a small community on the east side of Oahu called Hahaione, the polling station for this precinct was located in neighboring Niu Valley. Although Hahaione did have a polling station in the area, it was setup for residents who lived in the next precint over.