Create zone group crosswalk for weighting
prepare_zone_groups.RdCreates a crosswalk assigning zones to groups for weighting, using manual specification or clustering. Use to prepare zone group mapping for populationSim.
Arguments
- seed
data.table. Survey seed data.
- targets
data.table. PUMS targets data.
- settings
list. Must include:
zone_groups
- — manual group specification
puma_clustering
- — clustering method and parameters
zone_type
— grouping unit type Additional settings as needed for grouping and clustering
- show_plot
logical. If TRUE, shows plot of zone groups in console.
- replace
logical. If TRUE, replaces cached crosswalk if exists.
Value
data.table with columns:
client_zone_id
— client zone identifier zone_group
— zone group label zone_group_label
— descriptive label for zone group geometry
— geometry column (optional) Additional columns as needed for diagnostics Rows: one per zone. Keys: (client_zone_id).
Details
Uses manual group specification or k-means clustering (optimal K or user-defined).
Handles client zones and PUMA zones as grouping units.
Adds geometry if available and saves output to working directory.
Optionally visualizes grouping in console.
Returns a copy; does not modify by reference.
Settings
zone_groups (direct): Manual group specification. Default from settings.
puma_clustering (direct): Clustering method and parameters. Default from settings.
zone_type (direct): Grouping unit type. Default from settings.
See also
cluster_pumasscripts/weighting/zone_groups.R
Other weighting pipeline:
aggregate_targets(),
calc_day_weights(),
calc_linked_trip_weights(),
calc_person_weights(),
calc_sample_plan_counts(),
calc_tour_weights(),
calc_trip_weights(),
create_ie_adjustment_data(),
create_target_update_table(),
format_income_bins(),
get_day_groups(),
get_income_broad(),
get_income_broad_xwalk(),
update_daypat_seed(),
update_daypat_targets(),
update_income_broad_labels(),
update_rate_report(),
update_targets()
Examples
## Not run:
seed <- data.table(client_zone_id = "Z1")
targets <- data.table(client_zone_id = "Z1")
settings <- list(zone_groups = list(), puma_clustering = list(), zone_type = "client_zones")
prepare_zone_groups(seed, targets, settings)
#> Error in if (!dir.exists(dirname(table_path))) { stop("Parent folder does not exist. Did you run load_settings()?")}: argument is of length zero
## End(Not run)