Hi R Users,

I commonly import multiple .csv files and then write loops to work with those 
files like this:

>setwd('C://Nathaniel/R/allfiles')
>files<-list.files()
>allfiles<-lapply(t1,read.csv)
>for (i in 1:47) {
>     t1<-allfiles[[i]]

etc. etc.

I have written a script that I would like to loop to work with a folder of 400+ 
.shp files.  Is there an equivalent way to read in all the shapefiles so that I 
can run a loop?

I tried this:

>setwd('C://Nathaniel/R/shapefiles')
>t1<-list.files()
>t2<-lapply(t1,readShapePoly)

which returned this error:

"Error in Fun(c("shape1.dbf", "shape1.prj", "shape1.sbn", "shape1.sbx", :
   missing layer"

and I tried this:

>setwd('C://Nathaniel/R/shapefiles')

>t1<-list.files()

>t2<-lapply(t1,readOGR)

which returned this error:

"Error in getinfo.shape(filen) : Error opening SHP file"


I've searched the archives and wasn't able to find anything like this.  My 
understanding of R code is rudimentary, so any help would be greatly 
appreciated.  Thanks for considering my problem.

Best regards,

Nathaniel
                                          
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to