aw_calculate multiplies the given value by the area weight. This is the fourth step in the interpolation process after aw_weight.

aw_calculate(.data, value, areaWeight, newVar)

Arguments

.data

A given intersected dataset

value

A column within source to be interpolated

areaWeight

The name of the variable containing area weight per feature

newVar

Optional; a new field name to store the interpolated value in. If not specified, the value argument will be used as the new field name.

Value

An intersected file of class sf with a new field of interest recalculated with area weight

Examples

library(dplyr) 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") -> intersect aw_calculate(intersect, value = "TOTAL_E", areaWeight = "areaWeight")
#> Simple feature collection with 287 features and 6 fields #> geometry type: GEOMETRY #> dimension: XY #> bbox: xmin: 733361.8 ymin: 4268411 xmax: 746155.7 ymax: 4295504 #> projected CRS: NAD83 / UTM zone 15N #> First 10 features: #> GEOID TOTAL_E WARD area totalArea #> 1 29510106500 1148.4457826 1 4.271176e+05 1064776.2 #> 2 29510106700 1520.2464178 1 5.946820e+05 1239241.5 #> 3 29510107500 1341.3426720 1 6.146361e+05 912325.0 #> 4 29510107600 1829.4388297 1 1.071347e+06 1146634.4 #> 5 29510110100 0.1577461 1 5.563665e+01 994606.5 #> 6 29510109600 3.4643427 1 3.586828e+03 3157835.4 #> 7 29510126900 916.4807234 1 8.903340e+05 4334701.5 #> 8 29510127000 0.1259072 1 1.015451e+03 14726832.5 #> 9 29510106400 1231.7392274 1 6.866924e+05 1107191.4 #> 10 29510108100 0.1233147 1 1.198667e+02 3216478.2 #> geometry areaWeight #> 1 POLYGON ((738110.9 4283989,... 4.011337e-01 #> 2 POLYGON ((738335.2 4283055,... 4.798758e-01 #> 3 POLYGON ((740111.6 4286547,... 6.737030e-01 #> 4 POLYGON ((739386.1 4285082,... 9.343406e-01 #> 5 POLYGON ((739542.5 4283728,... 5.593835e-05 #> 6 POLYGON ((740899.6 4285240,... 1.135850e-03 #> 7 POLYGON ((739115.9 4285807,... 2.053968e-01 #> 8 MULTIPOLYGON (((740936.1 42... 6.895245e-05 #> 9 POLYGON ((738500.9 4284750,... 6.202111e-01 #> 10 POLYGON ((740163.9 4286467,... 3.726645e-05