This function combines multiple observations by summing the numeric variables, assigning one value for the character variables, and replacing the ID value with a unique ID. It returns the resulting single observation.

createGATregion(
  area,
  newreg,
  myidvar,
  nrid,
  pop = NULL,
  IDlist = NULL,
  pwrepeat = FALSE,
  popwt = FALSE
)

Arguments

area

The original shapefile.

newreg

The rows in the data frame (polygons in the shapefile later) that will be joined into a single observation (polygon).

myidvar

A variable of unique string values to identify the observations.

nrid

A string that will be the ID for the merged observation (polygon).

pop

The base population shapefile (if popwt=TRUE).

IDlist

The list to match GAT and old IDs (if popwt=TRUE).

pwrepeat

A boolean denoting whether population weighting (if used) should be recalculated each time two areas are merged (TRUE) or if area centroids should be weighted with area populations (FALSE). If population weighting is not used, this option is ignored.

popwt

A boolean that denotes whether population weighting is being used.

Details

This function can handle more than two observations at a time, but has only been tested with two observations.

Examples

# create dataset with polygons to merge
ids <- c("e", "e", "d", "d", "f", "f", "f", "e", "e", "d", "e",
         "d", "b", "c", "c", "a", "b", "c", "a", "b", "c")
my_merged_obs <-
  createGATregion(
    area = hftown,
    newreg = hftown[ids=="a",],
    myidvar = "ID",
    nrid = "a",
    pop = hfpop,
    IDlist = ids,
    pwrepeat = TRUE,
    popwt = TRUE
  )