Learn R Programming

ggmap (version 2.6.1)

geocode: Geocode

Description

Geocodes a location (find latitude and longitude) using either (1) the Data Science Toolkit (http://www.datasciencetoolkit.org/about) or (2) Google Maps. Note that when using Google 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"),
  source = c("google", "dsk"), messaging = FALSE, force = ifelse(source ==
  "dsk", FALSE, TRUE), sensor = FALSE, override_limit = FALSE,
  client = "", signature = "", nameType = c("long", "short"), data)

geocodeQueryCheck(userType = "free")

Arguments

location

a character vector of street addresses or place names (e.g. "1600 pennsylvania avenue, washington dc" or "Baylor University")

output

amount of output, "latlon", "latlona", "more", or "all"

source

"dsk" for Data Science Toolkit or "google" for Google

messaging

turn messaging on/off

force

force online query, even if previously downloaded

sensor

whether or not the geocoding request comes from a device with a location sensor

override_limit

override the current query count (.GoogleGeocodeQueryCount)

nameType

in some cases, Google returns both a long name and a short name. this parameter allows the user to specify which to grab.

data

deprecated in 2.5, use mutate_geocode

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

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

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
 # Server response can be slow; this cuts down check time.

# types of input
geocode("houston texas")
geocode("baylor university") # see known issues below
geocode("1600 pennsylvania avenue, washington dc")
geocode("the white house")
geocode(c("baylor university", "salvation army waco"))




# types of output
geocode("houston texas", output = "latlona")
geocode("houston texas", output = "more")
geocode("Baylor University", output = "more")
str(geocode("Baylor University", output = "all"))


# see how many requests we have left with google
geocodeQueryCheck()
geocode("one bear place, waco, texas")
geocode("houston texas", force = TRUE)



# known issues :
# (1) source = "dsk" can't reliably geocode colloquial place names
geocode("city hall houston")
geocode("rice university")


# }
# NOT RUN {
# }

Run the code above in your browser using DataLab