idw_xy {ptools} | R Documentation |
Inverse distance weighted sums
Description
Given a base X/Y dataset, calculates clipped inverse distance weighted sums of points from feature dataset
Usage
idw_xy(base, feat, clip = 1, weight = 1)
Arguments
base |
base dataset (eg gridcells), needs to be SpatialPolygonsDataFrame |
feat |
feature dataset (eg another crime generator), needs to be SpatialPointsDataFrame |
clip |
scaler minimum value for weight, default |
weight |
if 1 (default), does not use weights, else pass in string that is the variable name for weights in |
Details
This generates a inverse distance weighted sum of features within specified distance of the base
centroid.
Weights are clipped to never be below clip
value, which prevents division by 0 (or division by a very small distance number)
Uses loops and calculates all pairwise distances, so can be slow for large base and feature datasets. Consider
aggregating/weighting feature dataset if it is too slow. Useful for quantifying features nearby (Groff, 2014), or for egohoods
(e.g. spatial smoothing of demographic info, Hipp & Boessen, 2013).
Value
A vector of IDW weighted sums
References
Groff, E. R. (2014). Quantifying the exposure of street segments to drinking places nearby. Journal of Quantitative Criminology, 30(3), 527-548.
Hipp, J. R., & Boessen, A. (2013). Egohoods as waves washing across the city: A new measure of “neighborhoods”. Criminology, 51(2), 287-327.
See Also
dist_xy()
for calculating distance to nearest
count_xy()
for counting points inside polygon
kern_xy()
for estimating gaussian density of points for features at base polygon xy coords
bisq_xy()
to estimate bi-square kernel weights of points for features at base polygon xy coords
idw_xy()
to estimate inverse distance weights of points for features at base polygon xy coords
Examples
data(nyc_cafe); data(nyc_bor)
gr_nyc <- prep_grid(nyc_bor,15000)
gr_nyc$idwcafe <- idw_xy(gr_nyc,nyc_cafe)
head(gr_nyc@data)