get_phhs_parallel {pseudohouseholds}R Documentation

Get Pseudo-Households (PHH) for many regions, with optional parallel processing

Description

Calculate PHHs for a set of regions using a given road network.

Usage

get_phhs_parallel(
  regions,
  region_idcol,
  roads,
  region_popcol = NA,
  roads_idcol = NA,
  phh_density = 0.005,
  min_phh_pop = 5,
  min_phhs_per_region = 1,
  min_phh_distance = 25,
  road_buffer_m = 5,
  delta_distance_m = 5,
  skip_unpopulated_regions = TRUE
)

Arguments

regions

simple feature object, sf tibble where each row is a region

region_idcol

character, name of column with unique region id

roads

simple feature object, lines or polylines with road network

region_popcol

character, name of column with region population

roads_idcol

character, name of column containing road unique identifiers

phh_density

numeric, parameter given to sf::st_line_sample()

min_phh_pop

numeric, minimum population per phh

min_phhs_per_region

numeric, minimum phhs per region (it will try its best)

min_phh_distance

numeric, minimum distance between phhs in meters

road_buffer_m

numeric, buffer in meters for intersections

delta_distance_m

numeric, buffer in meters for intersections

skip_unpopulated_regions

boolean, should we skip regions with no population?

Details

Regions will be processed sequentially by default, but parallel processing is supported if users call future::plan() before calling this function.

This function is a wrapper around get_phhs_single(), and parameters are passed on to it.

Value

a simple feature object with one row per phh in the region

Examples

 # Create PHHs for the first 2 dissemination blocks in Ottawa, Ontario, without
 # using any parallel processing
 library(sf)
 library(pseudohouseholds)
 phhs <- get_phhs_parallel(region = ottawa_db_shp[1:2,], region_idcol = "DBUID",
 region_popcol = "dbpop2021", roads = ottawa_roads_shp, roads_idcol = "NGD_UID")


 # Create PHHs for the first 5 dissemination blocks in Ottawa, Ontario, using
 # parallel processing (consult documentation for the package future for details
 # about parallel processing).
 
 library(future)
 future::plan(future::multisession)
 phhs <- get_phhs_parallel(region = ottawa_db_shp[1:5,], region_idcol = "DBUID",
  region_popcol = "dbpop2021", roads = ottawa_roads_shp, roads_idcol = "NGD_UID")

 # Shut down parallel workers
 future::plan(future::sequential)



[Package pseudohouseholds version 0.1.1 Index]