points_to_polygon: Aggregate attributes of coordinates to area level

Description Usage Arguments Value Author(s) Examples

View source: R/points_to_polygon.R

Description

A data.frame containing coordinates (in terms of longitude and latitude) is joined to the polygon level. Then arithmetic operations on the attributes of the coordinates are applied to obtain aggregated values for each polygon.

Usage

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

Arguments

sf_map

object of class sf

df

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

oper

an arithmetic operation on the polygon level

crs

coordinate reference system: integer with the EPSG code, or character with proj4string

outside_print

print points that are not within a polygon (default is FALSE).

Value

an object of class sf

Author(s)

Martin Haringa

Examples

1
2
3
4
5
6
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 Nov. 10, 2021, 5:09 p.m.