ox_nearest_nodes: Find the nearest node to a point

View source: R/routing.R

ox_nearest_nodesR Documentation

Find the nearest node to a point

Description

Returns the osmid of the graph node closest (in planar distance) to each supplied coordinate.

Usage

ox_nearest_nodes(g, x, y)

Arguments

g

An osm_graph.

x, y

Numeric vectors of coordinates in the graph's CRS.

Value

An integer/numeric vector of node osmids, one per input point.

Examples

g <- example_osm_graph()
ox_nearest_nodes(g, x = 0, y = 0)

osmnxr documentation built on Oct. 20, 2026, 1:07 a.m.