Learn R Programming

osrmr (version 0.1.36)

nearest: nearest accessible position

Description

nearest() calculates the nearest position to the given coordinates which can be accessed by car. The coordinate-standard is WGS84. Attention: The OSRM API v4 is only working locally, but not with the 'OSRM' webserver.

Usage

nearest(lat, lng, api_version = 5, localhost = F, timeout = 0.001)

Arguments

lat,

A numeric (-90 < lat < 90)

lng,

A numeric (-180 < lng < 180)

api_version,

A numeric (either 4 or 5)

localhost,

A logical (TRUE = localhost is used, FALSE = onlinehost is used)

timeout

A numeric indicating the timeout between server requests (in order to prevent queue overflows). Default is 0.001s.

Value

A data.frame with lat and lng

Examples

Run this code
# NOT RUN {
osrmr::nearest(47,9, 5, FALSE)

Sys.setenv("OSRM_PATH_API_5"="C:/OSRM_API5")
osrmr::run_server(Sys.getenv("OSRM_PATH_API_5"), "switzerland-latest.osrm")
osrmr::nearest(47,9, 5, TRUE)
osrmr::quit_server()
Sys.unsetenv("OSRM_PATH_API_5")

Sys.setenv("OSRM_PATH_API_4"="C:/OSRM_API4")
osrmr::run_server(Sys.getenv("OSRM_PATH_API_4"), "switzerland-latest.osrm")
osrmr::nearest(47,9, 4, TRUE)
osrmr::quit_server()
Sys.unsetenv("OSRM_PATH_API_4")
# }

Run the code above in your browser using DataLab