Skip to contents

Function as an interface for the traffic API call

Usage

read_telraam_traffic(
  id,
  report = c("per-hour"),
  time_start,
  time_end,
  tz = Sys.timezone(),
  mytoken = get_telraam_token(),
  include_speed = FALSE
)

Arguments

id

the segment (or instance) identifier in question (can be found in the address of the segment from the Telraam website)

report

can only be "per-hour", resulting in hourly aggregated traffic

time_start

The beginning of the requested time interval

time_end

The end of the requested time interval (note: the time interval is closed-open, so the end time is not included anymore in the request

tz

timezone, by default the value from Sys.timezone() in your machine. If the provided time zone is affected by daylight saving time, the conversion of the time might result in NA values for the datetime when the clocks change.

mytoken

the authentication token, if not previously set with usethis::edit_r_environ() or the set_telraamToken function

include_speed

logical, if car speed distribution included in the final data, FALSE as default

Value

data.frame with traffic data

Examples





if (FALSE) { # \dontrun{
# Setting up the PAT Method 1 (Recommended):
# 1. Run the following line
usethis::edit_r_environ()

# 2. Add the following line:
    telraam = "your token goes here"
# 3. Restart your R session

# Setting up the PAT Method 2:
my_token = readLines(con = "mytoken.txt",warn = FALSE)

# Using the function
read_telraam_traffic(9000003890,
                     time_start = "2023-03-25 07:00:00",
                     time_end = "2023-03-30 07:00:00")

read_telraam_traffic(9000003890,
                     time_start = "2023-03-25 07:00:00",
                     time_end = "2023-03-30 07:00:00",
                     include_speed = TRUE)
} # }