points_to_polygon: Map points to polygons

View source: R/points_to_polygon.R

points_to_polygonR Documentation

Map points to polygons

Description

Join a data.frame containing coordinates (longitude and latitude) to polygon geometries. Arithmetic operations are then applied to the attributes of the joined coordinates to obtain aggregated values for each polygon.

Usage

points_to_polygon(sf_map, df, oper, crs = 4326, outside_print = FALSE)

Arguments

sf_map

object of class sf representing the polygon geometries.

df

data.frame containing coordinates (column names should be 'lon' and 'lat')

oper

arithmetic operation to be applied on the polygon level.

crs

coordinate reference system (default is 4326).

outside_print

logical indicating whether to print points that are not within a polygon (default is FALSE).

Value

An object of class sf

Author(s)

Martin Haringa

Examples

points_to_polygon(nl_postcode2, insurance, sum(amount, na.rm = TRUE))
## Not run: 
shp_read <- sf::st_read("~/path/to/file.shp")
points_to_polygon(shp_read, insurance, sum(amount, na.rm = TRUE))

## End(Not run)


spatialrisk documentation built on June 8, 2025, 9:40 p.m.