opengeos / whitebox-python

WhiteboxTools Python Frontend

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LidarElevationSlice isn't slicing

GeospatialPython opened this issue · comments

  • whitebox version: v0.13.0
  • Python version:
    • Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14)
    • [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
  • Operating System: MacOS Mojave 10.14.2

Description

Describe what you were trying to get done.

I have a small, 200 MB, colorized, indoor lidar point cloud of a conference room. I'm trying to extract a slice of it.

The lidar_info output is the following:

File Signature: LASF
File Source ID: 0
Global Encoding:
GPS time=GpsWeekTime,
Waveform data internal=false,
Waveform data external=false,
Return data synthetic=false,
CRS method=WellKnownText
Project ID (GUID): {0-0-0-00-000000}
System ID: EXTRACTION
Generating Software: WhiteboxTools 
Las Version: 1.3
File Creation Day/Year: 18/2019
Header Size: 235
Offset to Points: 440
Number of VLRs: 2
Point Format: 3
Point Record Length: 34
Num. of Points (32-bit): 5869712
Number of Points by Return: [11739424, 0, 0, 0, 0]
X Scale Factor: 0.0001
Y Scale Factor: 0.0001
Z Scale Factor: 0.0001
X Offset: -19.8205
Y Offset: -44.6813
Z Offset: 0.15910000000000002
Max X: 21.220100000000002
Min X: -19.8205
Max Y: 82.7065
Min Y: -44.6813
Max Z: 7.1942
Min Z: 0.15910000000000002
Waveform Data Start: 0
Min Intensity: 514
Max Intensity: 63737

Tell us what happened, what went wrong, and what you expected to happen.

When I try to use the lidar_elevation_slice command, it outputs a file the exact same size and no points have been removed as far as I can tell.

What I Did

Here is the command I'm running:

import whitebox
wbt = whitebox.WhiteboxTools()
wbt.set_working_dir(os.getcwd())
wbt.lidar_elevation_slice("test1.las", "test2.las", minz=3.0, maxz=5.0, cls=False)

The command-line output looks ok:

./whitebox_tools --run="LidarElevationSlice" --wd="<full path removed>/Data" --input='test1.las' --output='test2.las' --minz='3.0' --maxz='5.0' --inclassval=2 --outclassval=1 -v

***********************************
* Welcome to lidar_elevation_slice *
************************************
Reading input LAS file...
Performing analysis...
Saving data: 0%
Saving data: 1%
Saving data: 2%
Saving data: 3%
Saving data: 4%
Saving data: 5%
Saving data: 6%
Saving data: 7%
Saving data: 8%
Saving data: 9%
Saving data: 10%
Saving data: 11%
Saving data: 12%
Saving data: 13%
Saving data: 14%
Saving data: 15%
Saving data: 16%
Saving data: 17%
Saving data: 18%
Saving data: 19%
Saving data: 20%
Saving data: 21%
Saving data: 22%
Saving data: 23%
Saving data: 24%
Saving data: 25%
Saving data: 26%
Saving data: 27%
Saving data: 28%
Saving data: 29%
Saving data: 30%
Saving data: 31%
Saving data: 32%
Saving data: 33%
Saving data: 34%
Saving data: 35%
Saving data: 36%
Saving data: 37%
Saving data: 38%
Saving data: 39%
Saving data: 40%
Saving data: 41%
Saving data: 42%
Saving data: 43%
Saving data: 44%
Saving data: 45%
Saving data: 46%
Saving data: 47%
Saving data: 48%
Saving data: 49%
Saving data: 50%
Saving data: 51%
Saving data: 52%
Saving data: 53%
Saving data: 54%
Saving data: 55%
Saving data: 56%
Saving data: 57%
Saving data: 58%
Saving data: 59%
Saving data: 60%
Saving data: 61%
Saving data: 62%
Saving data: 63%
Saving data: 64%
Saving data: 65%
Saving data: 66%
Saving data: 67%
Saving data: 68%
Saving data: 69%
Saving data: 70%
Saving data: 71%
Saving data: 72%
Saving data: 73%
Saving data: 74%
Saving data: 75%
Saving data: 76%
Saving data: 77%
Saving data: 78%
Saving data: 79%
Saving data: 80%
Saving data: 81%
Saving data: 82%
Saving data: 83%
Saving data: 84%
Saving data: 85%
Saving data: 86%
Saving data: 87%
Saving data: 88%
Saving data: 89%
Saving data: 90%
Saving data: 91%
Saving data: 92%
Saving data: 93%
Saving data: 94%
Saving data: 95%
Saving data: 96%
Saving data: 97%
Saving data: 98%
Saving data: 99%
Saving data: 100%
Writing output LAS file...
Complete!
0

But I get the entire file and not a slice.

What am I doing wrong?

Thanks in advance!

@GeospatialPython Thanks for reporting the issue! I just tested the LidarElevationSlice tool using a sample LiDAR dataset (St. Elis Mountains and Gulf of Alaska) and I can confirm that the tool seems to export the entire file, not a slice. I am copying Dr. John Lindsay (@jblindsay) on this issue to see if he can look into the source code and fix the issue. Thanks!

I've set the tool up so that if you set the --inclassval or --outclassval, the tool works in classify mode rather than filter mode, i.e. it assigns the specified class values to points inside and outside the slice. The problem is that I've given default values to these parameters and so, in the Python WhiteboxTools interface, even if you don't mess with these parameters, the tool will classify the points.

For now, I'd suggest setting these parameters to None; the tool should work as expected when this is done. That is,

import whitebox
wbt = whitebox.WhiteboxTools()
wbt.set_working_dir(os.getcwd())
wbt.lidar_elevation_slice("test1.las", "test2.las", minz=3.0, maxz=5.0, cls=False, inclassval=None, outclassval=None)

I've just committed a change to the tool such that the only way that it runs in classify mode is when the --class parameter is set to True. This fix is available in the repository now and will be in v0.14.

Thank you for the info. I'll try the repository version. I could see in the output that it was populating the class values with defaults so I instinctively tried the None approach. I just tried it again. The None values are still passed as strings to the binary so you get the following error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', libcore/result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
0

I've set the tool up so that if you set the --inclassval or --outclassval, the tool works in classify mode rather than filter mode, i.e. it assigns the specified class values to points inside and outside the slice. The problem is that I've given default values to these parameters and so, in the Python WhiteboxTools interface, even if you don't mess with these parameters, the tool will classify the points.

For now, I'd suggest setting these parameters to None; the tool should work as expected when this is done. That is,

import whitebox
wbt = whitebox.WhiteboxTools()
wbt.set_working_dir(os.getcwd())
wbt.lidar_elevation_slice("test1.las", "test2.las", minz=3.0, maxz=5.0, cls=False, inclassval=None, outclassval=None)

I've just committed a change to the tool such that the only way that it runs in classify mode is when the --class parameter is set to True. This fix is available in the repository now and will be in v0.14.

@GeospatialPython The latest WhiteboxTools v0.14.0 has fixed the issue. Could you try again and let us know if you still have issues with the tool?

Make sure you upgrade to whitebox v0.7.0: pip install -U whitebox

import whitebox
wbt = whitebox.WhiteboxTools()
wbt.set_working_dir(os.getcwd())
wbt.lidar_elevation_slice("test1.las", "test2.las", minz=3.0, maxz=5.0, cls=False)

I believe this issue has been resolved in the latest version. Therefore, I am closing the issue. Please reopen the issue if you still encounter issues.