I am trying to find points in a LAS file (Lidar format):
Right now I am doing it the really slow way:
from laspy.file import File
import numpy as np
inFile = File('inputfile.las', mode='r')
coord = np.vstack((inFile.x, inFile.y, inFile.z)).transpose()
def find_pt(coord, x, y, z):
found = []
for i in coord:
if(i[0] >= x and i[0] < x+1):
if(i[1] >= y and i[1] < y+1):
if(i[2] >= z and i[2] < z+1):
found.append(i)
return found
Then I call it with:
find_pt(coord, 358397, 5280527, 550)
Which of course takes some time, especially when there are a lot of points in the file.
Is there a better/faster way? coords
is of type numpy.ndarray
I don't know las or laspy, but if
inFile.x
& friends are separate numpy arrays (judging from thevstack
call), you could simply use and compare them separately, then combine the results:The resulting
found
is slightly different, as it is a tuple of x, y and z coordinate arrays for valid point(s).