Geocodes (finds latitude and longitude of) a location using the Google
Geocoding API. Note: To use Google's Geocoding API, you must first enable the
API in the Google Cloud Platform Console. See register_google()
.
geocode(
location,
output = c("latlon", "latlona", "more", "all"),
source = c("google", "dsk"),
force = ifelse(source == "dsk", FALSE, TRUE),
urlonly = FALSE,
override_limit = FALSE,
nameType = c("long", "short"),
ext = "com",
inject = "",
...
)mutate_geocode(data, location, ...)
geocodeQueryCheck()
geocode_cache()
write_geocode_cache(path, ...)
load_geocode_cache(path, overwrite = FALSE)
clear_geocode_cache(path)
If output
is "latlon"
, "latlona"
, or "more"
, a tibble
(classed data frame). If "all"
, a list.
a character vector of street addresses or place names (e.g.
"1600 pennsylvania avenue, washington dc" or "Baylor University"
)
amount of output, "latlon"
, "latlona"
, "more"
, or "all"
"google" for Google (note: "dsk" is defunct)
force online query even if cached.
return only the url?
override the current query rate
in some cases, Google returns both a long name and a short name. this parameter allows the user to specify which to grab.
top level domain (e.g. "com", "co.nz"); helpful for non-US users
character string to add to the url or named character vector of key-value pairs to be injected (e.g. c("a" = "b") get converted to "a=b" and appended to the query)
In mutate_geocode()
, arguments to pass to geocode()
. In
write_geocode_cache()
, arguments to pass to saveRDS()
.
a data frame or equivalent
path to file
in load_geocode_cache()
, should the current cache be
wholly replaced with the one on file?
David Kahle david@kahle.io
Note: geocode()
uses Google's Geocoding API to geocode addresses. Please
take care not to disclose sensitive information.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8972108/ suggest various
alternative options for such data.