Skip to content

Show differences between categorical maps

1 message · Thiago V. dos Santos

#
? Dear colleagues,

? I have two rasterbrick objects which are categorical maps, ranging from 1 to 15 (only integer numbers). Each value represents a vegetation class (tropical forest, boreal forest, savanna, grassland etc). Each brick layer represents a year which ranges from 1605 to 2005. There are lots of NA values, specially over the ocean (as the data is distributed only over land). Please see the objects below:
class ? ? ? : RasterBrick?
dimensions ?: 83, 85, 7055, 401 ?(nrow, ncol, ncell, nlayers)
resolution ?: 0.5, 0.5 ?(x, y)
extent ? ? ?: -75, -32.5, -35, 6.5 ?(xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84?
values ? ? ?: /home/thiago/Dropbox/web/vegtype_fix_co2.nc?
layer names : X1605.01.01, X1606.01.01, X1607.01.01, X1608.01.01, X1609.01.01, X1610.01.01, X1611.01.01, X1612.01.01, X1613.01.01, X1614.01.01, X1615.01.01, X1616.01.01, X1617.01.01, X1618.01.01, X1619.01.01, ...?
Date ? ? ? ?: 1605-01-01, 2005-01-01 (min, max)
varname ? ? : vegtype0?
class ? ? ? : RasterBrick?
dimensions ?: 83, 85, 7055, 401 ?(nrow, ncol, ncell, nlayers)
resolution ?: 0.5, 0.5 ?(x, y)
extent ? ? ?: -75, -32.5, -35, 6.5 ?(xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84?
values ? ? ?: /home/thiago/Dropbox/web/vegtype_dyn_co2.nc?
layer names : X1605.01.01, X1606.01.01, X1607.01.01, X1608.01.01, X1609.01.01, X1610.01.01, X1611.01.01, X1612.01.01, X1613.01.01, X1614.01.01, X1615.01.01, X1616.01.01, X1617.01.01, X1618.01.01, X1619.01.01, ...?
Date ? ? ? ?: 1605-01-01, 2005-01-01 (min, max)
varname ? ? : vegtype0?

? Rasters are available here (22MB each file): https://www.dropbox.com/s/9re75op7dewo2vl/vegtype_fix_co2.nc and https://www.dropbox.com/s/f06vhtl1kfq2zb2/vegtype_dyn_co2.nc.

? First raster is my projected vegetation map and the second raster is an experimental one, which I created by crossing the first raster with deforestation data. My goal is to investigate the impact of deforestation data on the vegetation map. What I would like to do to achieve this goal is:?

? ?a) for each year, count the proportion (relative frequency) of each category in both rasters. Then, I would like to subtract the proportions of each class in the second raster the proportions of each class in the first raster across the years and plot this difference as lines (one for each class) over time;

? ?b) find a way to, in each year, when comparing one raster to the other, detect and account for the transition between classes (FROM which class the map changed). For example, pixel (1,1) of first raster in first year is "1". The same pixel, in the same year, in raster two, is "2". Then, we have one transition FROM class 1. How to count ALL transitions FROM class1?

? Any help would be very appreciated. Although this is a very odd problem, I am sure its solution feasible with R. I just need some help and/or ideas! There might be a "ready" technique to display this kind of categorical information, but this is really what I have in mind...
??
? Many many thanks in advance,
? Thiago.