How do i convert a las file into a txt (or csv) file in python?

825 Views Asked by At

As the title suggested, how can i convert a .las file in a .txt or .csv file? Does laspy library do that?

Someone suggested to use pdal (.LAS into a .CSV file using python) but it is not clear how to do that

1

There are 1 best solutions below

0
On

Solved in this way:

inFile = laspy.file.File(inputFile, mode='r')
test = np.vstack((inFile.x, inFile.y, inFile.z, inFile.raw_classification)).transpose()

with open(outFolder+"\\test.txt", mode='w') as f:
for i in range(len(test)):
    f.write("%f    "%float(test[i][0].item()))
    f.write("%f    "%float(test[i][1].item()))
    f.write("%f    "%float(test[i][2].item()))
    f.write("%d    \n"%int(test[i][3].item()))