dcount_xy: Count of points within distance of polygon

View source: R/sp_features.R

dcount_xyR Documentation

Count of points within distance of polygon

Description

Given a base X/Y dataset, calculates number of feature points that are within particular distance

Usage

dcount_xy(base, feat, d, weight = 1)

Arguments

base

base dataset (eg gridcells), needs to be SpatialPolygonsDataFrame

feat

feature dataset (eg another crime generator), needs to be SpatialPointsDataFrame

d

scaler distance to count (based on polygon boundary for base, not centroid)

weight

if 1 (default), does not use weights, else pass in string that is the variable name for weights in feat

Details

This generates a count (or weighted count) of features within specified distance of the base polygon border. Both should be projected in the same units. Uses raster::buffer() on feat dataset (which calls rgeos) and sp::over functions.

Value

A vector of counts (or 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.

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$dcafe_8k <- dcount_xy(gr_nyc,nyc_cafe,8000)
head(gr_nyc@data)



ptools documentation built on Feb. 16, 2023, 10:40 p.m.