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

1
2
3
4
5
6
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)

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

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"

Details

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

Value

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

Author(s)

David Kahle david.kahle@gmail.com

See Also

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

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
30
31
32
33
34
## 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")



## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.