Learn R Programming

hereR (version 0.2.1)

traffic: HERE Traffic API: Flow and Incidents

Description

Real-time traffic flow and incident information based on the 'Traffic' API. The traffic flow data contains speed ("SP") and congestion (jam factor: "JF") information. Traffic incidents contain information about location, time, duration, severity, description and other details.

Usage

traffic(aoi, product = "flow", from_dt = NULL, to_dt = NULL,
  local_time = FALSE, url_only = FALSE)

Arguments

aoi

sf object, Areas of Interest (POIs) of geometry type POLYGON.

product

character, traffic product of the 'Traffic API'. Supported products: "flow" and "incidents".

from_dt

datetime, timestamp of type POSIXct, POSIXt for the earliest traffic incidents (Note: Only takes effect if product is set to "incidents").

to_dt

datetime, timestamp of type POSIXct, POSIXt for the latest traffic incidents (Note: Only takes effect if product is set to "incidents").

local_time

boolean, should time values in the response for traffic incidents be in the local time of the incident or in UTC (default = FALSE)?

url_only

boolean, only return the generated URLs (default = FALSE)?

Value

An sf object containing the requested traffic information.

References

Examples

Run this code
# NOT RUN {
# Authentication
set_auth(
  app_id = "<YOUR APP ID>",
  app_code = "<YOUR APP CODE>"
)

# Real-time traffic flow
flow <- traffic(
  aoi = aoi[aoi$code == "LI", ],
  product = "flow",
  url_only = TRUE
)

# All traffic incidents from 2018 till end of 2019
incidents <- traffic(
  aoi = aoi[aoi$code == "LI", ],
  product = "incidents",
  from_dt = as.POSIXct("2018-01-01 00:00:00"),
  to_dt = as.POSIXct("2019-12-31 23:59:59"),
  url_only = TRUE
)
# }

Run the code above in your browser using DataLab