townsendr interactive map

This week I updated my Townsend Material Deprivation Score project. The update makes townsendr an interactive online map of deprivation that users can simply view in their browser, rather than having to download and run the R code or view only static maps. I think the result is much more intuitive and useful.

Making the map interactive is achieved by using Shiny, a technology for R to make interactive charts and plots. As well as this, the maps are now rendered by leaflet rather than ggplot2. ggplot2 is an awesome technology for making beautiful charts in R, but leaflet is a javascript library designed specifically for plotting interactive maps so rendering the map is now so effortless it felt like cheating.

The data is based on the relevant census tables obtained from Nomis. The shapefiles are obtained from the UK Data Service, but are greatly simplified (even the generalised versions were about 5MB, much too big for interactive use). Both are available under open licenses. For more information see the townsendr web page or the GitHub repository. Pull requests are very welcome.

I’m really happy with the result, which is my first attempt using Shiny and leaflet, but there’s more work to do (when I have time!). Specifically I think the following need addressing:

  • London probably needs removing from the analyses because car ownership and home ownership are low in London even among households that aren’t deprived.
  • The colour scale needs more contrast between high and low deprivation (although this might be corrected by removing London!). I might even create bands that show quantiles of deprivation.
  • The legend needs improving, specifically it should be clearer that darker blue = more deprivation. The z-scores probably aren’t that useful to someone who doesn’t know what they signify.

If you notice anything else, fix it and submit a pull request or file an issue for me to address!