Description Usage Arguments Value Examples
This function creates a tidy (i.e. long) table of origin-destination trip data using the Valhalla routing engine. For a set of o origins and d destinations, it returns a tibble with (o x d) rows with the travel distance and time between each pair. It can handle several different travel modes and routing options. Please note that this function requires access to a running instance of Valhalla.
This function provides fine-grained control over Valhalla's API options.
 For a user-friendly function, see the function valhallr::od_table().
For details about the API, see Valhalla's documentation here: https://valhalla.readthedocs.io/en/latest/api/matrix/api-reference/
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | sources_to_targets(
  froms,
  tos,
  costing = "auto",
  from_search_filter = list(max_road_class = "motorway", min_road_class =
    "residential"),
  to_search_filter = list(max_road_class = "motorway", min_road_class = "residential"),
  minimum_reachability = 50,
  costing_options = list(),
  exclude_polygons = NA,
  hostname = "localhost",
  port = 8002
)
 | 
| froms | A tibble containing origin locations in columns named  | 
| tos | A tibble containing destination locations in columns named  | 
| costing | The travel costing method: at present "auto", "bicycle", and "pedestrian" are supported. | 
| from_search_filter | A named list of options provided to Valhalla API. Defaults set a maximum road class ("motorway", the highest) and minimum road class ("residential", which is one above the lowest, "service_other"). See API documentation for details. | 
| to_search_filter | A named list of options provided to Valhalla API. Defaults set a maximum road class ("motorway", the highest) and minimum road class ("residential", which is one above the lowest, "service_other"). See API documentation for details. | 
| minimum_reachability | The minimum number of nodes a candidate network needs to have before it is included. Try increasing this value (e.g. to 500) if Valhalla is getting stuck in small disconnected road networks. | 
| costing_options | A named list of options provided to the Valhalla API that affect route costing, e.g. willingness to travel on highways or through alleys. See API documentation for details. | 
| exclude_polygons | A tibble or list of tibbles with  | 
| hostname | Hostname or IP address of your Valhalla instance. Defaults to "localhost". | 
| port | The port your Valhalla instance is monitoring. Defaults to 8002. | 
A tibble showing the trip distances and times from each origin to each destination.
| 1 2 3 4 5 6 7 8 9 | ## Not run: 
# NOTE: Assumes an instance of Valhalla is running on localhost:8002.
library(dplyr)
library(valhallr)
froms <- bind_rows(test_data("parliament"), test_data("uottawa"))
tos <- bind_rows(test_data("cdntirecentre"), test_data("parliament"))
st <- sources_to_targets(froms, tos)
## End(Not run)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.