geocode | R Documentation |
A wrapper around the Google geocoding web-service. It returns 0 to n matches. It is important to be as precise as possible, e.g. always include the country in the locality description.
geocode(x, oneRecord=FALSE, extent=NULL, progress='', geocode_key, ...)
x |
A vector of locality descriptions |
oneRecord |
Logical. If |
extent |
An Extent object, or an object that can be coerced to one, to bias the search towards that region |
progress |
Character. Valid values are "" (no progress indicator), "text" or "window" |
geocode_key |
character. Your Google API key for geocoding (and billing). See https://developers.google.com/maps/documentation/geocoding/get-api-key) |
... |
additional arguments (currently none implemeted) |
data.frame
with the following fields:
originalPlace |
the locality description as provided (in argument |
interpretedPlace |
the locality as interpreted by the Google API |
lon |
longitude |
lat |
latitude |
lonmin |
minimum longitude of the bounding box |
lonmax |
maximum longitude of the bounding box |
latmin |
minimum latitude of the bounding box |
latmax |
maximum latitude of the bounding box |
uncertainty |
distance from |
It is important to compare fields originalPlace
and interpretedPlace
as the Google interpretation of a (perhaps vague) locality description can be very speculative
Robert J. Hijmans
## Not run:
geocode(c('1600 Pennsylvania Ave NW, Washington DC', 'Luca, Italy', 'Kampala'))
geocode(c('San Jose', 'San Jose, Mexico'))
geocode(c('San Jose', 'San Jose, Mexico'), oneRecord=TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.