library(ggplot2)
#### Example 1: plot landmask of the Western Mediterranean Sea
## a) by using longitude and latitude coordinates:
# lon <- c(-6, 16.5)
# lat <- c(34, 44.5)
# ggobj <- ggplotmap(xlim = lon, ylim = lat)
# ggobj
# ggplotmaply(ggobj, expand = 10)
## b) plot landmask with an extent-object:
# library(raster)
# ext <- extent(lon, lat)
# plotmap(ext, main = "Western Mediterranean Sea")
# ggobj <- ggplotmap(ext)
# ggplotmaply(ggobj)
## c) raster-object example:
# r <- raster(ext)
# ggobj <- ggplotmap(r)
# ggplotmaply(ggobj)
## d) Mediterranean Sea by keyword:
ggobj <- ggplotmap("med4") +
geom_point(
data = data.frame(x = 3.7008, y = 43.4079),
aes(x, y),
size = 5,
colour = "blue"
)
# ggplotmaply(ggobj, expand = 10)
## e) raster image plot with landmask:
# library(dplyr)
# data(cmap)
# setwd(system.file("test_files", package = "oceanmap"))
# nc <- nc2raster(ncfiles[1])
# rs2df <- nc[[1]] %>%
# rasterToPoints() %>%
# as.data.frame()
# names(rs2df) <- c("Lon","Lat","Conc")
# ggobj <- ggplot() + geom_raster(data = rs2df, aes(x = Lon, y = Lat, fill = Conc))
# ggobj_with_land_mask <- ggplotmap(add_to = ggobj) +
# scale_fill_gradientn(colours = cmap$jet)
# ggplotmaply(ggobj_with_land_mask)
Run the code above in your browser using DataLab