Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LidarTinGridding buffer area when prosessing folder of LAZ files #116

Open
manmatej opened this issue Sep 25, 2023 · 1 comment
Open

LidarTinGridding buffer area when prosessing folder of LAZ files #116

manmatej opened this issue Sep 25, 2023 · 1 comment

Comments

@manmatej
Copy link

Hello,

I am currently working with LidarTinGridding in R using Whitebox in RStudio. I have a directory containing numerous laz files and I'd like to take advantage of Whitebox's capability to process them all together in order to reduce edge effects, as demonstrated in the Whitebox Tools user manual: Whitebox Tools Manual.

When calling the entire directory as input, the tool will use points in a small buffer area extending into neighbouring tiles to reduce edge effects

I'm attempting to provide the input folder as an argument or a list of files to the function, but I'm encountering an issue where I still receive a "permission denied" error. I've tried running RStudio as an administrator and moving the input files to as many public folders as possible, but I'm still encountering the same permission denied problem.

When I work with a single file, everything runs smoothly. However, I'm wondering how to process multiple files. Is this option implemented in R whitebox?

You can find my code and sample tiles in this GitHub repository: GitHub Repository. The folder named "laz" contains two sample tiles processed with the script testing_whitebox.R.

My sessioninfo:

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=Czech_Czechia.utf8  LC_CTYPE=Czech_Czechia.utf8    LC_MONETARY=Czech_Czechia.utf8
[4] LC_NUMERIC=C                   LC_TIME=Czech_Czechia.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] whitebox_2.3.1

loaded via a namespace (and not attached):
[1] compiler_4.2.0  tools_4.2.0     rstudioapi_0.14

The error I am getting:

> setwd(input2)
> wbt_lidar_tin_gridding(
+   input=".",
+   output = "c:/Users/matej.man/Downloads/laz/fin.tif",
+   parameter = "elevation",
+   returns = "all",
+   resolution = 10)

Error running WhiteboxTools (LidarTinGridding)

whitebox.exe_path: "C:\Users\matej.man\AppData\Roaming/R/data/R/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
Arguments: --run=LidarTinGridding  --input="." --output="c:/Users/matej.man/Downloads/laz/fin.tif" --parameter=elevation --returns=all --resolution=10 --exclude_cls=7,18 -v

System command had status 101
*******************************
* Welcome to LidarTINGridding *
* Powered by WhiteboxTools    *
* www.whiteboxgeo.com         *
*******************************
thread 'main' panicked at 'Error while reading LiDAR file header (.).: Os { code: 5, kind: PermissionDenied, message: "Přístup byl odepřen." }', whitebox-tools-app\src\tools\lidar_analysis\lidar_tin_gridding.rs:494:81
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
lidar_tin_gridding - Elapsed Time: NA [did not run]
@manmatej manmatej changed the title LidarTinGridding zone when prosessing folder of LAZ files LidarTinGridding buffer area when prosessing folder of LAZ files Sep 25, 2023
@brownag
Copy link
Member

brownag commented Sep 26, 2023

Hi @manmatej

Thanks for the detailed explanation of the problem and example data. I can confirm that passing anything but a path to a single LiDAR file as input will cause the errors you encounter.

You need to set the Whitebox working directory. In your sample code you try using setwd() which alters the R working directory but not the Whitebox working directory.

Use wbt_wd() instead to set path to your "laz" folder, then using input="" will cause all .laz files to be processed to .tif.

The manual states:

Note that if an input LiDAR file (--input) is not specified by the user, the tool will search for all valid LiDAR (*.las, *.laz, *.zlidar) files contained within the current working directory.

Note you need not specify --output because the .tif file names will be derived from the input LiDAR file base name.

See this example (using whitebox-tools v2.3.0):

library(whitebox)

my_wd <- "~/gh/whiteboxR/116/cuzk-process/laz"
wbt_wd(my_wd)

# input is empty, whitebox uses the whitebox working directory
wbt_lidar_tin_gridding(
  input = "",
  parameter = "elevation",
  returns = "all",
  resolution = 10)

Quickly inspecting the results:

library(terra)
outfiles <- list.files(my_wd, full.names = TRUE, pattern = "tif")

# view individual tiles
res <- sapply(sprc(outfiles), plot)

# view combined
plot(vrt(outfiles))


As the current code in whitebox R package v2.3.1 is set up it is not possible to pass NULL input argument. Therefore you need to set input="" in the call to wbt_lidar_tin_gridding() to use the whitebox working directory.

Luckily, whitebox-tools appears to treat --input="" equivalently to not passing --input at all. Since input is optional, I should refactor the code to conditionally handles input so that it can be be left out of the call entirely .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants