R/add_distance.R
add_distance.Rd
Find the distance between all sensors based on corridor and direction. Essential for estimating travel time.
add_distance(config, interpolate_missing = TRUE)
data.table, sensor configuration for multiple sensors
logical, default is TRUE
. Whether to interpolate
missing distance values.
The original data.table with additional columns
distance
the distance between the given sensor and the
nearest upstream sensor in miles. Valid for Station
node
types only; all others will appear as NA
.
It is best to call this function on the entire sensor configuration data table;
you can access the table with pull_configuration()
. Non-station node types
will be
Where upstream detector does not exist, or where distance is
beyond 3 miles, interpolate so as not to assume large VMT
merely because vehicles crossed an isolated detector.
If there is no upstream detector, or distance attributed is greater
than 1.5 miles, interpolate with the corridor median.
If, after interpolating with corridor median, distance is still
missing (i.e. NA for entire corridor), or distance attributed is
greater than 3 miles (want a conservative assumption for how
many miles of travel volume at a particular sensor depicts),
interpolate with metro-wide network median.
if (FALSE) {
library(tc.sensors)
config <- pull_configuration()
add_distance(config, interpolate_missing = TRUE)
}