interpolate_aw | R Documentation |
Areal-weighted interpolation of polygon data
st_interpolate_aw(x, to, extensive, ...)
## S3 method for class 'sf'
st_interpolate_aw(x, to, extensive, ..., keep_NA = FALSE, na.rm = FALSE)
x |
object of class |
to |
object of class |
extensive |
logical; if TRUE, the attribute variables are assumed to be spatially extensive (like population) and the sum is preserved, otherwise, spatially intensive (like population density) and the mean is preserved. |
... |
ignored |
keep_NA |
logical; if |
na.rm |
logical; if |
if extensive
is TRUE
and na.rm
is set to TRUE
, geometries with NA
are effectively treated as having zero attribute values.
nc = st_read(system.file("shape/nc.shp", package="sf"))
g = st_make_grid(nc, n = c(10, 5))
a1 = st_interpolate_aw(nc["BIR74"], g, extensive = FALSE)
sum(a1$BIR74) / sum(nc$BIR74) # not close to one: property is assumed spatially intensive
a2 = st_interpolate_aw(nc["BIR74"], g, extensive = TRUE)
# verify mass preservation (pycnophylactic) property:
sum(a2$BIR74) / sum(nc$BIR74)
a1$intensive = a1$BIR74
a1$extensive = a2$BIR74
plot(a1[c("intensive", "extensive")], key.pos = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.