# 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")
r <- raster::raster(system.file("external/test.grd", package="raster"))
credit <- "Label crediting the map."
explanation <- "Label explaining the raster cell value."
PlotMap(r, scale.loc = "bottomright", dms.tick = TRUE, credit = credit,
explanation = explanation)
data(meuse, package = "sp")
sp::coordinates(meuse) = ~ x + y
points(meuse)
val <- PlotMap(r, scale.loc = "topleft", dms.tick = TRUE, credit = credit,
explanation = explanation, file = "Rplots1.pdf")
print(val)
pdf(file = "Rplots2.pdf", width = val$din[1], height = val$din[2])
PlotMap(r, scale.loc = "topleft", dms.tick = TRUE, credit = credit,
explanation = explanation)
points(meuse)
dev.off()
file.remove(c("Rplots1.pdf", "Rplots2.pdf"))
graphics.off()
# }
Run the code above in your browser using DataLab