Learn R Programming

stplanr (version 0.4.0)

nearest_osm: Generate nearest point on the route network of a point from OSRM locate service

Description

Generate nearest point on the route network of a point from OSRM locate service

Usage

nearest_osm(lat, lng, number = 1, api = 5, profile = "driving",
  protocol = "v1", osrmurl = "http://router.project-osrm.org",
  return_sf = FALSE)

Arguments

lat

Numeric vector containing latitude coordinate for each coordinate to map. Also accepts dataframe with latitude in the first column and longitude in the second column.

lng

Numeric vector containing longitude coordinate for each coordinate to map.

number

Number of locations to return (API v5 only)

api

An integer value containing the OSRM API version (either 4 or 5). Default is 5.

profile

OSRM profile to use (for API v5), defaults to "driving".

protocol

The protocol to use for the API (for v5), defaults to "v1".

osrmurl

Base URL of the OSRM service

return_sf

Boolean value if this function should return an sf object, if FALSE returns sp object (default FALSE).

Details

Retrieve coordinates of the node(s) on the network mapped from coordinates passed to functions.

See Also

Other nodes: geo_code, locate2spdf, nearest_google

Examples

Run this code
# NOT RUN {
nearest_osm(
  lat = 50.3,
  lng = 13.2
)
# }

Run the code above in your browser using DataLab