[R-sig-Geo] Raster crosstab output: -1 values?

Megan Evans megan.evans at anu.edu.au
Thu Dec 20 00:03:13 CET 2012


Hi everyone,

I'm computing a very large crosstab analysis (using the raster package) for
around 700 tiles of 25m resolution vegetation raster data. Essentially, I
want to figure out how much forest is contained within each land use, land
tenure and jurisdictional boundary (eight Australian States) over a 39 year
time period (20 years with data). 

The land tenure, land use and State layers have all been cut up into the
same extent, resolution and projection as the forest cover data. I then
create a raster stack of the forest cover, State and land tenure-use (the
latter was combined into one raster layer) tiles, and subsequently a
crosstab. This process is repeated for each tile and year (~700 loops,
taking a rather long time). The forest cover data (in this particular year -
1972) has values of only 0 and 1 (non-forest/forest). However, I'm finding
in some cases the crosstab output contains data in a "-1" category, despite
this value not being part of the original forest cover data. 

I'm at a loss to explain this; all datasets have the same number of cells,
resoluton, and no missing data. Would really appreciate any insights!

Cheers, Megan

Data details below:

Forest Cover (ttile):
class       : RasterLayer 
dimensions  : 16000, 28360, 453760000  (nrow, ncol, ncell)
resolution  : 0.00025, 0.00025  (x, y)
extent      : 112.91, 120, -28, -24  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs 
data source :
D:/Analysis/R/Data/forestextent_reg/forest_v8_72_11/sg50/forst72.grd 
names       : layer 
values      : 0, 1  (min, max)
Raster Attribute Table
     fields : ID     COUNT
        min :  0  30065009
        max :  1 423694991

State (st_tex):
class       : RasterLayer 
dimensions  : 16000, 28360, 453760000  (nrow, ncol, ncell)
resolution  : 0.00025, 0.00025  (x, y)
extent      : 112.91, 120, -28, -24  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs 
data source : D:/Analysis/R/Data/sttiles/forest_v8_72_11/stsg50.grd 
names       : states_p 
values      : 8, 8  (min, max)

Land Use/Tenure (lu_ten_tex):
class       : RasterLayer 
dimensions  : 16000, 28360, 453760000  (nrow, ncol, ncell)
resolution  : 0.00025, 0.00025  (x, y)
extent      : 112.91, 120, -28, -24  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs 
data source : D:/Analysis/R/Data/lutentiles/forest_v8_72_11/lutensg50.grd 
names       : lu_ten 
values      : 1, 73  (min, max)
Raster Attribute Table
     fields : ID       COUNT
        min :  1 -1816924096
        max : 73  1681761600

Relevant code:
# Create raster stack between forestextent, lu and state
        x <-stack(ttile, lu_ten_tex, st_tex)
        
        #Crosstab will calculate the frequency of each level (0=non-forest,
1=primforest, 2=regforest) in each land use/tenure/state
        vegfreq <-crosstab(x, digits=0, long=FALSE, progress="text")

> vegfreq
, , states_p = 8

     lu_ten
layer         0         1         3        11        13        61        63       
33
   0     400975   2059222   2355223  28336430  13144612   2565663 316999241    
42855
   1      15814      1098     19824   6497248   3958995    761517  17902798      
345
   -1        11      1280       153      3522       393        20     15961        
0
     lu_ten
layer        43        73        23        53        71        51        12       
22
   0       8447     16777     64401     50205     19375     17463    334230   
664199
   1       1153      7223     66799       995     31825       137    396970   
126201
   -1         0         0         0         0         0         0         0        
0
     lu_ten
layer        62         2        32
   0     310439      1586     13062
   1     201561        14      2938
   -1         0         0         0




--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Raster-crosstab-output-1-values-tp7582028.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list