I'm using a for loop to read in multiple shapefiles within a directory and manipulate them individually. Presently I cannot do this because the for loop results in the error: "Error in readOGR(shp_paste) : length(dsn) == 1L is not TRUE". Not a single shapefile is read in; this error occurs immediately. I do not know what this means, and can only find a similar post with this error for writeOGR (link here). When I try to load the shapefiles individually into R Studio, I'm successful in doing so (though I haven't tried individually for all of them, there are too many). What could be causing this error? It's difficult to go through the files in the directory individually to identify potential problems because there are over 10,000. Below is my code:
library(rgdal)
input_path<- "/Volumes/Directory/data_folder/"
files<- list.files(input_path, pattern = "[.]shp$")
for(f in files){
ifile<- list.files(input_path, f)
shp_paste<- paste(input_path, ifile, sep = "")
shp1<- readOGR(shape_paste)
print("success!")
}
Running this code produces the error above.
shp_paste
and then reads fromshape_paste
. Please check your examples fail correctly before posting them - by which I mean it doesn't produce the error you say it does!