Monday, March 30, 2015

R - Selection of rows based on column criteria



Codes used to process LiDAR Original txt file.

Here you will see that the 5th column has 1's and 2's. This  code will consider rows with only 2's. 2's value represent ground points.

The sample file can be download from the below mentioned link.
Text file has 1'2 and 2's in the 5th column

Here is the R code...

rm(list=ls())

workDir <- "C:/Users/PKuranjekar/Desktop/Thumb drive/R/reneedyourhelpmann/"
setwd(workDir)

inData <- read.csv("Selection of rows2.txt", header=FALSE, sep=",", as.is=TRUE)

outData <- subset(inData, inData$V5=="2", select = V1:V3)

write.table(outData, "code2_output2.txt", sep=",", col.names=FALSE, row.names=FALSE)

No comments:

Post a Comment