googleway (version 2.7.1)

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, curl_proxy = NULL, key = get_api_key("roads"))

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 - TRUE indicates the returned JSON will be coerced into a list. FALSE indicates the returend JSON will be returned as a string

curl_proxy

a curl proxy object

key

string A valid Google Developers Places API key

API use and limits

The amount of queries you can make to Google's APIs is dependent on both the service and the API you are using.

Each API has specific quotas and limits. Check Google's API documentation for details.

View your usage at the Google Cloud Console https://console.cloud.google.com/

Each API can only accept and return one request at a time. If you write a loop to make multiple API calls you should ensure you don't go over your quota / limits during the loop.

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 DataCamp Workspace