Hi to the R community!
I'm a new R user and after hours of searching how to do, I hope you would help me to solve my problem and understand where is/are the mistake(s).
So, I have Lidar data from the french Litto3D programm. I need to use twelve tiles to produce a Digital Field Model using several kind of interpolation (I'm gonna compare the different ways of interpolation). For that, I begin to use Surfer because of the height of the data and to transfer the method to my colleagues and to everyone who would need it.
What I did and what I tried to do : To begin, I changed the file extension of the XYZ files (which contain the XYZ Lidar points) and I used a code to charge the 12 tiles in R. It seems to have worked but now I want to give a name to the colums of all my files in the same time (because they do not have any name at the moment), and this is exactly the point where it doesn't work anymore. I have an error which appears : "Error during wrapup: 'file' must be a character string or connection"
The entire code :
List.filesxyz = list.files("Donnees_pour_tests",pattern = ".xyz",recursive=F,full.names = T)
xyztest=List.filesxyz
old_filenames <- List.filesxyz
new_filenames <- replace_extension(List.filesxyz,"txt")
file.rename (old_filenames,new_filenames)
List.filestxt = list.files("Donnees_pour_tests",pattern = ".txt",recursive=F,full.names = T)
csvtest=List.filestxt
old_filenames <- List.filestxt
new_filenames <- replace_extension(List.filestxt,"csv")
file.rename (old_filenames,new_filenames)
setwd("C:/Mydirectory/Rspatial2018/data/Donnees_pour_tests")
list.files(pattern=".csv$")
list.filenames<-list.files(pattern=".csv$")
list.filenames
list.data<-list()
for (i in 1:length(list.filenames))
{
list.data[[i]]<-read.csv(list.filenames[i])
}
names(list.data)<-list.filenames
list.data[1]
import.multiple.csv.files<-function(mypath,mypattern,...)
{
tmp.list.1<-list.files(mypath, pattern=mypattern)
tmp.list.2<-list(length=length(tmp.list.1))
for (i in 1:length(tmp.list.1)){tmp.list.2[[i]]<-read.csv(tmp.list.1[i],...)}
names(tmp.list.2)<-tmp.list.1
tmp.list.2
}
csv.import<-import.multiple.csv.files("C:/Mydirectory/Rspatial2018/data/Donnees_pour_tests/",".csv$",sep=" ", dec=".")
save(import.multiple.csv.files,file="C:/Mydirectory/Rspatial2018/data/Donnees_pour_tests/")
data = read.csv(list.data,header=FALSE,sep=" ", dec = ".")
setnames(data, old=c("V1","V2","V3", "V4", "V5", "V6"), new=c("X","Y","Z","Classe","Intensite_signal_retour","Temps_GPS_absolu"))
}
I wish you could help me. I'm still going to find he solution on the web :) Thx a lot! Ally