I'm intending to analyse Australian census data using googleway to produce heat maps.
My approach has been to use prepared data from googleway melbourne
which contains column SA2_NAME
and join it with the ESRI shape file from the census data after conversion with rgdal (code below). The problem is that joining by SA2_NAME
is not unique for polylines - some SA2 areas are made of multiple 'sub' areas. So it seems this is not a good approach.
A better approach would be to convert the ESRI shape data sa2_shape
below to have polylines in the format of the melbourne
data. How is this done?
Code below produces a 'bridging' data frame to use in joining melbourne
data from googleway
with ABS data which has SA2_MAIN
as the key field - as stated above, the problem with this 'hack' approach is that polylines are not unique by SA2_NAME
library(tidyverse)
library(googleway)
library(rgdal)
shape_path <- "abs_data/sa2_esri_shapefile"
shape_file <- "SA2_2016_AUST"
sa2_shape <- readOGR(shape_path, shape_file)
sa2_df <- data.frame(sa2_shape$SA2_MAIN, sa2_shape$SA2_NAME)
names(sa2_df) <- c("SA2_MAIN", "SA2_NAME")
sa2_df <- sa2_df %>% semi_join(melbourne, by = "SA2_NAME")