[R-sig-Geo] [RGDAL] Error with writeGDAL to pcraster maps (in a loop)

Philippe R philippe.roudier at jrc.ec.europa.eu
Tue Apr 15 12:12:36 CEST 2014


Hello everyone

My problem is the following : basically I need to pick up daily
precipitation data from a netcdf file (50000 days) to create 50000 pcraster
maps (one for each day). 
I am therefore doing a loop using RGDAL that looks like:

/for (d in 1:50000){

tget<-readGDAL("R:/mypath/target.map")   ##here I load my .map target file

tget at data<-new_data[d]    #I change the data (replacing with the on efrom
Netcdf)

writeGDAL(tget, fname=name_out,
drivername='PCRaster',type="Float32",mvFlag=-9999)   #export to .map files
}
/
This works well until d=509 (and outputs are perfectly fine) and then it
crashes, and I got the error message 

/Error in .local(.Object, ...) : Dataset copy failed
Calls: writeGDAL ... saveDataset -> new -> initialize -> initialize ->
.local -> .Call
/
The point is that if I start the loop at e.g. d=100, it crashes at 509+100.
So, it does not seem to be a problem of syntax.
So I suspect it may be a problem of memory (but I have enough disk space
left)….maybe I should close the connection everytime but GDAL.close(tget)
does not work 

/Error in slot(dataset, "handle") : 
  no slot of name "handle" for this object of class "SpatialGridDataFrame"
/
The very weird thing is that it happens when I run it on the cluster. If
doing it locally (windows), I have no problem when d=509…

Do you have any idea?

Best,




--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/RGDAL-Error-with-writeGDAL-to-pcraster-maps-in-a-loop-tp7586213.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list