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")
}