View source: R/summarise_points_by_polygon.R
| summarise_points_by_polygon | R Documentation |
Spatially joins point data to polygon geometries and summarises a numeric point exposure or value for each reporting area.
summarise_points_by_polygon(
polygons,
points,
value,
fun = sum,
lon = "lon",
lat = "lat",
crs = 4326,
output_col = NULL,
na.rm = TRUE,
outside = c("message", "warning", "ignore"),
repair_geometry = TRUE
)
polygons |
An object of class |
points |
A data.frame containing point coordinates and the value to summarise. |
value |
A string giving the name of the numeric column in |
fun |
A summary function, such as |
lon |
A string with the name of the longitude column in |
lat |
A string with the name of the latitude column in |
crs |
Coordinate reference system of the point coordinates. Default is
|
output_col |
Optional string giving the name of the output column. If
|
na.rm |
Logical. Whether to remove missing values when |
outside |
What to do when points fall outside all polygons:
|
repair_geometry |
Logical. Whether to try |
An sf object equal to polygons with an additional
summary column.
summarise_points_by_polygon(
polygons = nl_postcode2,
points = insurance,
value = "amount",
fun = sum
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.