Learn R Programming

hereR (version 0.3.0)

traffic: HERE Traffic API: Flow and Incidents

Description

Real-time traffic flow and incident information based on the HERE 'Traffic' API in areas of interest (AOIs). 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 = NULL,
  to = NULL,
  min_jam_factor = 0,
  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

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

to

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

min_jam_factor

numeric, only retrieve flow information with a jam factor greater than the value provided (Note: Only takes effect if product is set to "flow", default = 0).

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 {
# Provide an API Key for a HERE project
set_key("<YOUR API KEY>")

# 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 = as.POSIXct("2018-01-01 00:00:00"),
  to = as.POSIXct("2019-12-31 23:59:59"),
  url_only = TRUE
)
# }

Run the code above in your browser using DataLab