In general, the z coordinate of a LiDAR point within a LAS/LAZ file contains the absolute z value of the coordinate system used. For some operations such as classification (lasclassify) or canope metrics (lascanope) it is mandatory to specify the “height above ground” as an additional value for the calculations.
There have been several ways to achieve this so far. The first step was to classify the ground points using lasground or lasground_new. The second step was to calculate the height values above ground for each non-ground point., (“-replace_z“, “-store_in_user_data“, “-store_as_extra_bytes“ and “-store_precise_as_extra_bytes“).
Replacing the original z value only makes sense when working with an additional copy of the data, as the original z value is lost. Storing it in the user data and as an additional byte makes sense in most cases. However, in all further processes, care must be taken to use the corresponding field argument to process the data. Especially when the data contains more than one additional byte, this mechanism is not convenient:
:: input file analysis
lasinfo -i in.laz
lasinfo (240220) report for 'in.laz'
reporting all LAS header entries:
variable length header record 1 of 2:
user ID 'LASF_Projection'
...
variable length header record 2 of 2:
...
...
lasground_new64 -i in.laz
lasheight64 -i in.laz -o hei.laz -store_as_extra_bytes
:: we have to know that the new extrabyte is the 3rd within our data
lasclassify -i hei.laz -o cla.laz -height_in_attribute 3
This has been improved: the argument “-store_as_extra_bytes“ still needs to be set to add the argument as an additional field to the data. However, during further processing it no longer matters where the elevation data is stored.
The new argument “-z_from_attribute” helps to determine the height as a z value from the attributes. The name has been changed from „height_in_attribute“ because this change was made in the general LAS reader. This offers the possibility to generally replace the z value with the value in an attribute and for all LAStools. It is possible to define the attribute by specifying the attribute number as a parameter. If this parameter is not specified, LAStools will attempt to find the appropriate argument by looking for an attribute called “height above ground”. This is the name given to the attribute by lasheight.
For further simplification, the argument does not even need to be used in the tools that require LiDAR elevation values: lasclassify and lascanopy implicitly look for an attribute with the defined name and use that attribute field as the height value. The „-z_as_height“ argument can be used in rare cases to suppress this behavior.
The default workflow changed to the following commands:
lasground_new64 -i in.laz -o in_g.laz
lasheight64 -i in_g.laz -o in_hei.laz -store_as_extra_bytes
lasclassify -i in_hei.laz -o out_cla.laz
A verbose output informs about the z replacement:
autodetect extra_byte[1] as z
Since this feature is implemented in the general reader, this behavior can be used in all LAStools. The command below extracts all coordinates with height values as z into a text file and expects an attribute called “height above ground“:
las2txt64 -i in.laz -o out.txt -parse xyz -z_from_attribute