5.3 plot methods for raster objects

Let’s get a raster layer of altitude in Belgium using again getData().

alt <- getData("alt", country = "Belgium", path =  "data")
#R>  Warning in getData("alt", country = "Belgium", path = "data"): getData will be removed in a future version of raster
#R>  . Please use the geodata package instead
plot(alt)

We can also add different layers of information on this maps:

plot(alt)
contour(alt, add = TRUE)

Or reclassify and change the color palette:

# Assign color to a object
myCol <- terrain.colors(3)
plot(alt,
     breaks = c(0, 200, 400, 700),
     col = myCol,
     main = "Altitude map of Belgium")