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 286 features and 6 fields
#> Geometry type: GEOMETRY
#> Dimension:     XY
#> Bounding box:  xmin: 265638 ymin: 299509.9 xmax: 278973 ymax: 326430.3
#> Projected CRS: NAD_1983_HARN_StatePlane_Missouri_East_FIPS_2401
#> First 10 features:
#>          GEOID TOTAL_E WARD         area  totalArea
#> 1  29510106500    2863    1 4.268099e+05  1064032.5
#> 2  29510106700    3168    1 5.942485e+05  1238338.0
#> 3  29510107500    1991    1 6.141786e+05   911677.5
#> 4  29510107600    1958    1 1.074142e+06  1168054.2
#> 5  29510110100    2820    1 5.559584e+01   993793.8
#> 6  29510126900    4462    1 8.896824e+05  4331867.8
#> 7  29510127000    1826    1 1.014709e+03 14697280.1
#> 8  29510108100    3309    1 1.197780e+02  3198604.2
#> 9  29510106400    1986    1 6.861954e+05  1106392.9
#> 10 29510107500    1991    2 1.548859e+01   911677.5
#>                          geometry   areaWeight
#> 1  POLYGON ((270624.5 315101.4... 4.011249e-01
#> 2  POLYGON ((270823.1 314161.8... 4.798758e-01
#> 3  POLYGON ((272693.4 317603.1... 6.736797e-01
#> 4  POLYGON ((271928.5 316159, ... 9.195993e-01
#> 5  POLYGON ((272047.9 314802.1... 5.594303e-05
#> 6  POLYGON ((271678.3 316891, ... 2.053808e-01
#> 7  MULTIPOLYGON (((273486.1 31... 6.904061e-05
#> 8  POLYGON ((272743.5 317521.7... 3.744694e-05
#> 9  POLYGON ((271034.9 315851.6... 6.202095e-01
#> 10 POLYGON ((272862.1 317334.3... 1.698911e-05