Learn R Programming

ggmap (version 2.4)

geocode: Geocode

Description

Geocodes a location (find latitude and longitude) 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

geocode(location, output = c("latlon", "latlona", "more", "all"),
  messaging = FALSE, sensor = FALSE, override_limit = FALSE,
  client = "", signature = "", data)

geocodeQueryCheck(userType = "free")

Arguments

location
a character string specifying a location of interest (e.g. "Baylor University")
output
amount of output
messaging
turn messaging on/off
sensor
whether or not the geocoding request comes from a device with a location sensor
override_limit
override the current query count (.GoogleGeocodeQueryCount)
client
client ID for business users, see https://developers.google.com/maps/documentation/business/webservices/auth
signature
signature for business users, see https://developers.google.com/maps/documentation/business/webservices/auth
data
a data frame
userType
User type, "free" or "business"

Value

  • If output is "latlon", "latlona", or "more", a data frame. If all, a list.

Details

Note that the google maps api limits to 2500 queries a day. Use geocodeQueryCheck to determine how many queries remain.

See Also

http://code.google.com/apis/maps/documentation/geocoding/

Examples

Run this code
# Types of input
geocode('Baylor University')
geocode('1600 Pennsylvania Avenue, Washington DC')
geocode('the white house')
geocode(c('baylor university', 'salvation army waco'))

# Types of output
geocode('Baylor University', output = "latlona")
geocode('Baylor University', output = "more")
str(geocode('Baylor University', output = "all"))

# See how many requests we have left
geocodeQueryCheck()

Run the code above in your browser using DataLab