Thursday, January 22, 2015

R - Copy out selected LiDAR files into a different folder

Before this, Please refer to the post "LiDAR file Processing in R, C#, MS-DOS, ArcGIS & LAStools"

Once you export the selected attributes into a text file. Then open a text file in a text pad and save that particular column in different text file.


Manually, it will be very difficult to copy out selected files of 2548 files. Here is the R program which helps to copy out all these selected files into a separate folder automatically.

work_dir <- "K:/Resource Info/20140312_CHSTP-Backersfield to Palmdale/Rasters/LIDAR/From_GeoDigital_July_2012/"
setwd(work_dir)

las_file_nos <- readLines("Selected_LAS.csv")
las_file_nos <- paste0(las_file_nos)

las_file_names <- list.files("LAS/", pattern = "BP_")

las_present <- las_file_nos %in% las_file_names

for (eachFile in 1:length(las_present)) {
  if (las_present[eachFile]) {
    file.copy(paste0("LAS/", las_file_nos[eachFile]), 
              "LAS/Output folder/")
  }
}




No comments:

Post a Comment