[R-sig-Geo] GDAL.close
Oliver Soong
osoong+r at gmail.com
Mon Oct 28 06:03:21 CET 2013
I've had a long standing struggle with GDAL.close on Windows, and I
think I might finally have found a fix. I'm currently running rgdal
0.8.11, R 3.0.2, and 32-bit Windows 7.
Currently, writeRaster and writeGDAL create temporary files in the
tempdir() folder (the final filename prefixed with 3 random [a-z]
letters). On my system, these files get left open and orphaned. When
doing heavy processing, this can lead to the drive hosting the
tempdir() folder to become full, even if the data is being ultimately
written to a much larger drive. This also means that R cannot clean
up these files or the tempdir() folder when it closes, causing similar
bloat in my %TEMP%.
I haven't tested this on other platforms, but I think it might help to
insert an extra line into GDAL.close:
.setCollectorFun(slot(dataset, "handle"), NULL)
.Call("RGDAL_CloseHandle", dataset at handle, PACKAGE = "rgdal")
.Call("RGDAL_CloseDataset", dataset, PACKAGE = "rgdal")
For whatever reason, RGDAL_CloseDataset doesn't seem to actually close
the C file handle, but it doesn't seem to mind if the file handle was
closed beforehand.
Cheers,
Oliver
More information about the R-sig-Geo
mailing list