if (FALSE) {
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()
}
Run the code above in your browser using DataLab