geocode
Georeferencing with Google
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.
- Keywords
- spatial
Usage
geocode(x, oneRecord=FALSE, extent=NULL, progress='', geocode_key, ...)
Arguments
- x
A vector of locality descriptions
- oneRecord
Logical. If
TRUE
a single record for each item in x is returned. If the API returned multiple records, the values of this record are computed by averaging the coordinates and taking the union of all bounding boxes- 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)
Value
data.frame
with the following fields:
the locality description as provided (in argument x
)
the locality as interpreted by the Google API
longitude
latitude
minimum longitude of the bounding box
maximum longitude of the bounding box
minimum latitude of the bounding box
maximum latitude of the bounding box
distance from c(lon, lat)
to the farthest corner of the bounding box
Note
It is important to compare fields originalPlace
and interpretedPlace
as the Google interpretation of a (perhaps vague) locality description can be very speculative
Examples
# 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)
# }