Learn R Programming

REAT (version 1.2.1)

dist.buf: Counting points in a buffer

Description

Counting points within a buffer of a given distance with points with given coordinates

Usage

dist.buf(startpoints, sp_id, lat_start, lon_start, endpoints, ep_id, lat_end, lon_end, ep_sum = NULL, bufdist = 500, extract_local = TRUE, unit = "m")

Arguments

startpoints
A data frame containing the start points
sp_id
Column containing the IDs of the startpoints in the data frame startpoints
lat_start
Column containing the latitudes of the start points in the data frame startpoints
lon_start
Column containing the longitudes of the start points in the data frame startpoints
endpoints
A data frame containing the points to count
ep_id
Column containing the IDs of the points to count in the data frame endpoints
lat_end
Column containing the latitudes of the points to count in the data frame endpoints
lon_end
Column containing the longitudes of the points to count in the data frame endpoints
ep_sum
Column of an additional variable in the data frame endpoints to sum
bufdist
The buffer distance
extract_local
Logical argument that indicates if the start points should be included or not (default: TRUE)
unit
Unit of the buffer distance: unit="m" for meters, unit="km" for kilometers or unit="miles" for miles

Value

The function returns a data.frame containing 2 columns: The start point IDs (from) and the number of counted points in the given buffer distance (count_location).

Details

The function is based on the idea of a buffer analysis in GIS (Geographic Information System), e.g. to count the points of interest within a given buffer distance.

References

de Lange, N. (2013): “Geoinformatik in Theorie und Praxis”. 3rd edition. Berlin : Springer Spektrum.

Krider, R. E./Putler, R. S. (2013): “Which Birds of a Feather Flock Together? Clustering and Avoidance Patterns of Similar Retail Outlets”. In: Geographical Analysis, 45, 2, p. 123-149

See Also

dist, dist.mat

Examples

Run this code
# Pharmacies in a 500 m buffer:
data(health1)
# Health service locations (physicians and pharmacies)
data(health2)
# 420 regions
health2_city <- health2[health2$city == 1,] 
# only regions in the city of Goettingen (city=1)
pharmacy <- health1[health1$type == "pharm",] 
# Only pharmacies
pharm_city <- dist.buf(health2_city, "region", "lat", "lon", pharmacy, 
"location", "lat", "lon", bufdist = 500)
# Pharmacies in a 500 m buffer from the statistical districts in Goettingen

Run the code above in your browser using DataLab