I have a classified point cloud (.las file)
I would like to split it in several smaller point clouds, with respect to the classification values.
I can do it in a non-iterative way:
ground=xyz[np.where(xyz[:,6] == 2)]
header = laspy.header.Header()
x=ground[:,0]
y=ground[:,1]
z=ground[:,2]
intensity=ground[:,3]
return_num=ground[:,4].astype(int)
num_returns=ground[:,5].astype(int)
classification=ground[:,6].astype(int)
xmin = np.floor(np.min(x))
ymin = np.floor(np.min(y))
zmin = np.floor(np.min(z))
outfile = laspy.file.File(outFolder+"\classificationNumber2.las", mode="w", header=header)
outfile.header.offset = [xmin,ymin,zmin]
outfile.header.scale = [0.001,0.001,0.001]
outfile.x = x
outfile.y = y
outfile.z = z
outfile.intensity = intensity
outfile.return_num = return_num
outfile.num_returns = num_returns
outfile.classification = classification
outfile.close()
How can I modify the code to write point clouds for different classification values iteratively?
I believe the LAS specification tells you that the class of a point is stored on 5 bits. Meaning you can have at most 32 classes.
You can probably do something like that :
This code is a slightly modified version of the doc available here laspy doc on filtering
A "point" contains all the data associated to it. You don't need to filter each and every fields in your LAS file.