geocode: Geocode

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/geocode.R

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), urlonly = FALSE, override_limit = FALSE,
  nameType = c("long", "short"), ext = "com", inject = "", ...)

geocodeQueryCheck()

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

urlonly

return only the url?

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.

ext

domain extension (e.g. "com", "co.nz")

inject

character string to add to the url

...

...

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/, https://developers.google.com/maps/documentation/geocoding/usage-limits

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
## Not run:  # Server response can be slow; this cuts down check time.

##### basic usage
########################################

geocode("houston texas")
geocode("1600 pennsylvania avenue, washington dc")
geocode("the white house")
geocode(c("the white house", "washington dc"))
# see also mutate_geocode()
geocode("ninos", inject = "region=es", urlonly = TRUE)


##### types of output
########################################

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


##### interfacing with the google geocoding api
########################################

register_google(key = "your code here")
geocode("houston texas")


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



##### known issues
########################################
# sources often have a hard time reliably geocoding colloquial place names
geocode("city hall houston")
geocode("city hall houston texas")
geocode("rice university")
geocode("rice university houston texas")



## End(Not run)

fresques/ggmap documentation built on May 28, 2019, 8:40 p.m.