google_snapToRoads: Snap To Roads

Description Usage Arguments API use and limits Note See Also Examples

View source: R/google_roads.R

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

1
2
3
4
5
6
7
8
9
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.

Note

The snapping algorithm works best for points that are not too far apart. If you observe odd snapping behaviour, try creating paths that have points closer together. To ensure the best snap-to-road quality, you should aim to provide paths on which consecutive pairs of points are within 300m of each other. This will also help in handling any isolated, long jumps between consecutive points caused by GPS signal loss or noise.

See Also

google_nearestRoads

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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)



## End(Not run)

googleway documentation built on Nov. 16, 2020, 9:08 a.m.