This function is for aggregating OD pairs. It generally decreases the number of rows in an OD dataset, while aiming to keep the amount of travel represented in the data the same.

od_aggregate(od, aggzones = NULL, FUN = sum)

od_group(od, aggzones = NULL, FUN = sum)

Arguments

od

An origin-destination data frame

aggzones

Points within the zones defining the OD data

FUN

The aggregating function to use

Details

An alias for the function is od_group().

Examples

od_aggregated = od_data_df[1:2, c(1, 2, 9)]
aggzones = od::od_data_zones_min
subzones = od_data_zones_small
plot(aggzones$geometry)
plot(subzones$geometry, add = TRUE)

od = od_disaggregate(od_aggregated, aggzones, subzones)
#> Converting polygons to points
#> Warning: st_centroid assumes attributes are constant over geometries
od_agg = od_aggregate(od, aggzones)
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
#> 0 origins with no match in zone ids
#> 0 destinations with no match in zone ids
#>  points not in od data removed.
names(od_agg)[1:(ncol(od_agg) - 1)] = names(od_aggregated)
attr(od_aggregated, "spec") = NULL
identical(sf::st_drop_geometry(od_agg), od_aggregated)
#> [1] TRUE