I am trying to plot a predicted surface (raster layer) over a
ggmap object that contains base imagery from Google Earth. I have produced the map that I want however, I am struggling to add the legend scalebar.
To add the raster over top the
ggmap object, I used the
inset_raster function and I am not sure where to map the aesthetics to produce the proper legend based on the color scale I assigned the raster.
Below is an example of my code. Does anyone have advice on how to add the legend based on the
rsfmap <- ggmap(get_googlemap(center = c(lon = x, lat = y), zoom = 9, maptype = "hybrid"), extent = "device", darken = 0.05, legend='right') rsfmap+ geom_point(aes(x=coords.x1, y=coords.x2), size=1, alpha=0.75, data=mydata) + inset_raster(as.raster(ggras, col=(topo.colors(500, alpha=0.4))), xmin = ggras@extent, xmax = ggras@extent,ymin = ggras@extent, ymax = ggras@extent, interpolate = TRUE)