google_encode64: Generates digital signatures for Google Maps API calls.

Description Usage Arguments

View source: R/google_encode64.R


This function, primarily, is a helper for drive_time and geocode_url. It is only necessary when building digital signatures with the private cryptographic key associated with your (paid) Google for Work account. To build valid signatures your vector of addresses must contain "web-safe" UTF-8 characters. By default, and unlike drive_time and geocode_url,this function assumes that the address and dest parameters are already URL encoded. If this is not the case, you may apply url encoding to the inputs using the optional urlencode parameter (see below). (see: address_cleaner). For basic geocoding and distance analyses it is generally easier to use drive_time and geocode_url to encode a request with your Google for Work private key. However, and particularly with large batch jobs, it can be useful to inspect the output of this function for malformed values which yield invalid signatures (see the "debug" option). The function's method of signature generation follows the pattern outlined for Python in the Google Developer documention.


google_encode64(address, dest = NULL, gmode = "geocode", privkey = NULL,
  clientid = NULL, debug = FALSE, verbose = FALSE,
  travel_mode = "driving", units = "metric", language = "en-EN",
  urlencode = FALSE)



A 1xN vector of UTF-8 addresses (if gmode='dtime', this is the origin address).


If gmode is 'dtime', this is the destination address.


character string; must be either "geocode" (the default) or "dtime" (for distance requests).


character string; your Google for Work API key


character string; generally, this ID will be of the form 'gme-[company]'.


logical; when TRUE, returns a complete data frame of locations and their associated URL signatures (this can be useful for debugging invalid signatures).


logical; when TRUE, displays additional progress output.


character string; currently, valid values include (see this page for details):

  • driving (the default): indicates standard driving directions using the road network.

  • transit: requests directions via public transit routes.

  • walking: requests walking directions via pedestrian paths & sidewalks (where available).

  • bicycling: requests bicycling directions via bicycle paths & preferred streets (currently only available in the US and some Canadian cities).


character string; must be either "metric" (the default) or "imperial". Specifying "metric" will return distance between origin and destination as kilometers, whereas "imperial" returns distance in miles. For geocode requests this parameter is ignorned if non-null.


character string; localization of the returned object. This parameter is set to "en-EN" by default, but refer to this page for an up-to-date list of Google's supported languages.


logical; when TRUE, applies the url_encode function from the urltools package.

placement documentation built on May 19, 2017, 10:22 p.m.

Search within the placement package
Search all R packages, documentation and source code