This is an R Shiny and Leaflet data visualisation of the commuter data from the 2018 NZ Census of Populations and Dwellings; you can see it in action here. It serves as my entry for the 2020 There and Back Again data viz competition. The code for the visualisation itself is in the viz/
folder, however note that it requires the code in process.R
to be run first to produce the .RData
file, along with the separate download of a SA2 shapefile (in WGS projection, and possibly simplified by the code in maps.R
).
Some problems with the code, for future personal reference.
Unfortunately I had to remove the Chatham Islands from the map, despite it being in the dataset! This was because their position on the far side of the 180° meridian causes issues with leaflet maps on WGS projections, while I was unable to get an alternative projection to work.
If you hover the cursor over a region, and then over the sea or a lake, the shiny code is capable of registering that you're not over that same region still. However if you then return to the same region it doesn't recognise that. This seems to be a limitation of how the shiny events stuff works. There might be something I can do with resetting the input$
, but I'll look into it later.