LiDAR to DSM – Converting LiDAR (.laz) Data to DSM in .asc Format

demlazlidaropen-source-gisraster

I'm looking to convert a LIDAR scan in .laz format into a DSM in ASCII Grid format, in order to calculate RF propagation in an urban environment from a given transmission location (bonus: converting the georeferencing from NAD83 to WGS84).

My source data is a set of scans from NOAA, and I'm working to ingest them into another application which wants it in .asc format, like so:

ncols        2454
nrows        1467
xllcorner    -1.475333294357
yllcorner    53.378635095801
cellsize     0.000006170864
NODATA_value      0
0 0 0 0 0 0 0 0 0 0 0 0 0 ...

Being able to batch-process the data would definitely desirable.

Best Answer

One caveat to using FUSION: it truncates the precision of the output coordinates to only 4 decimal places, and I required 6. I really wanted to use WhiteBox GAT, however I was unable to get it to perform the nearest-neighbor processing (it kept insisting that the units from my files were in meters, not decimal degrees)

I ended up using SAGA GIS on the command line (functions on Windows and Linux - there's a Mac port in Brew but it's several revisions behind and didn't have LAS support).

I did a very rough job and simply converted the LAS point cloud directly into a raster grid via performing mean sampling for every grid square. As a result, the output file has a lot of holes. This could be fixed with one of the Gridding tools such as triangulation, nearest-neighbor, etc. However, those tools hung the app, possibly due to the sheer size of the dataset. For my purposes, simply sampling works fine, and has the added benefit of being significantly faster to process, as the performance is gated by I/O rather than CPU (SAGA has the side benefit of being more multi-core aware, as opposed to FUSION).

Rough steps which can be done in the GUI:

  1. Import LAS file to a Point Cloud file
  2. Use Point Cloud to Grid tool and set the Cellsize value – I used 0.00001 to represent the resolution in decimal degrees I required (going beyond that significantly increased computation and file size requirements)
  3. Export data in ESRI ASCII Grid format

I also needed to use las2las.exe to move the data from LAZ to LAS format, since SAGA doesn't support LAZ yet.

The following is the Windows batch script which I used to successfully process ~450 files

REM ********************************* PATHS ***********************************
REM Path to saga_cmd.exe and LAStools
set PATH=%PATH%;C:\SAGA;C:\laser\LAStools\bin

REM Path to working dir
SET WORK=C:\laser
REM ***************************************************************************


FOR /F %%i IN ('dir /b %WORK%\*.laz') DO (
cd /d %WORK%

saga_cmd io_shapes_las 1 ^
-FILES=%WORK%\%%~ni.las ^
-POINTS=%WORK%\%%~ni ^
-T=0 -i=0 -a=0 -r=0 -c=0 -u=0 -n=0 -R=0 -G=0 -B=0 -e=0 -d=0 -p=0 -C=0 ^
-VALID=0 -RGB_RANGE=0

saga_cmd pointcloud_tools 4 ^
-POINTS=%WORK%\%%~ni.spc ^
-GRID=%WORK%\%%~ni ^
-OUTPUT=0 -AGGREGATION=0 ^
-CELLSIZE=0.00001

saga_cmd io_grid 0 ^
-GRID=%WORK%\%%~ni.sdat ^
-FILE=%WORK%\%%~ni.asc ^
-FORMAT=1 -GEOREF=0 -PREC=6 -DECSEP=0

del *.mgrd
del *.mpts
del *.sgrd
del *.spc
del *.sdat
)

PAUSE

Note that if you're working with .LAZ files, you'll need to uncompress them to .LAS format with las2las, like below:

las2las.exe -i %%i -o %%~ni.las

and probably of these to delete it too

del *.las
Related Question