Hi everyone,

I've been experiencing errors using the aggregate() raster function on
large files. It only seems to happen when using the expand=FALSE option.

The warning I get reads:

Warning message:
In .rasterFromRasterFile(grdfile, band = band, objecttype) :
  size of values file does not match the number of cells (given the data
type)

And most of the time the bottom rows of the resulting aggregated image
contains values that read -3.4e+38 (which to me is rather arbitrairy).

I'm running:
R version 3.0.1 (2013-05-16) -- "Good Sport"
Platform: x86_64-pc-linux-gnu (64-bit)
raster 2.1-37

Any clues on how to solve this would be appreciated. The error also seems
to be limited to large files > 5000 x 5000 pixels or so.

Best,
Koen


--------------
a copy of the example code:


> # aggregate error on large files
>
> # read image
> img <- mean(brick('/home/khufkens/virton.tif'))
> # show image info
> img
class       : RasterLayer
dimensions  : 10342, 10342, 106956964  (nrow, ncol, ncell)
resolution  : 0.7464698, 0.7464698  (x, y)
extent      : 611736.7, 619456.7, 6379237, 6386957  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
data source :
/tmp/R_raster_tmp/khufkens/raster_tmp_2013-07-01_142516_99728.grd
names       : layer
values      : 0, 213.3333  (min, max)

> # set window size
> windowsize <- 81

> zones <- aggregate(img,fact=windowsize,fun=mean,expand=TRUE,na.rm=TRUE)
> # show results info
> zones
class       : RasterLayer
dimensions  : 128, 128, 16384  (nrow, ncol, ncell)
resolution  : 60.46405, 60.46405  (x, y)
extent      : 611736.7, 619476.1, 6379218, 6386957  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
data source :
/tmp/R_raster_tmp/khufkens/raster_tmp_2013-07-01_142555_110676.grd
names       : layer
values      : 24.63222, 138.7439  (min, max)

> zones <- aggregate(img,fact=windowsize,fun=mean,expand=FALSE,na.rm=TRUE)
> # BAM!
Warning message:
In .rasterFromRasterFile(grdfile, band = band, objecttype) :
  size of values file does not match the number of cells (given the data
type)

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to