WbW - lidar_digital_surface_model()

24 views
Skip to first unread message

Philip

unread,
Jan 8, 2023, 12:45:34 AM1/8/23
to WhiteboxTools
Thanks for WbW it was quite easy to get going as a novice python scripter :).

From a las file (~200MB), I am trying to create a DEM using the lidar_tin_gridding() method and a DSM using the lidar_digital_surface_model() method with WbW. My code is below.

When I run the script, I get this error:
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized }', src\tools\lidar_processing\lidar_digital_surface_model.rs:115:88
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

If I block comment out the DEM code, the script completes and it generates the DSM. Am I supposed to delete the intermediary DEM variables before proceeding to the DSM tasks?

Thanks,
Philip

- - -

import whitebox_workflows as wbw
import pathlib
from datetime import datetime
from os import system

SCRIPT_DIR = pathlib.Path.cwd()
LIDAR_DIR = SCRIPT_DIR
DEM_DIR = SCRIPT_DIR

system('cls')

now = datetime.now()
dt_string = now.strftime("%Y%m%d_%H_%M")

wbe = wbw.WbEnvironment()
wbe.verbose=False

print(f'{wbe.version()}\n')

lidar_fname = 'UTM16-310-5135.las'
lidar_fpath = pathlib.Path.joinpath(LIDAR_DIR, lidar_fname)
lidar = wbe.read_lidar(str(lidar_fpath))

# Report

lidar_report_fname = f'{lidar_fpath.stem}_report.html'
lidar_report_fpath = pathlib.Path.joinpath(DEM_DIR, lidar_report_fname)
wbe.lidar_info(lidar, str(lidar_report_fpath), True, True, True)

# DEM

#Exclude all classes except 'ground' (2) from the interpolation
lasclasses = [i for i in range(18+1) if i not in [2]]
print(lasclasses)

dem = wbe.lidar_tin_gridding(lidar, interpolation_parameter="elevation", returns_included='last', excluded_classes=lasclasses, cell_size=0.5)
dem_nodata_filled = wbe.fill_missing_data(dem, filter_size=21)
dem_hs = wbe.multidirectional_hillshade(dem_nodata_filled, altitude=45.0, full_360_mode=True)

dem_fname = f'{lidar_fpath.stem}_DEM_{dt_string}.tiff'
dem_hs_fname = f'{lidar_fpath.stem}_DEM-HS_{dt_string}.tiff'
dem_fpath = pathlib.Path.joinpath(DEM_DIR, dem_fname)
dem_hs_fpath = pathlib.Path.joinpath(DEM_DIR, dem_hs_fname)

wbe.write_raster(dem_nodata_filled, str(dem_fpath), compress=True)
wbe.write_raster(dem_hs, str(dem_hs_fpath), compress=True)

# DSM

dsm = wbe.lidar_digital_surface_model(lidar, cell_size=0.5)
dsm_hs = wbe.multidirectional_hillshade(dsm, altitude=45.0, full_360_mode=True)

dsm_fname = f'{lidar_fpath.stem}_DSM_{dt_string}.tiff'
dsm_hs_fname = f'{lidar_fpath.stem}_DSM-HS_{dt_string}.tiff'
dsm_fpath = pathlib.Path.joinpath(DEM_DIR, dsm_fname)
dsm_hs_fpath = pathlib.Path.joinpath(DEM_DIR, dsm_hs_fname)

wbe.write_raster(dsm, str(dsm_fpath), compress=True)
wbe.write_raster(dsm_hs, str(dsm_hs_fpath), compress=True)
Reply all
Reply to author
Forward
0 new messages