Learn R Programming

googleway (version 2.0.0)

google_snapToRoads: Snap To Roads

Description

Takes up to 100 GPS coordinates collected along a route and returns a similar set of data, with the points snapped to the most likely roads the vehicle was treveling along

Usage

google_snapToRoads(df_path, lat = NULL, lon = NULL, interpolate = FALSE,
  simplify = TRUE, key)

Arguments

df_path

data.frame with at least two columns specifying the latitude & longitude coordinates, with a maximum of 100 pairs of coordinates.

lat

string specifying the column of df_path containing the 'latitude' coordinates. If left NULL, a best-guess will be made.

lon

string specifying the column of df_path containing the ' longitude' coordinates. If left NULL, a best-guess will be made.

interpolate

logical indicating whether to interpolate a path to include all points forming the full road-geometry. When TRUE, additional interpolated points will also be returned, resulting in a path that smoothly follows the geometry of the road, even around corners and through tunnels. Interpolated paths will most likely contain more ponts that the original path.

simplify

logical Indicates if the returned JSON should be coerced into a list

key

string A valid Google Developers Places API key

See Also

google_nearestRoads

Examples

Run this code
# NOT RUN {
key <- 'your_api_key'

df_path <- read.table(text = "lat lon
-35.27801 149.12958
-35.28032 149.12907
-35.28099 149.12929
-35.28144 149.12984
-35.28194 149.13003
-35.28282 149.12956
-35.28302 149.12881
-35.28473 149.12836", header = T)

google_snapToRoads(df_path, key = key, interpolate = TRUE, simplify = TRUE)


# }

Run the code above in your browser using DataLab