Lets say we have xyz points for several LiDAR files adjacent vertically and horizontally to each other
Here is the R code...
rm(list=ls())
workDir <- "J:/Thumb drive/Technical/GIS Exercise/Chapters/Chapter 14 - R by example in Statistics & Geospatial Analysis/R/reneedyourhelpmann/Incomplete/Row bind points file as per the txt file/"
setwd(workDir)
( p <- list.files(getwd(), pattern="pts$") )
ptdf <- read.table(p[1], header=FALSE)
names(ptdf) <- c("x","y","z")
p <- read.table("DataList.txt")
( p <- as.character(p[,1]) )
for(i in 2:length(p)) {
d <- read.table(p[i], header=FALSE)
names(d) <- c("x","y","z")
ptdf <- rbind(ptdf, d)
}
write.csv(ptdf, "FileName.csv", row.names=FALSE, quote=FALSE)
You can even write out a point shapefile, if so desired.
require(sp)
require(rgdal)
coordinates(ptdf) <- ~X+Y
writeOGR(ptdf, getwd(), "OutShape", driver="ESRI Shapefile")
No comments:
Post a Comment