# NOT RUN {
r <- raster::raster(nrow = 10, ncol = 10, crs = NA)
r[] <- 1L
r[51:100] <- 2L
r[3:6, 1:5] <- 8L
r <- raster::ratify(r)
rat <- raster::levels(r)[[1]]
rat$land.cover <- c("Pine", "Oak", "Meadow")
rat$code <- c(12, 25, 30)
levels(r) <- rat
PlotMap(r, att = "land.cover", col = c("grey", "orange", "purple"))
PlotMap(r, att = "code")
m <- t(datasets::volcano)[61:1, ]
x <- seq(from = 6478705, length.out = 87, by = 10)
y <- seq(from = 2667405, length.out = 61, by = 10)
r <- raster::raster(m, xmn = min(x), xmx = max(x), ymn = min(y), ymx = max(y),
crs = "+init=epsg:27200")
PlotMap(r, pal = terrain.colors, scale.loc = "bottomright",
explanation = "Topographic information on Auckland's Maunga Whau volcano.",
credit = "Digitized from a topographic map by Ross Ihaka on a 10-m by 10-m grid.",
shade = list(alpha = 0.3), contour.lines = list(col = "#1F1F1F"),
useRaster = TRUE)
r <- raster::raster(system.file("external/test.grd", package = "raster"))
Pal <- colorspace::rainbow_hcl
breaks <- seq(0, 2000, by = 200)
PlotMap(r, breaks = breaks, pal = Pal, dms.tick = TRUE, bg.lines = TRUE,
scale.loc = "bottomright", contour.lines = list(col = "#1F1F1F"),
draw.key = FALSE, simplify = 0)
AddGradientLegend(breaks, Pal, at = breaks, title = "Explanation", loc = "topleft",
inset = c(0.1, 0.1), strip.dim = c(2, 20))
out <- PlotMap(r, dms.tick = TRUE, file = "Rplots1.pdf")
pdf(file = "Rplots2.pdf", width = out$din[1], height = out$din[2])
PlotMap(r, dms.tick = TRUE)
data(meuse, package = "sp")
sp::coordinates(meuse) = ~ x + y
points(meuse)
dev.off()
file.remove(c("Rplots1.pdf", "Rplots2.pdf"))
graphics.off()
# }
Run the code above in your browser using DataLab