urban_aggregate() transfers numeric variables from polygons, such as
census blocks or tracts, to the cells made by urban_grid(). Counts on
equal-area cells read as densities, which is why the Urban Atlas maps
totals per cell.
Arguments
- x
An
sfobject of polygons.- grid
A lattice made by
urban_grid().xis transformed to its coordinate reference system if the two differ.- cols
Names of the numeric columns of
xto transfer.- type
"extensive"for totals such as population, which are divided among cells and summed."intensive"for rates and averages such as median income, which are averaged within each cell.- method
"area"splits each polygon among the cells it overlaps, in proportion to area."centroid"assigns each polygon whole to the cell that contains a point on its surface. It is faster, and suits polygons much smaller than a cell.
Value
The cells of grid that received data, as an sf object with the
columns of grid and one column for each of cols. The "pitch"
attribute of grid is kept.
See also
geom_urban_disc() to draw the result.
Examples
blocks <- sf::st_make_grid(
sf::st_as_sfc(sf::st_bbox(
c(xmin = 583000, ymin = 4506000, xmax = 584000, ymax = 4507000),
crs = 32618
)),
cellsize = 100
)
blocks <- sf::st_sf(people = seq_along(blocks), geometry = blocks)
grid <- urban_grid(blocks)
urban_aggregate(blocks, grid, "people")
#> Simple feature collection with 16 features and 4 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 583000 ymin: 4506000 xmax: 584000 ymax: 4507000
#> Projected CRS: WGS 84 / UTM zone 18N
#> First 10 features:
#> cell x y people geometry
#> 1 1 583125 4506125 61.25 POLYGON ((583000 4506000, 5...
#> 2 2 583375 4506125 76.25 POLYGON ((583250 4506000, 5...
#> 3 3 583625 4506125 92.50 POLYGON ((583500 4506000, 5...
#> 4 4 583875 4506125 107.50 POLYGON ((583750 4506000, 5...
#> 5 5 583125 4506375 211.25 POLYGON ((583000 4506250, 5...
#> 6 6 583375 4506375 226.25 POLYGON ((583250 4506250, 5...
#> 7 7 583625 4506375 242.50 POLYGON ((583500 4506250, 5...
#> 8 8 583875 4506375 257.50 POLYGON ((583750 4506250, 5...
#> 9 9 583125 4506625 373.75 POLYGON ((583000 4506500, 5...
#> 10 10 583375 4506625 388.75 POLYGON ((583250 4506500, 5...