opengeos / whitebox-python

WhiteboxTools Python Frontend

Home Page:https://pypi.org/project/whitebox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Whitebox python lib method lidar_digital_surface_model getting stuck at filtering

aturgarg opened this issue · comments

  • whitebox version: v2.2.0
  • Python version: Python 3.9.13
  • Operating System: macOsX 13.2, Ubuntu 20.04, Ubuntu 22.04

Description

I am trying to convert lidar files to DSM raster, using method lidar_digital_surface_model.
For certain lidars, the method 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:

  • Should convert Lidar to DSM raster
  • Or should fail gracefully

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)

    

This seems the WBT backend issue. I saw you already opened an issue on the WBT repo. Closing this one.

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

Link to issue/bug opened in WBT repo:
jblindsay/whitebox-tools#364