osmdata_nearest_nodes: Get the nearest OSM nodes to a point

Description Usage Arguments Value Examples

Description

Finds the nearest OSM node(s) to a lat/lon coordinate.

Usage

1
osmdata_nearest_nodes(osmarobj, lon, lat, num = 1)

Arguments

osmarobj

an osmar object

lon

The longitude

lat

The latitude

num

The number of points to return

Value

a list containing the OSM data pertaining to the points as well as the computed distances

Examples

1
2
3
4
5
6
7
8
#use extract_highways to get highway data
wv <- prettymapr::searchbbox("wolfville, ns", source="google")
d2 <- osmdata_highways(wv)

#use nearest_nodes to get nearest road names to a location
nearesthwys <- osmdata_nearest_nodes(d2, -64.3557, 45.0857, num=10)
waysdata <- subset(d2, way_ids = nearesthwys$info$way_ids)
waynames <- unique(as.character(waysdata$ways$tags$v[waysdata$ways$tags$k=="name"]))

paleolimbot/rfuncs documentation built on May 24, 2019, 6:13 p.m.