Create a tidy data frame, containing volume and occupancy,
for a single date and sensor.
Use pull_sensor_ids() to obtain metro sensor IDs.
pull_sensor(
sensor,
pull_date,
fill_gaps = TRUE,
length_ft_min = NULL,
length_ft_max = NULL,
headway_sec_min = NULL,
headway_sec_max = NULL,
speed_mph_min = NULL,
speed_mph_max = NULL,
district = "metro",
.quiet = TRUE
)character, the sensor ID.
See pull_sensor_ids() to obtain metro sensor IDs.
character, the date of data to pull.
Accepts either "YYYY-MM-DD" or "YYYYMMDD" format.
logical, whether to fill gaps in the time series with NA
values. Default is TRUE
numeric, minimum vehicle length in feet for filtering. Optional. Default is NULL.
numeric, maximum vehicle length in feet for filtering (non-inclusive). Optional. Default is NULL.
numeric, minimum headway in seconds for filtering. Optional. Default is NULL.
numeric, maximum headway in seconds for filtering (non-inclusive). Optional. Default is NULL.
numeric, minimum speed in mph for filtering. Optional. Default is NULL.
numeric, maximum speed in mph for filtering (non-inclusive). Optional. Default is NULL.
character, MnDOT district code. Default is "metro".
Use mayfly_get_districts() to see available districts.
logical, whether to suppress error messages. Default TRUE
data frame containing variables volume, occupancy, sensor, date, time.
Other loop sensor functions:
pull_configuration(),
pull_sensor_espeed(),
pull_sensor_headway(),
pull_sensor_ids(),
pull_sensor_length(),
pull_sensor_speed()
if (FALSE) { # \dontrun{
# Simple example
library(tc.sensors)
library(purrr)
library(data.table)
loop_data <- pull_sensor(5474, "2025-10-14")
# With filtering - passenger cars only (7-19 feet)
library(tc.sensors)
cars_only <- pull_sensor(5474, "2025-10-14",
length_ft_min = 7,
length_ft_max = 19
)
# Mapping example
date_range <- seq(as.Date("2024/01/01"), as.Date("2024/01/02"), by = "days")
loop_data <- map(date_range, ~ pull_sensor(8564, .x))
loops_full <- rbindlist(loop_data)
# Parallel mapping example with furrr
library(furrr)
plan(multisession, workers = parallel::detectCores() - 1)
date_range <- seq(as.Date("2024/01/01"), as.Date("2024/01/02"), by = "days")
loop_data <- future_map(date_range, ~ pull_sensor(8564, .x))
loops_full <- rbindlist(loop_data)
} # }