I get an error message in a script that iterates over some text files in a directory, does some data manipulation and writes it to an ESRI shapefile using writeOGR from the rgdal package in R. I keep getting an error message after a certain number of files are written (about 43-44 separate files or ~ 14 full shapefiles, since each form file creates several files).
The error usually looks like
GDAL Error 4: Unable to open ./test_8.shp or ./test_8.SHP
Also, after the script crashes, I get an error like
cannot open file 'file_test.R': Too many open files
When I try to read or do something with another file.
showConnections
does not show open files at this moment.
Here is the code that reproduces the problem:
library(gstat) library(rgdal) data(meuse) coordinates(meuse) = ~x + y for (i in 1:50){ writeOGR(meuse,'.',paste('test',i,sep="_"),driver="ESRI Shapefile") }
I am using R 2.12.2 on OSX. The error occurs in both 64-bit and 32-bit versions.
source share