0

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?

Bob
  • 11
  • 1
  • Just use the euclidean distance between two points? – Dschoni Feb 14 '17 at 12:46
  • thts what i want to do but i have problems finding these points. I updated the question. – Bob Feb 16 '17 at 07:42
  • So, basically this is not a numpy question, but more a question how your data looks like. Can you explain the format a little? – Dschoni Feb 16 '17 at 10:49
  • And furthermore: What do you mean by "beneath"? Perpendicular to world coordinates or along the surface normal of the plane under the highest point? – Dschoni Feb 16 '17 at 10:58
  • The data is stored as a numpy array with three columns representing longitude, latitude and meters above sealevel (xyz). With beneath i mean the lowest z point that has the same long/lat values as the highest z point, to make sure i only calculate the actual height of the tree. – Bob Feb 18 '17 at 13:31

1 Answers1

0

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

lat = 1
long = 2

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:

import numpy as np
# This is some test data, with three data points
a = np.array([[1,2,3],[1,2,4],[0,1,2]])
# Now we define the lat and long we want to get
filter_x = 1
filter_y = 2
filtered_points = []
for i in range(a.shape[0]): # iterating through all points
    if a[i][0] == filter_x and a[i][1] == filter_y: 
        filtered_points.append(a[i][2]) # Append z of point to list
print min(filtered_points) # print minimum
Dschoni
  • 3,714
  • 6
  • 45
  • 80