mapdist: Compute map distances using Google

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

View source: R/mapdist.R

Description

Compute map distances using Google Maps. Note that in most cases by using this function you are agreeing to the Google Maps API Terms of Service at https://developers.google.com/maps/terms.

Usage

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

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, or walking

output

amount of output

messaging

turn messaging on/off

language

language

urlonly

return only the url?

override_limit

override the current query count (.GoogleDistQueryCount)

ext

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

inject

character string to add to the url

usingPlaceIDs

indicate that from and to fields contain placeIDs. Turns of URL encoding of addresses.

...

...

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.

mapdist now makes a single query to the mapdist api. The returned data frame will have length(from)*length(to) rows

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/

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
## Not run: # online queries draw R CMD check times

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")

# google requires a key for mode="transit"
register_google(key = "[your key here]")
from <- "city hall houston texas"
to <- "nrg stadium 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")
distQueryCheck()


## End(Not run)

fresques/ggmap documentation built on May 28, 2019, 8:40 p.m.