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.


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)

What's going on here?

  • 1
    What did the warnings say? Have you at least been able to plot the raster dataset?
    – whuber
    Commented Jul 24, 2014 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. Commented Jul 24, 2014 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
    Commented Nov 9, 2015 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
    Commented Nov 9, 2015 at 16:58

1 Answer 1


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
    Commented Jul 20, 2018 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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