Learn R Programming

osrm (version 2.0.0)

osrmTable: Get Travel Time Matrices Between Points

Description

Build and send OSRM API queries to get travel time matrices between points. This function interface the table OSRM service.

Usage

osrmTable(loc, locId, locLat, locLon, src = NULL, srcId, srcLat, srcLon,
  dst = NULL, dstId, dstLat, dstLon)

Arguments

loc
data frame containing points identifiers, longitudes and latitudes (WGS84). If loc parameter is used, all pair-wise distances are computed.
locId
identifier field in loc.
locLat
latitude field in loc.
locLon
longitude field in loc.
src
data frame containing origin points identifiers, longitudes and latitudes (WGS84). If dst and src parameters are used, only pairs between scr/dst are computed.
srcId
identifier field in src
srcLat
latitude fiels in src
srcLon
longitude field in src
dst
data frame containing destination points identifiers, longitudes and latitudes (WGS84). If dst and src parameters are used, only pairs between scr/dst are computed.
dstId
identifier field in dst
dstLat
latitude field in dst
dstLon
longitude field in dst

Value

  • A list containing 3 data frames is returned. distance_table is the matrix of travel times (in minutes), source_coordinates and destination_coordinates are the coordinates of the origin and destination points actually used to compute the travel times.

Examples

Run this code
# Load data
data("com")
# Travel time matrix
distCom <- osrmTable(loc = com[1:50,], 
                     locId = "comm_id", 
                     locLat = "lat", 
                     locLon = "lon")
# First 5 rows and columns
distCom$distance_table[1:5,1:5]
distCom2 <- osrmTable(src = com[1:50,], 
                      srcId = "comm_id", srcLat = "lat", srcLon = "lon", 
                      dst = com[51:100,], 
                      dstId = "comm_id", dstLat = "lat", dstLon = "lon")
# First 5 rows and columns
distCom2$distance_table[1:5,1:5]

Run the code above in your browser using DataLab