This function reads in the layer to be aggregated (large area) and the file details for the shapefile containing small areas, including the file name, file location, and variable containing population values.
It subsets the small area layer based on boundaries of the large are layer, then calculates the proportion of each small area that falls in each large area based on the area proportion of the small area that falls in each large area. This creates a base layer from which to create population weighted centroids.
importGATweights(area, filein, pathin, popvar = "Pop_tot")
The spatial polygons data frame you want to aggregate.
The filename of the population shapefile.
The path of the population shapefile.
The population variable to use in the population shapefile.
if (interactive()) {
pathin <- paste0(find.package("gatpkg"), "/extdata")
mywtshp <- importGATweights(area = hftown, filein = "hfblockgrp",
pathin = pathin, popvar = "Pop")
}
#> Error: Cannot open "C:/Users/ajstamm/Documents/GitHub/Coding/gatpkg/extdata"; The file doesn't seem to exist.