Learn R Programming

osrm (version 1.0)

osrmViarouteGeom: Get the Travel Geometry Between Two Points

Description

Build and send an OSRM API query to get the travel geometry between two points. This function interface the viaroute OSRM service.

Usage

osrmViarouteGeom(xo, yo, xd, yd)

Arguments

xo
longitude of the origine point.
yo
latitude of the origine point.
xd
longitude of the destination point.
yd
latitude of the destination point.

Value

  • A data frame is return. It contains the longitudes and latitudes of the travel path between the two points.

See Also

osrmViaroute

Examples

Run this code
# Load data
data("com")
# Travel path between points
routeGeom <- osrmViarouteGeom(xo = com[1,"lon"], yo = com[1,"lat"],
                              xd = com[15,"lon"], yd = com[15,"lat"])
# Display the path
plot(com[c(1,15),3:4], asp =1, col = "red", pch = 20, cex = 1.5)
points(routeGeom[,2:1], type = "l", lty = 2)
text(com[c(1,15),3:4], labels = com[c(1,15),2], pos = 2)

Run the code above in your browser using DataLab