Problm with CHM pit-free script

202 views
Skip to first unread message

Krošelj Tina

unread,
Jun 4, 2016, 1:32:54 PM6/4/16
to last...@googlegroups.com
Hello,

I am new to programing and scripts. How can I put more than one input
file working with .bat script file? I can not figurate it out. I tray
with *laz, but seems not working at all. Every try I got same error:
no input specified ...

It works with .bil files at the end, but not with normalized one at
the beginning. Can anyone please enlighten me, what I am doing wrong?

It would be very helpful if anyone can rescue me ;)

Thank you very very much!!

BR, Tina

Script with my parameters:

:: allows you to run the script from other folders
set PATH=%PATH%;E:\LAStools\LAStools\bin;

:: here we specify the input (already height-normalized)
set NORMALIZED_LIDAR=E:\LAStools\LAStools\test\klas_height\height_first2345_drop100\poskuszvectile

:: specify the desired resolution
set STEP=0.3

:: specify the radius of the laser beam
set BEAM_RADIUS=0.1

:: specify the sub-resolution for the beam file (about half the step or less)
set SUB_STEP=0.15

:: specify the desired triangle kill (about 3 times the step)
set KILL=1

:: specify a temporary directory for the beam file and the partial CHMs
set TEMP_CHM_DIR=E:\LAStools\LAStools\test\klas_height\height_first2345_drop100\poskuszvectile\temp_chms

:: specify the temporary beam file
set BEAM_LIDAR=%TEMP_CHM_DIR%\beam.laz

:: specify the final output CHM file name and format
set PIT_FREE_CHM=D:\rezultati\chm1_5_4t.tif

rmdir %TEMP_CHM_DIR% /s /q
mkdir %TEMP_CHM_DIR%

pause
::
:: do the actual processing
::
las2dem -i %NORMALIZED_LIDAR%\*laz ^
-drop_z_below 0.1 ^
-cores 3
-step %STEP% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _ground -obil

lasthin -i %NORMALIZED_LIDAR%\*laz ^
-highest ^
-step %SUB_STEP% ^
-subcircle %BEAM_RADIUS% ^
-o %BEAM_LIDAR%

blast2dem -i %BEAM_LIDAR% ^
-cores 3
-step %STEP% ^ -kill %KILL% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _00 -obil

blast2dem -i %BEAM_LIDAR% ^
-drop_z_below 2 ^
-cores 3
-step %STEP% ^ -kill %KILL% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _02 -obil

blast2dem -i %BEAM_LIDAR% ^
-drop_z_below 5 ^
-cores 3
-step %STEP% ^ -kill %KILL% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _05 -obil

blast2dem -i %BEAM_LIDAR% ^
-drop_z_below 10 ^
-cores 3
-step %STEP% ^ -kill %KILL% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _10 -obil
pause

blast2dem -i %BEAM_LIDAR% ^
-drop_z_below 15 ^
-cores 3
-step %STEP% ^ -kill %KILL% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _15 -obil

:: this would be sufficient for forests with tree heights
:: of up to about 20 meter. maybe delete higher up steps

blast2dem -i %BEAM_LIDAR% ^
-drop_z_below 20 ^
-cores 3
-step %STEP% ^ -kill %KILL% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _20 -obil

blast2dem -i %BEAM_LIDAR% ^
-drop_z_below 25 ^
-cores 3
-step %STEP% ^ -kill %KILL% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _25 -obil
pause

blast2dem -i %BEAM_LIDAR% ^
-drop_z_below 30 ^
-cores 3
-step %STEP% ^ -kill %KILL% ^
-elevation -use_tile_bb ^
-odir %TEMP_CHM_DIR% -odix _30 -obil

:: merge partial CHMs together into pit-free CHM

lasgrid -i %TEMP_CHM_DIR%\*.bil -merged ^
-cores 3
-step %STEP% -highest ^
-elevation -use_tile_bb ^
-false -set_min_max 0 30 ^
-o %PIT_FREE_CHM%
pause

:: remove the temporary files and directory ćč

rmdir %TEMP_CHM_DIR% /s /q

echo "bye bye"

pause

--
Tina***

David Brubacher

unread,
Jun 5, 2016, 12:51:43 PM6/5/16
to LAStools - efficient tools for LiDAR processing
Hi Tina

it looks like it might be as simple as changing '*laz' to '*.laz'. Note the dot after the star.

Krošelj Tina

unread,
Jun 6, 2016, 10:59:33 AM6/6/16
to last...@googlegroups.com
David,

thank you a lot to reply, but it wasn't that. I tried, and still doesn't work :/ It is maybe something with not setting the directory of the input right?

Thank you for help!

BR, Tina 

Krošelj Tina

unread,
Jun 6, 2016, 11:00:57 AM6/6/16
to last...@googlegroups.com
I manged to solve it :) :) but I have one another question ... as I told before, I use batch script from example_batch_scripts  lastool folder, but do not understand why after 20 m the error  no input points is reported. I checked and max z-values on my research space is 30,49 m.

Thank you for help once more

BR, Tina



--
Tina***

David Brubacher

unread,
Jun 6, 2016, 12:00:02 PM6/6/16
to LAStools - efficient tools for LiDAR processing
Hi Tina

It's very difficult to diagnose the problem without more information.

Can you please tell us how you solved the earlier problem and supply any other warnings or messages that are occurring.

When you say 'after 20m' I assume you mean after 
blast2dem -i %BEAM_LIDAR% ^
          -drop_z_below 20 ^
          -cores 3
          -step %STEP% ^ -kill %KILL% ^
          -elevation -use_tile_bb ^
          -odir %TEMP_CHM_DIR% -odix _20 -obil
which means the problem is occurring at
blast2dem -i %BEAM_LIDAR% ^
          -drop_z_below 25 ^
          -cores 3
          -step %STEP% ^ -kill %KILL% ^
          -elevation -use_tile_bb ^
          -odir %TEMP_CHM_DIR% -odix _25 -obil

If that is correct, then the '-drop_z_below 25' argument is dropping all of your points leaving none for blast2dem to work with. Simply comment out the 25m and 30m operations by preceding them with a double colon (::) or the REM command. Note that REM is the correct way to do it because the :: sequence can be misinterpreted sometimes. Also note the ^ is a line continuation character, so if you put REM in front of blast2dem without ALSO putting it in front of the other arguments on the following lines, your script will fail.

The best way to diagnose scripts like this is to manually enter the commands on the command line, one-by-one, to see where things go bad. You can also use the ECHO command to print information to the screen or redirect it to the file, but I will have to leave that for your own research.

Regards, D

Krošelj Tina

unread,
Jun 8, 2016, 6:00:24 AM6/8/16
to last...@googlegroups.com
David,

thank you very much, you have been most helpful.

For the question about more inputs - you were actually right, it was only problem in forgetting to put the dot. But as I try so many times, I thought that I correct it on some other way :)

And I have one more question:

How can it be, that lasgrid merge the .bil files, if the tool read only LAS/LAZ/ASCII and then grids them? As I try to do every step of the script (pit-free CHM) separately, the last step is some kind of mistery for me. It doesn't happen anything. I laso have unlicense program, but could be this a problem here?

Why I am asking this and why I am decided to do the script in steps is that I got really bad CHM after running the script, with a lot of pits - a lot more, if as done it without the partial CHMs. So maybe is catch in lasgrid? I don know.

Thank you for help once more!

BR, Tina



Martin Isenburg

unread,
Jul 22, 2016, 10:45:35 AM7/22/16
to LAStools - efficient command line tools for LIDAR processing
Hello,

How can it be, that lasgrid merge the .bil files, if the tool read only LAS/LAZ/ASCII and then grids them? As I try to do every step of the script (pit-free CHM) separately, the last step is some kind of mistery for me. It doesn't happen anything. I laso have unlicense program, but could be this a problem here?

In general you may be better advised to use a *real* raster processing tool such as GDAL or GDAL via QGIS to merge your rasters into one. However, lasgrid can also do that as BIL / ASC / DTM rasters can be read by *any* of the LAStools "as if" they were points. It simply uses the center coordinate of each grid cell as x / y coordinates and the value of the grid cell as the z coordinate. However, it is important that you tell lasgrid what resolution to use to produce the output raster. In other words the '-step 0.25' must be identical to the pixel size of your input BIL / ASC / DTM rasters.


Why I am asking this and why I am decided to do the script in steps is that I got really bad CHM after running the script, with a lot of pits - a lot more, if as done it without the partial CHMs. So maybe is catch in lasgrid? I don know.

There are many places to make mistakes in creating pit-free CHMs. The most usual place is to (a) forget to normalize, (b) use the wrong -kill, and (c) use the wrong set of partial CHMs. If you have not solved this by now then the only way for us to help you is to send us a link to one of the normalized LAZ tiles that you are trying to generate a pit-free CHM for ...


Or try out our new method:


Regards,

Martin @rapidlasso

Message has been deleted

Martin Isenburg

unread,
Feb 12, 2018, 4:58:34 AM2/12/18
to LAStools - efficient command line tools for LIDAR processing
Hello Lily.

What value to use as the "kill" value in the CHM algorithm. There are two way to think about this. First, what is the smallest possible value you should put there? This has to do with the spacing between your pulses. The value should be such that it is larger than most of your pulse spacings. The usual way to compute an approximate spacing between pulses is by constructing a Delaunay TIN from all the last returns and then looking at the edge lengths of that TIN. A histogram of edge lengths (you can compute this with las2tin) gives you a good idea what value to use. Use a value high enough such that it is larger than 95 percent to 99 percent of all edges reported in the histogram. Here an example:

E:\LAStools\bin>las2tin -i ..\data\sample.laz -keep_last -histo_only edge_length 0.25
edge length histogram histogram with bin size 0.25
  bin [0,0.25) has 109555
  bin [0.25,0.5) has 145743
  bin [0.5,0.75) has 59046
  bin [0.75,1) has 4903
  bin [1,1.25) has 1015
  bin [1.25,1.5) has 366
  bin [1.5,1.75) has 112
  bin [1.75,2) has 73
  bin [2,2.25) has 41
  bin [2.25,2.5) has 27
  bin [2.5,2.75) has 22
  bin [2.75,3) has 17
  bin [3,3.25) has 18
  bin [3.25,3.5) has 22
  bin [3.5,3.75) has 20
  bin [3.75,4) has 12
[...]
  bin [21.25,21.5) has 2
  bin [27,27.25) has 1
  average edge length histogram 0.350882815199769 for 321119 element(s)

When we get to around a length of somewhere between 1.0 and 1.25 then most of the 321119 edges are included. Note that this is similar to three times the average edge length of 0.35. This value is also similar to what is computed as an approximate last return spacing by lasinfo

E:\LAStools\bin>lasinfo -i ..\data\sample.laz -nh -nv -nr -nmm -cd
lasinfo (180209) report for ..\data\sample.laz
covered area in square units/kilounits: 9996/0.01
point density: all returns 15.05 last only 10.71 (per square units)
      spacing: all returns 0.26 last only 0.31 (in units)

So you should not use a kill any smaller than 1.0. I would try a few values between 1.0 and 1.5. If you make it much bigger then you will start loose sub-crown structure and start connecting crowns. However, if you decide to raster a rather coarse CHM of maybe 2 meter cells or even 5 meter cells then (a) maybe using lasgrid with option highest or lascanopy with percentiles are better suited or (b) you should increase your kill further because it will then also do some form of "down-sampling" or "low-pass filtering" that can help to avoid aliasing effects (the Nyquist sampling theorem says "Hello"). Finally, also have a look at the reasoning here:


Why I always use a kill for all partical CHMs now? Anytime we are interpolating across areas where we do not have any LiDAR returns that are flanked by high canopy returns on both sides we make a big error. Look at the gridded image and the interpolated image that are attached. There is an area without LiDAR points. In the area circled a "fake" canopy is created because the TIN is interpolating canopy returns across a small wet area without any returns.

This is why I always use a kill for the CHM rasterization step when I am interpolating canopy points. To fill the holes you can simply use zero (in case of a pit-free CHM) or the raster value from the DTM (in case of a pit-free / spike-free DSM). Also have a look at this more recent spike-free algorithm in LAStools for generating pit-free CHMs (and DSMs).


Regards,

Martin

On Thu, Jan 25, 2018 at 11:06 AM, Lily G. <lily...@gmail.com> wrote:
Hello,
I'm also new on this topic and I'm trying to follow the algorithm in ArcMap

One question is related when I want to create the "general CHM": What value do I need to put in "KILL triangles with edges longer than" ? in some other codes that I saw, they put the same value like for the partial CHM " STEP = 0.5  KILL= 1.5 " and others, don't include anything, like in the   "generating_a _pit_free_chm.bat" example

blast2dem -i %NORMALIZED_LIDAR% ^
          -keep_first ^
          -step %STEP% ^
          -odir %TEMP_CHM_DIR% -odix _00 -obil

My second question is with "drop_z_below#"... in BLAST2DEM, can I add "drop_z_below.."  in  "additional command-line parameters"? Or do I need to "drop" the values using LASHEIGHT script and using the option "drop points with height below..."

blast2dem -i %NORMALIZED_LIDAR% ^
          -keep_first -drop_z_below 2 ^
          -step %STEP% -kill %KILL% ^
          -odir %TEMP_CHM_DIR% -odix _02 -obil

Kind regards,
Lily
200_percent_chm_grd_d20.jpg
200_percent_chm_tin_hhs_d20.jpg
Reply all
Reply to author
Forward
0 new messages