I really struggle to understand some basic concepts in the structure of how R's
raster
-objects save values. Namely the RasterLayer
, the RasterBrick
and the RasterStack
.
I understand that the values (when manually creating a raster) can just be of type numeric, integer, logical or factor
. When I create a raster with numeric values like this:
raster_numeric = raster(nrows = 6, ncols = 6, res = 0.5,
xmn = -1.5, xmx = 1.5, ymn = -1.5, ymx = 1.5,
vals = seq(0.1,3.6,0.1))
I get this structure:
class : RasterLayer
dimensions : 6, 6, 36 (nrow, ncol, ncell)
resolution : 0.5, 0.5 (x, y)
extent : -1.5, 1.5, -1.5, 1.5 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
source : memory
names : layer
values : 0.1, 3.6 (min, max)
And apparently no attributes
-slot.
Whereas, when I use factorial values (copied from the amazing Lovelace et al. book) I get, what to my understanding is a Raster-Attribute-Table (RAT). So why is this?
class : RasterLayer
dimensions : 6, 6, 36 (nrow, ncol, ncell)
resolution : 0.5, 0.5 (x, y)
extent : -1.5, 1.5, -1.5, 1.5 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
source : memory
names : layer
values : 1, 3 (min, max)
attributes :
ID VALUE
1 clay
2 silt
3 sand
What exactly is this RAT and can raster
-objects really save just one value because in the end each cell can be references to a row in the RAT and thereby hold many values of different type?