R/plot_raster_resample.R

##' @import ggplot2
##' @import maps
##' @import PBSmapping
##' @importFrom data.table setnames
##' @export plot raster_resample
plot.raster_resample <- function(x, ...) {

  n <- length(x)
  .x <- Reduce(rbind, x)

  world <- map_data("world")
  xlim <- range(.x$lon)
  ylim <- range(.x$lat)
  data.table::setnames(world, c("X","Y","PID","POS","region","subregion"))
  world <- clipPolys(world, xlim = xlim, ylim = ylim, keepExtra = TRUE)

  for (i in 1:n) {
    gg <- ggplot(x[[i]], aes(x = lon, y = lat, colour = factor(cell)), ...) +
      geom_point() +
      coord_quickmap() +
      geom_polygon(data = world, aes(x = X,  y = Y, group = PID),
                   colour = "black", fill = "white", alpha = 0) +
      theme_minimal()
    print(gg)
    cat ("Press [enter] for next plot")
    line <- readline()
  }
}
cszang/raresa documentation built on May 14, 2019, 12:27 p.m.