I’m using the R plot_ly library. I have generated a 3d surface of ozone concentrations in my neighborhood (Grand Junction, CO). I’d like to put a map of the region ‘underneath’ it so the casual observer will have some feel for where the data are located in the real world.
Here is the code for the 3d surface
library(ggmap)
library(akima)
library(plotly)
x ← c(“-108.6125”,“-108.5114”,“-108.805”,“-108.4014”,“-108.5615”,“-108.8349”,“-108.225”,“-108.3139”,“-108.5568”,“-108.4968”)
y ← c(“39.02205”,“39.22255”,“39.598”,“38.89478”,“39.06429”,“39.27625”,“39.03”,“39.1306”,“39.14823”,“38.89795”)
z ← c(“60.7735”,“56.45783”,“49.65”,“60.15”,“50”,“53.95417”,“50.825”,“56”,“55.843”,“38.73333”)
df ← data.frame(x = as.numeric(x),y = as.numeric(y),z = as.numeric(z))s = interp(x = df$x, y = df$y, z = df$z)
p ← plot_ly(x = s$x, y = s$y, z = s$z) %>% add_surface()
And some code that gets a google map that is relatively close (the ggmap code doesn’t generate quite what I want yet but it’s close)
get google map of the grand valley
loc ← c(-109, 38.8, -108, 39.8)
tx_map_gmaps ← get_map(location=loc, zoom = 9, source=“google”, maptype=“terrain”)
gg ← ggmap(tx_map_gmaps)
gg
Is there some way to put the google map at x,y,0?