Okay so I wish to plot a plain map onto the ggmap base so that the ocean shows the bathymetry data.
library(maps)
library(mapdata)
library(ggplot2)
library(ggmap)
#pick out the base layer I want
get.Peru<-get_map(location = c(left = -85, bottom = -20, right = -70, top = -5), maptype="satellite")
#this is the layer i wish to put over the top
coast_map <- fortify(map("worldHires", fill = TRUE, plot = FALSE))
peru_bathy_map <- fortify(get.Peru)
gg <- ggplot()
gg <- gg + geom_map(data=peru_bathy_map, map=peru_bathy_map,
aes(map_id=id))
gg <- gg + geom_map(data=coast_map, map=coast_map, aes(x=long, y=lat, map_id=region),
fill="gray", color="black") + xlim(-86,-70) + ylim(-20,-4) + labs(x="Longitude", y="Latitude")
gg <- gg + coord_map() + theme_classic()
However, I get the error: Error: ggplot2 doesn't know how to deal with data of class ggmapraster
when I try and run the fortify code.
I have used this method before to add bathymetry polygons (see previous question) but they looked messy when I plotted datapoints onto the ocean so I am now trying this.
If anyone has any pointers, or even other ways of plotting cleanish looking bathymetry data other that ggmaps satellite please let me know :)