Learn R Programming

spNetwork (version 0.2.1)

aggregate_points: Events aggregation

Description

Function to aggregate points within a radius.

Usage

aggregate_points(points, maxdist, weight = "weight")

Arguments

points

The SpatialPointsDataFrame to contract (must have a weight column)

maxdist

The distance to use

weight

The name of the column to use as weight (default is "weight"). The values of the aggregated points for this column will be summed. For all the other columns, only the first value is retained.

Value

A new SpatialPointsDataFrame

Details

This function can be used to aggregate points within a radius. This is done by iterating over the features. For each feature, all the features in the radius are found and merged (mean of coordinates). This process is repeated until no more modification is applied.

Examples

Run this code
# NOT RUN {
eventsgpkg <- system.file("extdata", "events.gpkg", package = "spNetwork", mustWork = TRUE)
bike_accidents <- rgdal::readOGR(eventsgpkg,layer="bike_accidents", verbose=FALSE)
bike_accidents$weight <- 1
agg_points <- aggregate_points(bike_accidents, 5)
# }

Run the code above in your browser using DataLab