pointdensity {pointdensityP} | R Documentation |
Point density function for geospatial data
Description
This function maps a dataset of geospatial points to a regular grid and calculates the density and temporal average of the points.
Usage
pointdensity(df, lat_col, lon_col, date_col = NULL, grid_size, radius)
Arguments
df |
Data frame minimally containing latitude and longitude of spatial point data |
lat_col |
name of column in |
lon_col |
name of column in |
date_col |
name of column in |
grid_size |
distance in kilometers between the grid lines that will support discretization of data and density reference |
radius |
distance in kilometers that represents the local neighborhood where an event adds density |
Details
pointdensity
returns a density count and the temporal average for every point in the original list. The dataframe returned includes four columns: lat, lon, count, and date_avg. The "lat" column is the original latitude data; the "lon" column is the original longitude data; the "count" is the density count of the number of points within a defined radius (the neighborhood); and the date_avg column includes the average date of each point in the neighborhood. Designed specifically for geospatial point processes and originally developed for military applications, this technique applies to any geospatial point process where there is a desire for an explainable measurement of density and maintaining fidelity of the original point locations. Typical spatial density plotting algorithms, such as kernel density estimation, implement some type of smoothing function that often results in a density value that is difficult to interpret. pointdensity
was designed for ease of interpretation. Potential applications include analysis of military events, crime, and real estate transactions. An example follows with the Arigon data using ggmap (recommended) for visualization:
Arigon_density <- pointdensity(df = Arigon, lat_col = "latitude", lon_col = "longitude",
date_col = "date", grid_size = 1, radius = 2)
map_base <- qmap(location="44.12,-120.83", zoom = 7, darken=0.3)
map_base + geom_point(aes(x = lon, y = lat, colour = count), shape = 16, size = 2,
data = Arigon_density) + scale_colour_gradient(low = "green", high = "red")
Here is another example using the crime dataset from ggmap:
H_crime <- pointdensity(df = clean_crime, lat_col = "lat", lon_col = "lon",
grid_size = 1, radius = 4)
map_base <- qmap(location="29.76,-95.42", zoom = 11, darken=0.3)
map_base + geom_point(aes(x = lon, y = lat, colour = count), shape = 16, size = 2,
data = H_crime) + scale_colour_gradient(low = "green", high = "red")
Author(s)
Paul Evangelista paul.evangelista@usma.edu
David Beskow david.beskow@usma.edu
References
Wand, M. P. (1994). Fast Computation of Multivariate Kernel Estimators. Journal of Computational and Graphical Statistics, 3, 433-445.
Examples
Arigon_test <- Arigon[1:1000,]
Arigon_density <- pointdensity(df = Arigon_test, lat_col = "latitude",
lon_col = "longitude", date_col = "date", grid_size = 1, radius = 2)