aw_aggregate
sums the new estimates produced by aw_calculate
based on the target id. These are then joined with the target data. This is
the fourth step in the interpolation process after aw_weight.
aw_aggregate(.data, target, tid, interVar, newVar)
A given intersected dataset
A sf
object that data should be interpolated to
A unique identification number within target
A variable containing an interpolated value created by aw_calculate
Optional; a new field name to store the interpolated value in. If not specified,
the interVar
argument will be used as the new field name.
A sf
object with the interpolated value added to it.
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
race <- select(ar_stl_race, GEOID, TOTAL_E)
wards <- select(ar_stl_wards, WARD)
wards %>%
aw_intersect(source = race, areaVar = "area") %>%
aw_total(source = race, id = GEOID, areaVar = "area", totalVar = "totalArea",
weight = "sum", type = "extensive") %>%
aw_weight(areaVar = "area", totalVar = "totalArea", areaWeight = "areaWeight") %>%
aw_calculate(value = "TOTAL_E", areaWeight = "areaWeight") -> intersect
aw_aggregate(intersect, target = wards, tid = WARD, interVar = TOTAL_E)
#> Simple feature collection with 28 features and 2 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 265638 ymin: 299436.3 xmax: 278974.9 ymax: 326430.3
#> Projected CRS: NAD_1983_HARN_StatePlane_Missouri_East_FIPS_2401
#> First 10 features:
#> WARD TOTAL_E geometry
#> 1 1 7959.092 POLYGON ((272762.8 317484.8...
#> 2 2 12110.535 POLYGON ((275044.1 320169.6...
#> 3 3 7356.539 POLYGON ((275469.4 315093.9...
#> 4 4 8457.699 POLYGON ((272072.6 315153.2...
#> 5 5 8807.580 POLYGON ((277328.1 312562.2...
#> 6 6 14052.998 POLYGON ((274902.5 310971.6...
#> 7 7 15841.502 POLYGON ((278014.2 310777.7...
#> 8 8 12188.988 POLYGON ((272184.4 308794.1...
#> 9 9 14217.903 POLYGON ((274931.9 307729.1...
#> 10 10 11239.120 POLYGON ((269582.8 308190.9...