Examples for 'sf::interpolate_aw'


Areal-weighted interpolation of polygon data

Aliases: interpolate_aw st_interpolate_aw st_interpolate_aw.sf

Keywords:

### ** Examples

nc = st_read(system.file("shape/nc.shp", package="sf"))
Reading layer `nc' from data source 
  `/usr/local/R/4.2/site-library/sf/shape/nc.shp' using driver `ESRI Shapefile'
Simple feature collection with 100 features and 14 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
Geodetic CRS:  NAD27
g = st_make_grid(nc, n = c(10, 5))
a1 = st_interpolate_aw(nc["BIR74"], g, extensive = FALSE)
Warning in st_interpolate_aw.sf(nc["BIR74"], g, extensive = FALSE):
st_interpolate_aw assumes attributes are constant or uniform over areas of x
sum(a1$BIR74) / sum(nc$BIR74) # not close to one: property is assumed spatially intensive
[1] 0.4026287
a2 = st_interpolate_aw(nc["BIR74"], g, extensive = TRUE)
Warning in st_interpolate_aw.sf(nc["BIR74"], g, extensive = TRUE):
st_interpolate_aw assumes attributes are constant or uniform over areas of x
# verify mass preservation (pycnophylactic) property:
sum(a2$BIR74) / sum(nc$BIR74)
[1] 0.9999998
a1$intensive = a1$BIR74
a1$extensive = a2$BIR74
## No test: 
plot(a1[c("intensive", "extensive")], key.pos = 4)
plot of chunk example-sf-interpolate_aw-1
## End(No test)

[Package sf version 1.0-19 Index]