-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Sent in email to @Ennazus. Can we consider this in the next feature update for the package, @erika-redding?
I think the most accurate way to calculate a weighted VMT is to follow the same process we use when calculating weighted trip rates. I had actually considered re-writing the hts_prep_triprate function to calculate VMT at one point using the same workflow – you can actually kind of trick hts_prep_triprate to do what I describe below with some creative subsetting, but it's not the prettiest.
I have the Met Council's data open on my computer, so this code below written for their data, but the concept should be the same:
Starting with the trip table:
vmt = trip[, .(
hh_id,
person_id,
day_id,
trip_id,
trip_weight,
distance_miles,
num_travelers,
mode_type
)]
Get the subset of trips made by auto modes, where the number of occupants is known:
vmt = vmt[num_travelers != 995 &
mode_type %in% c(8:9)]
Calculate trip-level vmt:
vmt[, vmt := distance_miles/num_travelers]
Calculate weighted vmt:
vmt[, weighted_vmt = sum(vmt * trip_weight]
Sum weighted VMT for each person-day:
weighted_vmt = vmt[,
.(weighted_vmt_personday = sum(weighted_vmt)),
.(day_id)]
Join weighted VMT to day table:
day_vmt = copy(day)
day_vmt[weighted_vmt,
weighted_vmt_personday := i.weighted_vmt_personday ,
on = .(day_id)]
Set weighted_vmt_personday to 0 where person did not travel by car that day:
day_vmt[is.na(weighted_vmt_personday ), weighted_vmt_personday := 0]
Join to household to get your city center variable,
... your code here
then get your total VMT by city center name:
day_vmt[day_weight > 0,
.(
weighted_vmt = sum(weighted_vmt),
weighted_num_days = sum(day_weight),
weighted_vmt_percap = sum(weighted_vmt) /
sum(day_weight)
),
keyby = 'city_center']