I have begun learning how to manipulate LAS data in python and wanted to see how others handle LAS files. I would like to read the points (I am using a numpy array), and filter out classes 1 and 2 (unclassified and ground) to a separate array. I have the following code but cannot seem to get the points filtered.
# Import modules
from liblas import file
import numpy as np
if __name__=="__main__":
'''Read LAS file and create an array to hold X, Y, Z values'''
# Get file
las_file = r"E:\Testing\ground_filtered.las"
# Read file
f = file.File(las_file, mode='r')
# Get number of points from header
num_points = int(f.__len__())
# Create empty numpy array
PointsXYZIC = np.empty(shape=(num_points, 5))
# Load all LAS points into numpy array
counter = 0
for p in f:
newrow = [p.x, p.y, p.z, p.intensity, p.classification]
PointsXYZIC[counter] = newrow
counter += 1
I have seen arcpy.da.featureClassToNumpyArray, but I did not want to import arcpy nor have to convert to shapefile.
How else can I filter/read LAS data into a numpy array?