1

This is the error message:

"In writeBin(v, x@file@con, size = x@file@dsize) : problem writing to connection 6: In .rasterFromRasterFile(grdfile, band = band, objecttype) : size of values file does not match the number of cells (given the data type)"

I have 15 raster files of the same extent and dimension. I just want to find out the Correlation of this data across time (15 years) ie 15 raster files.

I used the script below:

list  <- c(list.files(pattern = "\\.tif$"))
y <- stack()
for  (i in 1:length(list)){
y <- stack(y,list[i]) }
corT <- layerStats(y, 'pearson', na.rm=TRUE)

OR Used the stacked file directly like this

test = brick ("EOS_ALL_STACK.tif")

corT = layerStats(test, 'pearson', na.rm=TRUE)

I also tried to use this function to get correlation coefficients and r squared like this

fun5=function(x) { if (is.na(x[1])){ NA } else { m <- lm(x[1:15] ~ c(1:15));summary(m)$coefficients[1,4]}} #fstatistic[1]
fun5=function(x) { if (is.na(x[1])){ NA } else { m <- lm(x[1:15] ~ c(1:15));summary(m)$coefficients[2,4]}} #fstatistic[2]
fun3=function(x) { if (is.na(x[1])){ NA } else { m <- lm(x[1:15] ~ x[1:15]);summary(m)$r.squared }}

then used "calc" to calculate these across all pixels. For example:

r.squared <- calc(y, fun3)

However, my results still has the above errors and even when there is an output, it does not seem to make sense.

Tyruno
  • 25
  • 1
  • 8
  • Can you give a reproducible example? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Hack-R Jun 24 '16 at 03:07
  • Is your disk full? – Robert Hijmans Jun 24 '16 at 04:35
  • I really have been trying to do this. My files are very large images of the entire African continent. I have been able to have really abridged version of them but still can't find a way to reproduce them here. Any tips please? – Tyruno Jun 24 '16 at 04:44
  • Disk full you mean my computer hard disk space? – Tyruno Jun 24 '16 at 04:45
  • Yes. Probably the disk of your temp folder. That would explain the "problem writing" – Robert Hijmans Jun 24 '16 at 04:47
  • hmmmmmm...Interesting. I have been having issues with that. It shows I do not have any more available space, but I do not have any of my data stored on my C drive and also can't see of find what's in it, because I work from my external hard drive. Although softwares are installed on my computers C drive. – Tyruno Jun 24 '16 at 04:54

1 Answers1

3

This error message:

writeBin(v, x@file@con, size = x@file@dsize) : problem writing to connection

Most likely indicates that your disk is full. This could be the disk of your working directory, or anywhere else you are writing a file. If you are not specifying a filename, you can check tempfile() to find the general location where temporary files are stored (the actual folder changes between sessions). You can change this via rasterOptions(). You can also avoid writing temporary files by providing a filename= argument to the raster functions.

Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63