I have two raster layer, the first one r is my zonal mask as a raster grid, and I created as:
ext <-extent(Yraster)
r <- raster(nrows=32,ncols=32,ext)
r[] <-(1:ncell(r))
and project it as the 'Yraster' one
projection(r)<-"+proj=utm +zone=19 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
> r
class : RasterLayer
dimensions : 32, 32, 1024 (nrow, ncol, ncell)
resolution : 428.465, 430.3401 (x, y)
extent : 346090.2, 359801.1, 8783943, 8797714 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=19 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 1, 1024 (min, max)
> Yraster
class : RasterLayer
dimensions : 459, 457, 209763 (nrow, ncol, ncell)
resolution : 30.00192, 30.00192 (x, y)
extent : 346090.2, 359801.1, 8783943, 8797714 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=19 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : acre_2010_non1
values : 1, 1 (min, max)
Raster Attribute Table
fields : ID Rowid COUNT
min : 1 0 13821927
max : 1 0 13821927
but when I do the zonal statistics, an error pop out:
> list <- zonal(Yraster,r, na.rm=TRUE)
Error in compare(c(x, z)) : ncols different
How can I make the zonal statistics work?
