I have a 3D-LiDAR pointcoud repesenting a tree loaded into python with the laspy package. It is now stored as a numpy array. My purpose is to calculate the height of the tree by finding the point with the highest z-value and calculate the distance to the lowest z-value beneath it. So I imported the data via:
inFile = laspy.file.File("~/DATA/tree.las", mode='r')
point_records = inFile.points
At the moment, i calculated the height by:
min = inFile.header.min
max = inFile.header.max
zdist = max[2] -min[2]
The problem is that this way, i do not take slope in the terrain into account. How can i index the point that is exactly below the highest one?
This is just a blind guess, because for a good answer, there is a lot of information missing.
Suppose we have an array of 3 points with (x,y,z)
A = [1,2,3]
B = [1,2,4]
C = [0,1,2].
We have identified point A as being the maximum in z and have its lat and long with
Basically, you go through the list of point and filter out all the points, you want to look at, and take the minimal point. Below is a straightforward way to do that, using a for-loop. This is not ideal for speed.
np.where()
and fancy indexing can be used, to do that easier and faster, but this is more readable and adjustable: