View source: R/concentration.R
concentration | R Documentation |
Calculates the concentration, which is the sum of all observations within a circle of a certain radius.
concentration(
sub,
full,
value,
lon_sub = lon,
lat_sub = lat,
lon_full = lon,
lat_full = lat,
radius = 200,
display_progress = TRUE
)
sub |
A data.frame of target points for which concentration risk is calculated. Must include at least columns for longitude and latitude. |
full |
A data.frame containing reference points. Must include at least columns for longitude, latitude, and the value of interest to summarize. |
value |
Column name in |
lon_sub |
Column name in |
lat_sub |
Column name in |
lon_full |
Column name in |
lat_full |
Column name in |
radius |
Numeric. Radius of the circle in meters. Must be positive (default: 200). |
display_progress |
Logical. Whether to display a progress bar
( |
This function uses a C++ backend for efficient distance calculations
(Haversine formula). For each point in sub
, it finds all points in
full
within the specified radius and sums their value
.
A data.frame equal to sub
with an additional numeric column
concentration
containing the summed values from full
.
Martin Haringa
# Target points
sub <- data.frame(location = c("p1", "p2"),
lon = c(6.561561, 6.561398),
lat = c(53.21369, 53.21326))
# Reference points with values
full <- data.frame(lon = c(6.5614, 6.5620, 6.5630),
lat = c(53.2132, 53.2140, 53.2150),
amount = c(10, 20, 15))
# Calculate concentration within 100 meters
concentration(sub, full, value = amount, radius = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.