1. Plotting Rasters

Rasters are generally plotted using the plot command from the raster library. Like many functions in the raster library, the syntax is relatively straightfoward. For example, consider the following plot of a US population count raster:

library(raster)
us.pop <- raster("RGIS3_Data/us_population_raster.asc")
plot(us.pop)

1.1 Managing Breaks

As you can see, however, the raster seems kind of washed out due to the color scaling – most places have no-one, so the default color ramp results in most places being empty. The easiest fix is to just take logs as follows:

us.pop.logged <- us.pop
values(us.pop.logged) <- log(values(us.pop.logged))
plot(us.pop.logged)