Aggregate SpatialPolygonsDataFrame to new geometry.
sp_aggregate(zones, aggzones, cols = FALSE, FUN = sum,
prop_by_area = ifelse(identical(FUN, mean) == FALSE, TRUE, FALSE),
digits = getOption("digits"))
A spatial object representing origins (and destinations if no separate destinations object is provided) of travel.
A SpatialPolygonsDataFrame containing the new boundaries to aggregate to.
A character vector containing the names of columns on which to apply FUN. By default, all numeric columns are aggregated.
Function to use on aggregation. Default is sum.
Boolean value indicating if the values should be proportionally adjusted based on area. Default is TRUE unless FUN = mean.
The number of digits to use when proportionally adjusting values based on area. Default is the value of getOption("digits").
SpatialPolygonsDataFrame
This function performs aggregation on a SpatialPolygonsDataFrame to a different geometry specified by another SpatialPolygons object.
Other od: dist_google
, od2line
,
od2odf
, od_aggregate_from
,
od_aggregate_to
,
od_aggregate
, od_coords2line
,
od_coords
, od_dist
,
od_id
, od_oneway
,
od_radiation
, od_to_odmatrix
,
odmatrix_to_od
, points2flow
,
points2odf
# NOT RUN {
zones@data$region <- 1
zones@data[c(2, 5), c("region")] <- 2
aggzones <- sp::SpatialPolygonsDataFrame(rgeos::gUnaryUnion(
zones,
id = zones@data$region
), data.frame(region = c(1, 2)))
zones@data$region <- NULL
zones@data$exdata <- 5
library(sp)
sp_aggregate(zones, aggzones)
# }
Run the code above in your browser using DataLab