Learn R Programming

ggmap (version 2.2)

geocode: Geocode

Description

geocodes a location using Google Maps.

Usage

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

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)

Value

  • depends (at least a data.frame with variables lon and lat)

Details

note that the google maps api limits to 2500 queries a day.

See Also

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

Examples

Run this code
geocode('Baylor University')
geocode('1600 Pennsylvania Avenue, Washington DC')
geocode('1600 Pennsylvania Avenue, Washington DC', messaging = TRUE)
geocode('the white house', messaging = TRUE)
geocode('the eiffel tower')
geocode(c('baylor university', 'salvation army waco'))
geocode(c('baylor university', 'the vatican'))
geocode(c('baylor university', 'the vatican'), output = 'latlona')
geocode(c('baylor university', 'the vatican'), output = 'more')
geocode('the eiffel tower', output = 'all')
geocodeQueryCheck()

# careful in running this...
library(stringr)
ads <- unique(crime$address)[1:120]
ads <- paste(ads, ', houston, texas', sep = '')
ads <- str_trim(ads)
gc <- geocode(ads)

Run the code above in your browser using DataLab