[R-sig-Geo] GDAL.close

Roger Bivand Roger.Bivand at nhh.no
Fri Nov 1 09:41:18 CET 2013


On Mon, 28 Oct 2013, Oliver Soong wrote:

> 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.

Could you please provide a working example? I have looked at this, but 
need a baseline to know whether I'm looking at the same thing. I'm very 
unsure that this is a robust solution, and need an instrumented example, 
including listings of the temporary directory during the process, to see 
the consequences. Thanks for looking into this, but I'd prefer to be sure 
that a Windows-specific fix doesn't make things worse for others too. 
Please also report on the source of your Windows rgdal binary - is it from 
CRAN or locally built dynamically linking your own GDAL?

Best wishes,

Roger

>
> Cheers,
> Oliver
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list