Learn R Programming

lawn (version 0.1.7)

lawn_aggregate: Calculate a series of aggregations for a set of points within polygons

Description

Calculates a series of aggregations for a set of points within a set of polygons. Sum, average, count, min, max, deviation supported

Usage

lawn_aggregate(polys, pts, agg = list(c("count", "", "num_of_pts")), lint = FALSE)

Arguments

polys
data-Polygon defining area to aggregate.
pts
data-Point with values to aggregate.
agg
Aggregation object. For more information, see details.
lint
(logical) Lint or not. Uses geojsonhint. Takes up increasing time as the object to get linted increases in size, so probably use by default for small objects, but not for large if you know they are good geojson objects. Default: FALSE

Value

data-FeatureCollection of polygons with properties listed based on outField values in aggregations

Details

Provides a statistical summary of values from points that are within a polygon. The agg parameter must be a list of vector(s), that contain three values: aggregation, inField, and outField. Aggregation may be a string of one of the following: sum, average, count, min, max, or deviation. The inField is the name of the field on pts on which you wish to perfrom the aggregation and outField is the name of the field on the ouput polygon FeatureCollection that will store the resultant value.

See Also

Other aggregations: lawn_average, lawn_count, lawn_deviation, lawn_max, lawn_median, lawn_min, lawn_sum, lawn_variance

Examples

Run this code
ex_polys <- lawn_data$polygons_aggregate
ex_pts <- lawn_data$points_aggregate
ex_agg <- list(c('sum','population','pop_sum'),
            c('average','population','pop_average'),
            c('count','','num_of_pts'))
lawn_aggregate(ex_polys, ex_pts, ex_agg)

Run the code above in your browser using DataLab