aw_weight creates an area weight field by dividing the area field by the total area field. This is the third step in the interpolation process after aw_weight.

aw_weight(.data, areaVar, totalVar, areaWeight)

Arguments

.data

A sf object that has been intersected using aw_intersect

areaVar

The name of the variable measuring a feature's area

totalVar

The name of the variable containing total area field by source id

areaWeight

The name of a new area weight field to be calculated

Value

A sf object with the intersected data and new area weight field.

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") -> intersect aw_weight(intersect, areaVar = "area", totalVar = "totalArea", 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 2863 1 4.271176e+05 1064776.2 #> 2 29510106700 3168 1 5.946820e+05 1239241.5 #> 3 29510107500 1991 1 6.146361e+05 912325.0 #> 4 29510107600 1958 1 1.071347e+06 1146634.4 #> 5 29510110100 2820 1 5.563665e+01 994606.5 #> 6 29510109600 3050 1 3.586828e+03 3157835.4 #> 7 29510126900 4462 1 8.903340e+05 4334701.5 #> 8 29510127000 1826 1 1.015451e+03 14726832.5 #> 9 29510106400 1986 1 6.866924e+05 1107191.4 #> 10 29510108100 3309 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