google_elevation.Rd
The Google Maps Elevation API provides elevation data for all locations on the surface of the earth, including depth locations on the ocean floor (which return negative values).
google_elevation(df_locations = NULL, polyline = NULL, location_type = c("individual", "path"), samples = NULL, key = get_api_key("elevation"), simplify = TRUE, curl_proxy = NULL)
df_locations |
|
---|---|
polyline |
|
location_type |
|
samples |
|
key |
|
simplify |
|
curl_proxy | a curl proxy object |
Either list or JSON string of the elevation data
Locations can be specified as either a data.frame containing both a lat/latitude and lon/longitude column, or a single encoded polyline
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.
# NOT RUN { set_key("YOUR_GOOGLE_API_KEY") ## elevation data for the MCG in Melbourne df <- data.frame(lat = -37.81659, lon = 144.9841) google_elevation(df_locations = df, simplify = TRUE) ## elevation data from the MCG to the beach at Elwood (due south) df <- data.frame(lat = c(-37.81659, -37.88950), lon = c(144.9841, 144.9841)) df <- google_elevation(df_locations = df, location_type = "path", samples = 20, simplify = TRUE) ## plot results library(ggplot2) df_plot <- data.frame(elevation = df$results$elevation, location = as.integer(rownames(df$results))) ggplot(data = df_plot, aes(x = location, y = elevation)) + geom_line() # }