jblindsay / whitebox-tools

An advanced geospatial data analysis platform
https://www.whiteboxgeo.com/
MIT License
914 stars 159 forks source link

Whitebox tool function LidarDigitalSurfaceModel getting stuck at filtering stage #364

Open aturgarg opened 11 months ago

aturgarg commented 11 months ago

Description

I am trying to convert lidar files to DSM raster, using method lidar_digital_surface_model (LidarDigitalSurfaceModel). For certain lidars, the tool is getting stuck at filtering. Example input lidar files can be obtained from USGS links:

  1. https://rockyweb.usgs.gov/vdelivery/Datasets/Staged/Elevation/LPC/Projects/FEMA_R6_AR_Dardanelle_Reservoir_QL2_Lidar/AR_DardanelleReservoir_2015/LAZ/USGS_LPC_FEMA_R6_AR_Dardanelle_Reservoir_QL2_Lidar_15svv560345.laz

  2. https://rockyweb.usgs.gov/vdelivery/Datasets/Staged/Elevation/LPC/Projects/FEMA_R6_AR_Dardanelle_Reservoir_QL2_Lidar/AR_DardanelleReservoir_2015/LAZ/USGS_LPC_FEMA_R6_AR_Dardanelle_Reservoir_QL2_Lidar_15svv560270.laz

Logs:


./whitebox_tools --run="LidarDigitalSurfaceModel" --wd="/tmp" --input='647910b9d34eac007b50fc55_USGS_LPC_FEMA_R6_AR_Dardanelle_Reservoir_QL2_Lidar_15svv560345.laz' --output='dsm_from_laz_1.tif' --resolution=0.5 --radius=0.5

***************************************
* Welcome to LidarDigitalSurfaceModel *
* Powered by WhiteboxTools            *
* www.whiteboxgeo.com                 *
***************************************
Performing interpolation...
Reading input LiDAR file...
Reading points: 0%
Reading points: 1%
Reading points: 2%
Reading points: 3%
.....
.....

Reading points: 99%
Reading points: 100%
Filtering points: 0%
Filtering points: 1%
Filtering points: 2%
Filtering points: 3%
....
....
Filtering points: 30%
Filtering points: 31%
Filtering points: 32%

Process got stuck at 32% for one on the Lidar file. This percentage varies from Lidar to Lidar.

Expected result:

What I Did

Code used:


import whitebox

def convert_to_dsm(laz_file_name, output_file_name):
    wbt_digital_surface_model_lidar(laz_file_name, output_file_name)

def __handle_whitebox_errors__(output):
    if 'panicked' in output or 'Error reading LAZ' in output or 'Warning: No points found' in output:

        print(f"whitebox processing of lidar throw error: {output}")
        raise Exception(message = f"whitebox processing of lidar throw error: {output}")       
    else:
        print(f"{output}")

def wbt_digital_surface_model_lidar(lidar_file, converted_file_name) -> str:
    print("#initialize whitebox tool")
    wbt = whitebox.WhiteboxTools()
    print(f"Whitebox tool version: {wbt.version()}")
    wbt.work_dir = "/tmp"
    dsm_output_tif = converted_file_name 
    callback_function = lambda output: __handle_whitebox_errors__(output)

    wbt.lidar_digital_surface_model(
        i=lidar_file,
        output=dsm_output_tif,
        resolution=0.5,
        radius=0.5, 
        minz=None, 
        maxz=None, 
        max_triangle_edge_length=None,
        callback=callback_function
    )               

    print(f"dsm_output_tif: {dsm_output_tif}")
    return dsm_output_tif

if __name__ == "__main__":
    laz_file = "647910b9d34eac007b50fc55_USGS_LPC_FEMA_R6_AR_Dardanelle_Reservoir_QL2_Lidar_15svv560345.laz"
    tif_file_name = "dsm_from_laz_1.tif"
    convert_to_dsm(laz_file, tif_file_name)
aturgarg commented 11 months ago

Also tried with: Python version 3.10.10 whitebox version v2.3.0 Error is still same as above