osrmNearest: Get the Nearest Point on the Street Network

View source: R/osrmNearest.R

osrmNearestR Documentation

Get the Nearest Point on the Street Network

Description

This function interfaces with the nearest OSRM service.

Usage

osrmNearest(
  loc,
  exclude,
  osrm.server = getOption("osrm.server"),
  osrm.profile = getOption("osrm.profile")
)

Arguments

loc

a point to snap to the street network. loc can be:

  • a vector of coordinates (longitude and latitude, WGS 84),

  • a data.frame of longitudes and latitudes (WGS 84),

  • a matrix of longitudes and latitudes (WGS 84),

  • an sfc object of type POINT,

  • an sf object of type POINT.

If src is a data.frame, a matrix, an sfc object or an sf object then only the first row or element is considered.

exclude

pass an optional "exclude" request option to the OSRM API.

osrm.server

the base URL of the routing server.

osrm.profile

the routing profile to use, e.g. "car", "bike" or "foot".

Value

The output of this function is an sf POINT of the point on the street network.
It contains 2 fields:

  • id, the point identifierv

  • distance, the distance in meters to the supplied input point.

Examples

## Not run: 
library(sf)
apotheke.sf <- st_read(system.file("gpkg/apotheke.gpkg", package = "osrm"),
  quiet = TRUE
)
pt <- osrmNearest(apotheke.sf[56, ])
pt$distance

## End(Not run)

osrm documentation built on May 29, 2024, 9:29 a.m.