Hack the Survey

2017 Australian Marriage Law Postal Survey - Results Map
I had been looking for a good coding project for a while, to try and build some confidence before I attempted a hackathon, when a friend posted a link to a great map based representation of the  Australian Marriage Law Postal Survey results.  It was a nice clean map that provided a mouse-over pop-up of the yes/no percentage for each electorate which I found it really interesting, but I also wanted some more information.  Information on things like the number of voters, the member holding that seat, the party they are from, what suburbs where in each electorate, and maybe even some census data.  Thus the project was formed.

As always, the 80:20 rule was proved true when I got the map up with the basic info the following day, but being a perfectionist (with a small child and a few other project on the go), it has taken me quite a bit longer to show it off but here it is:
2017 Australian Marriage Law Postal Survey - Results Map
(The site is hosted on shinyapps.io so hopefully it doesn't run out of server time)

So I'm actually hoping it isn't finished, there are a number of other thing I would like to continue adding:
  1. More census data sets
  2. Improved mobile/touch device support
  3. Change the layout
  4. Improved loading speed
  5. Plot formatting and grouping to improve readability
but these things can continue to happen slowly over time.

Just very briefly, I know that a lot of people have been hurt or angered by the survey so I hope this isn't seen as taking side or bringing up bad memories, my intention was to build a tool for examining the data and inspiring people to do more with their data.  So along those same lines, if people are commenting, it would be great if you could keep it about the tech, the data and the analysis.  Thanks!

Technical Details

For those who that are here for the technical details and challenges, here's what you need to know...


The site is built with Shiny, a web app language based on R developed by  RStudio which can run R code in the background to generate an html page a browsers can view.  The actual layout code is like a cross between R, html and javascript but it is relatively easy to learn, particularly if you have some experience in R and html.

The map is powered by leaflet, a javascript plugin for R and Shiny which allows you to display map tiles, both hosted from an external wms server (including a number of built in base maps), or rendered from your own spatial data.  Leaflet is really easy to use in Shiny but I ran into a few issues along the way.
  1.  Leaflet can be very slow to load files, particularly complicated polygons.
    1. To get around this I simplified my polygon layers as much as possible (you will see the don't perfectly match up in places).
    2. Even with this the suburb layer was very slow to load so I set up a button to load it separately for those that wanted to use it.
  2. Census data can be hard to wrangle into a useful format for plotting
  3. The help files for Leaflet are not always easy to understand when you don't have a background in coding, like how to read button clicks and switch layers on and off.
  4. There are some limitations in Leaflet that I'm still hoping to overcome.
 I'm hoping to update this article as I progress the site and I also hope to write some help articles on the challenges I found and (hopefully) overcame in building the site.  Let me know if you have any questions or a topic you would like me to start with.


Comments

Popular posts from this blog

Victorian Property Overlay Map

On your bike... to where?

Everyday IoT: Tank Water Levels