Dhahi
October 24, 2019, 2:39am
1
Dear all,
How can I read kmls from subdirectories and write them into a new single folder? I tried to do that using a loop, but it didn't work.
setwd("old_dir")
ls = list.files()
for(i in ls){
rs=list.files(paste0(getwd(),"/",i),pattern="kml$",full.names=T)
my_data = lapply(rs, readOGR)
ss = list(my_data, makeUniqueIDs = T) %>%
flatten() %>%
do.call(rbind, .)
writeOGR(ss, dsn= "new_dir", layer="polygon", driver="KML")
}
cderv
October 24, 2019, 6:11pm
2
As we can't rerun your example, can you say what does not work exactly ?
Dhahi
October 25, 2019, 1:24am
3
After I create a list of polygons from different sub directories and specify new single directory, I use the writeOGR function to copy and paste each single polygon to the new directory, but it is only write one polygon to the new directory.
system
Closed
December 18, 2019, 5:24am
4
This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.