I'm trying to manipulate some downloaded rasters using R, and keep getting the same error when I try to do any type of map algebra.
The example below uses a raster file downloaded from http://www.csc.noaa.gov/digitalcoast/data/ccapregional/ geotiff and .grd files, regardless of whether I downloaded them or generated them previously.
require(raster) test1=raster("nh_2006_ccap_land_cover.img") test2=test1+1
Gives the error:
Error in matrix(unlist(ini), ncol = 2, byrow = TRUE) : 'data' must be of a vector type, was 'NULL' In addition: There were 11 warnings (use warnings() to see them)
On the other hand, I'm not encountering problems with map algebra for rasters generated on the fly. So I'm not having any problems with this example from the documentation:
r1 <- raster(ncols=10, nrows=10) r1 <- runif(ncell(r1)) r2 <- setValues(r1, 1:ncell(r1) / ncell(r1) ) r3 <- r1 + r2 r2 <- r1 / 10 r3 <- r1 * (r2 - 1 + r1^2 / r2) plot(r3)
What's going on here?