mapdist: Compute map distances using Google

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Compute map distances using Google's Distance Matrix API. Note: To use Google's Distance Matrix API, you must first enable the API in the Google Cloud Platform Console. See ?register_google.

Usage

1
2
3
4
5
mapdist(from, to, mode = c("driving", "walking", "bicycling", "transit"),
  output = c("simple", "all"), urlonly = FALSE,
  override_limit = FALSE, ext = "com", inject = "", ...)

distQueryCheck()

Arguments

from

name of origin addresses in a data frame (vector accepted)

to

name of destination addresses in a data frame (vector accepted)

mode

driving, bicycling, walking, or transit

output

amount of output

urlonly

return only the url?

override_limit

override the current query count (.google_distance_query_times)

ext

domain extension (e.g. "com", "co.nz")

inject

character string to add to the url

...

...

Details

if parameters from and to are specified as geographic coordinates, they are reverse geocoded with revgeocode. note that the google maps api limits to 2500 element queries a day.

Value

a data frame (output="simple") or all of the geocoded information (output="all")

Author(s)

David Kahle david.kahle@gmail.com

See Also

http://code.google.com/apis/maps/documentation/distancematrix/, https://developers.google.com/maps/documentation/distance-matrix/intro

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Not run:  requires Google API key, see ?register_google

## basic usage
########################################

mapdist("waco, texas", "houston, texas")

from <- c("houston, texas", "dallas")
to <- "waco, texas"
mapdist(from, to)
mapdist(from, to, mode = "bicycling")
mapdist(from, to, mode = "walking")

from <- c(
  "1600 Amphitheatre Parkway, Mountain View, CA",
  "3111 World Drive Walt Disney World, Orlando, FL"
)
to <- "1600 Pennsylvania Avenue, Washington DC"
mapdist(from, to)

from <- "st lukes hospital houston texas"
to <- "houston zoo, houston texas"
mapdist(from, to, mode = "transit")

from <- c("houston", "houston", "dallas")
to <- c("waco, texas", "san antonio", "houston")
mapdist(from, to)


## geographic coordinates are accepted as well
########################################
(wh <- as.numeric(geocode("the white house, dc")))
(lm <- as.numeric(geocode("lincoln memorial washington dc")))
mapdist(wh, lm, mode = "walking")


## End(Not run)

ggmap documentation built on May 1, 2019, 8:22 p.m.