Counting points within a buffer of a given distance with points with given coordinates
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")
A data frame containing the start points
Column containing the IDs of the startpoints in the data frame startpoints
Column containing the latitudes of the start points in the data frame startpoints
Column containing the longitudes of the start points in the data frame startpoints
A data frame containing the points to count
Column containing the IDs of the points to count in the data frame endpoints
Column containing the latitudes of the points to count in the data frame endpoints
Column containing the longitudes of the points to count in the data frame endpoints
Column of an additional variable in the data frame endpoints
to sum
The buffer distance
Logical argument that indicates if the start points should be included or not (default: TRUE
)
Unit of the buffer distance: unit="m"
for meters, unit="km"
for kilometers or unit="miles"
for miles
The function returns a list
containing:
A data.frame
containing two columns: The start point IDs (from
) and the number of counted points in the given buffer distance (count_location
)
A data.frame
containing the corresponding distance matrix wiht
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.
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
# NOT RUN {
citynames <- c("Goettingen", "Karlsruhe", "Freiburg")
lat <- c(51.556307, 49.009603, 47.9874)
lon <- c(9.947375, 8.417004, 7.8945)
citynames <- c("Goettingen", "Karlsruhe", "Freiburg")
cities <- data.frame(citynames, lat, lon)
dist.mat (cities, "citynames", "lat", "lon", cities, "citynames", "lat", "lon")
# Euclidean distance matrix (3 x 3 cities = 9 distances)
dist.buf (cities, "citynames", "lat", "lon", cities, "citynames", "lat", "lon", bufdist = 300000)
# Cities within 300 km
# }
Run the code above in your browser using DataLab