calculate_route: Calculate route between series of points

Description Usage Arguments Examples

View source: R/routing.R

Description

Calculate route between series of points

Usage

1
calculate_route(locations, alternatives = 0)

Arguments

locations

A sf object with a series of points that need to be on route.

alternatives

Number of alternative routes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(dplyr)
library(sf)

library(tomtom)

TOMTOM_API_KEY = Sys.getenv("TOMTOM_API_KEY")
set_api_key(TOMTOM_API_KEY)

locations <- tribble(
  ~label, ~lon, ~lat,
  "Durban", 31.05, -29.88,
  "Port Elizabeth", 25.6, -33.96,
  "Cape Town", 18.42, -33.93,
  "Johannesburg", 28.05, -26.20
)

locations <- st_as_sf(locations, coords = c("lon", "lat"), remove = FALSE, crs = 4326)
calculate_route(locations)

datawookie/tomtom documentation built on Dec. 19, 2021, 9:03 p.m.