gw_aggregate aggregates points from a given sf object to one of six possible geographies: census block group and tract, precinct and ward, neighborhood, and city.

gw_aggregate(.data, to, sf = TRUE, replace_na = TRUE,
  keep_na = FALSE)

Arguments

.data

A sf object

to

The string name of an areal unit to aggregate to: "block group", "tract", "precinct", "ward", "neighborhood", or "city".

sf

A logical scalar; if TRUE, returns an sf object. Otherwise returns a tibble.

replace_na

A logical scalar; if TRUE, areal units that do not have any points enclosed in them with be given a value of 0. If FALSE, they will be given a value of NA.

keep_na

A logical scalar; if TRUE, a row with count of points that could not be joined to the areal unit will be returned. This occurs when points fall outside of all given features. If FALSE, no count of missing points is returned. This argument only returns an NA row if sf = FALSE.

Value

gw_aggregate returns a table or simple features object with the requested data.