google_geocode {googleway} | R Documentation |
Google geocoding
Description
Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers on a map, or position the map.
Usage
google_geocode(
address,
bounds = NULL,
key = get_api_key("geocode"),
language = NULL,
region = NULL,
components = NULL,
simplify = TRUE,
curl_proxy = NULL
)
Arguments
address |
|
bounds |
list of two, each element is a vector of lat/lon coordinates representing the south-west and north-east bounding box |
key |
|
language |
|
region |
|
components |
|
simplify |
|
curl_proxy |
a curl proxy object |
Value
Either list or JSON string of the geocoded address
API use and limits
The amount of queries you can make to Google's APIs is dependent on both the service and the API you are using.
Each API has specific quotas and limits. Check Google's API documentation for details.
View your usage at the Google Cloud Console https://console.cloud.google.com/
Each API can only accept and return one request at a time. If you write a loop to make multiple API calls you should ensure you don't go over your quota / limits during the loop.
Examples
## Not run:
set_key("YOUR_GOOGLE_API_KEY")
df <- google_geocode(address = "MCG, Melbourne, Australia",
simplify = TRUE)
df$results$geometry$location
lat lng
1 -37.81659 144.9841
## using bounds
bounds <- list(c(34.172684,-118.604794),
c(34.236144,-118.500938))
js <- google_geocode(address = "Winnetka",
bounds = bounds,
simplify = FALSE)
## using components
components <- data.frame(component = c("postal_code", "country"),
value = c("3000", "AU"))
df <- google_geocode(address = "Flinders Street Station",
components = components,
simplify = FALSE)
## End(Not run)