6

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?

  • 1
    What did the warnings say? Have you at least been able to plot the raster dataset? – whuber Jul 24 '14 at 21:40
  • 2
    The warnings seem to be a bunch of repetitions of "In writeBin(v, x@file@con, size = x@file@dsize) : problem writing to connection" Ok, this is almost certainly related to the fact that I seem to have eaten up all of the storage space on my hard drive. Now I have a different thing to troubleshoot. I'll come back and close this if resolving the disk space issue solves it. – user1521655 Jul 24 '14 at 21:47
  • I have the same issue when I run remotely in parallel in a linux supercomputer. Did you figure out how to solve the issue? – user62070 Nov 9 '15 at 16:09
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – Kersten Nov 9 '15 at 16:58
9

The problem was that I had run out of space to write to disk, and the map algebra commands I was using were attempting to generate and write large temporary raster files.

  • but your answer is not exactly a solution because large temporary rasters still need to be used. – csheth Jul 20 '18 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.