GithubHelp home page GithubHelp logo

opengeos / whiteboxr Goto Github PK

View Code? Open in Web Editor NEW
171.0 10.0 30.0 14.82 MB

WhiteboxTools R Frontend

Home Page: https://whiteboxR.gishub.org

License: Other

R 81.22% Python 18.75% Dockerfile 0.04%
geospatial gis remote-sensing geoprocessing hydrology geomorphometry r rstudio rstats

whiteboxr's Introduction

whitebox

CRAN_Status_Badge CRAN download count whitebox Manual License: MIT R-CMD-check codecov Binder Donate

WhiteboxTools R Frontend.

This repository is related to the whitebox R package for geospatial analysis, which is an R frontend of a stand-alone executable command-line program called WhiteboxTools.

Contents

  1. Description
  2. Installation
  3. Usage
  4. Available Tools
  5. Contributing
  6. License
  7. Reporting Bugs

Description

The whitebox R package is built on WhiteboxTools, an advanced geospatial data analysis platform developed by Prof. John Lindsay (webpage; jblindsay) at the University of Guelph’s Geomorphometry and Hydrogeomatics Research Group. WhiteboxTools can be used to perform common geographical information systems (GIS) analysis operations, such as cost-distance analysis, distance buffering, and raster reclassification. Remote sensing and image processing tasks include image enhancement (e.g. panchromatic sharpening, contrast adjustments), image mosaicing, numerous filtering operations, simple classification (k-means), and common image transformations. WhiteboxTools also contains advanced tooling for spatial hydrological analysis (e.g. flow-accumulation, watershed delineation, stream network analysis, sink removal), terrain analysis (e.g. common terrain indices such as slope, curvatures, wetness index, hillshading; hypsometric analysis; multi-scale topographic position analysis), and LiDAR data processing. LiDAR point clouds can be interrogated (LidarInfo, LidarHistogram), segmented, tiled and joined, analyzed for outliers, interpolated to rasters (DEMs, intensity images), and ground-points can be classified or filtered. WhiteboxTools is not a cartographic or spatial data visualization package; instead it is meant to serve as an analytical backend for other data visualization software, mainly GIS. Suggested citation: Lindsay, J. B. (2016). Whitebox GAT: A case study in geomorphometric analysis. Computers & Geosciences, 95, 75-84. doi: http://dx.doi.org/10.1016/j.cageo.2016.07.003

Installation

There are three ways to install the whitebox R package.

1. CRAN

whitebox is now available on CRAN, so you can install it with:

install.packages("whitebox")

2. GitHub

You can alternatively install the development version of whitebox from GitHub as follows:

if (!require("remotes")) install.packages('remotes')
remotes::install_github("opengeos/whiteboxR", build = FALSE)

Usage

The function wbt_init() checks the path to the ‘WhiteboxTools’ binary.

wbt_init()

It (invisibly) returns a logical (TRUE/FALSE) value reflecting whether a file is found at one of the default paths, including those specified by package options. See ?whitebox::whitebox.

If you have ‘WhiteboxTools’ installed already but in a non-standard location run wbt_init(exe_path=...) to set up your options for your current R session.

wbt_init(exe_path = 'C:/home/user/path/to/whitebox_tools.exe')

Additional arguments to wbt_init() can set other package options, such as whether tools print their standard console output with cat().

If you want to turn this off, set verbose = FALSE, for instance:

wbt_init(exe_path = 'C:/home/user/path/to/whitebox_tools.exe', verbose = FALSE)

Documentation

For whitebox package documentation in R, ask for help:

??whitebox

For list of functions, try the wbt_ prefix in your search:

??wbt_

A complete list of functions available in the whitebox R package can be found HERE.

Check out this demo for examples.

Installing ‘WhiteboxTools’

The quickest way to get started if you are on 64-bit Windows, Linux or MacOS architectures is to download and install the ‘WhiteboxTools’ binary. Linux binaries compiled with ‘musl’ instead of ‘glibc’ on Ubuntu 22.04 are available with platform="linux_musl". On MacOS, Intel and Apple ‘M’ series processors (‘arm64’) are supported.

A method install_whitebox() is provided to download a version of the binaries that corresponds to the wrapper functions available in the package.

whitebox::install_whitebox()

By default this will install ‘WhiteboxTools’ to your whitebox R package data directory (see wbt_data_dir()), subdirectory “WBT”.

whitebox

How do I run tools?

Tool names in the whitebox R package can be called by corresponding function using wbt_snake_case() naming convention (e.g. wbt_lidar_info() R function for "LidarInfo" ‘WhiteboxTools’ tool name).

First we load the library and perform any necessary setup.

library(whitebox)

# set up as needed
wbt_init()

Many ‘WhiteboxTools’ will take GeoTIFF files as input, but ‘WhiteboxTools’ supports several grid input formats. There is a sample Digital Elevation Model (DEM) included in the whitebox package. You can get path as follows for this demo:

# Set input raster DEM file
dem <- sample_dem_data()

We will use this DEM in a sequence of ‘WhiteboxTools’ processing routines. Run tools by passing file paths for the input and output files.

  1. Apply feature-preserving smoothing (FeaturePreservingSmoothing)

  2. Breach depressions in a DEM (BreachDepressions)

  3. Calculate D-Infinity flow accumulation (DInfFlowAccumulation)

The filter argument to wbt_feature_preserving_smoothing() sets the size of the filter kernel.

## 1. FeaturePreservingSmoothing
wbt_feature_preserving_smoothing(
  dem = dem,
  output = "./smoothed.tif",
  filter = 9
)

## 2. BreachDepressions
wbt_breach_depressions(dem = "./smoothed.tif", output = "./breached.tif")

## 3. DInfFlowAccumulation
wbt_d_inf_flow_accumulation(input = dem, output = "./flow_accum.tif")

if (requireNamespace('terra')) {
  terra::plot(terra::rast("./flow_accum.tif"))
}
#> Loading required namespace: terra

About ‘WhiteboxTools’

library(whitebox)

# cat() output in non-interactive mode
wbt_verbose(TRUE)

# Prints the whitebox-tools help...a listing of available commands
wbt_help()
#> WhiteboxTools Help
#> 
#> The following commands are recognized:
#> --cd, --wd          Changes the working directory; used in conjunction with --run flag.
#> --compress_rasters  Sets the compress_raster option in the settings.json file; determines if newly created rasters are compressed. e.g. --compress_rasters=true
#> -h, --help          Prints help information.
#> -l, --license       Prints the whitebox-tools license. Tool names may also be used, --license="Slope"
#> --listtools         Lists all available tools. Keywords may also be used, --listtools slope.
#> --max_procs         Sets the maximum number of processors used. -1 = all available processors. e.g. --max_procs=2
#> -r, --run           Runs a tool; used in conjunction with --wd flag; -r="LidarInfo".
#> --toolbox           Prints the toolbox associated with a tool; --toolbox=Slope.
#> --toolhelp          Prints the help associated with a tool; --toolhelp="LidarInfo".
#> --toolparameters    Prints the parameters (in json form) for a specific tool; --toolparameters="LidarInfo".
#> -v                  Verbose mode. Without this flag, tool outputs will not be printed.
#> --viewcode          Opens the source code of a tool in a web browser; --viewcode="LidarInfo".
#> --version           Prints the version information.
#> 
#> Example Usage:
#> >> ./whitebox_tools -r=lidar_info --cd="/path/to/data/" -i=input.las --vlr --geokeys


# Prints the whitebox-tools license
wbt_license()
#> WhiteboxTools License
#> Copyright 2017-2023 John Lindsay
#> 
#> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
#> associated documentation files (the "Software"), to deal in the Software without restriction,
#> including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
#> and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
#> subject to the following conditions:
#> 
#> The above copyright notice and this permission notice shall be included in all copies or substantial
#> portions of the Software.
#> 
#> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
#> NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
#> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
#> OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
#> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Prints the whitebox-tools version
wbt_version()
#> WhiteboxTools v2.4.0 (c) Dr. John Lindsay 2017-2023
#> 
#> WhiteboxTools is an advanced geospatial data analysis platform developed at
#> the University of Guelph's Geomorphometry and Hydrogeomatics Research 
#> Group (GHRG). See www.whiteboxgeo.com for more details.


# Prints the toolbox for a specific tool.
wbt_toolbox("AsciiToLas")
#> LiDAR Tools


# Lists tools with 'lidar' in tool name or description.
wbt_list_tools("lidar")
#> All 66 Tools containing keywords:
#> AsciiToLas: Converts one or more ASCII files containing LiDAR points into LAS files.
#> ClassifyBuildingsInLidar: Reclassifies a LiDAR points that lie within vector building footprints.
#> ClassifyOverlapPoints: Classifies or filters LAS points in regions of overlapping flight lines.
#> ClipLidarToPolygon: Clips a LiDAR point cloud to a vector polygon or polygons.
#> ErasePolygonFromLidar: Erases (cuts out) a vector polygon or polygons from a LiDAR point cloud.
#> FilterLidarClasses: Removes points in a LAS file with certain specified class values.
#> FilterLidarScanAngles: Removes points in a LAS file with scan angles greater than a threshold.
#> FindFlightlineEdgePoints: Identifies points along a flightline's edge in a LAS file.
#> FlightlineOverlap: Reads a LiDAR (LAS) point file and outputs a raster containing the number of overlapping flight-lines in each grid cell.
#> HeightAboveGround: Normalizes a LiDAR point cloud, providing the height above the nearest ground-classified point.
#> LasToAscii: Converts one or more LAS files into ASCII text files.
#> LasToMultipointShapefile: Converts one or more LAS files into MultipointZ vector Shapefiles. When the input parameter is not specified, the tool grids all LAS files contained within the working directory.
#> LasToShapefile: Converts one or more LAS files into a vector Shapefile of POINT ShapeType.
#> LasToZlidar: Converts one or more LAS files into the zlidar compressed LiDAR data format.
#> LidarBlockMaximum: Creates a block-maximum raster from an input LAS file. When the input/output parameters are not specified, the tool grids all LAS files contained within the working directory.
#> LidarBlockMinimum: Creates a block-minimum raster from an input LAS file. When the input/output parameters are not specified, the tool grids all LAS files contained within the working directory.
#> LidarClassifySubset: Classifies the values in one LiDAR point cloud that correspond with points in a subset cloud.
#> LidarColourize: Adds the red-green-blue colour fields of a LiDAR (LAS) file based on an input image.
#> LidarDigitalSurfaceModel: Creates a top-surface digital surface model (DSM) from a LiDAR point cloud.
#> LidarElevationSlice: Outputs all of the points within a LiDAR (LAS) point file that lie between a specified elevation range.
#> LidarGroundPointFilter: Identifies ground points within LiDAR dataset using a slope-based method.
#> LidarHexBinning: Hex-bins a set of LiDAR points.
#> LidarHillshade: Calculates a hillshade value for points within a LAS file and stores these data in the RGB field.
#> LidarHistogram: Creates a histogram of LiDAR data.
#> LidarIdwInterpolation: Interpolates LAS files using an inverse-distance weighted (IDW) scheme. When the input/output parameters are not specified, the tool interpolates all LAS files contained within the working directory.
#> LidarInfo: Prints information about a LiDAR (LAS) dataset, including header, point return frequency, and classification data and information about the variable length records (VLRs) and geokeys.
#> LidarJoin: Joins multiple LiDAR (LAS) files into a single LAS file.
#> LidarKappaIndex: Performs a kappa index of agreement (KIA) analysis on the classifications of two LAS files.
#> LidarNearestNeighbourGridding: Grids LiDAR files using nearest-neighbour scheme. When the input/output parameters are not specified, the tool grids all LAS files contained within the working directory.
#> LidarPointDensity: Calculates the spatial pattern of point density for a LiDAR data set. When the input/output parameters are not specified, the tool grids all LAS files contained within the working directory.
#> LidarPointStats: Creates several rasters summarizing the distribution of LAS point data. When the input/output parameters are not specified, the tool works on all LAS files contained within the working directory.
#> LidarRansacPlanes: Performs a RANSAC analysis to identify points within a LiDAR point cloud that belong to linear planes.
#> LidarRbfInterpolation: Interpolates LAS files using a radial basis function (RBF) scheme. When the input/output parameters are not specified, the tool interpolates all LAS files contained within the working directory.
#> LidarRemoveDuplicates: Removes duplicate points from a LiDAR data set.
#> LidarRemoveOutliers: Removes outliers (high and low points) in a LiDAR point cloud.
#> LidarRooftopAnalysis: Identifies roof segments in a LiDAR point cloud.
#> LidarSegmentation: Segments a LiDAR point cloud based on differences in the orientation of fitted planar surfaces and point proximity.
#> LidarSegmentationBasedFilter: Identifies ground points within LiDAR point clouds using a segmentation based approach.
#> LidarTINGridding: Creates a raster grid based on a Delaunay triangular irregular network (TIN) fitted to LiDAR points.
#> LidarThin: Thins a LiDAR point cloud, reducing point density.
#> LidarThinHighDensity: Thins points from high density areas within a LiDAR point cloud.
#> LidarTile: Tiles a LiDAR LAS file into multiple LAS files.
#> LidarTileFootprint: Creates a vector polygon of the convex hull of a LiDAR point cloud. When the input/output parameters are not specified, the tool works with all LAS files contained within the working directory.
#> LidarTophatTransform: Performs a white top-hat transform on a Lidar dataset; as an estimate of height above ground, this is useful for modelling the vegetation canopy.
#> NormalVectors: Calculates normal vectors for points within a LAS file and stores these data (XYZ vector components) in the RGB field.
#> SelectTilesByPolygon: Copies LiDAR tiles overlapping with a polygon into an output directory.
#> ZlidarToLas: Converts one or more zlidar files into the LAS data format.
#> ModifyLidar: Modify points within a LiDAR point cloud based on point properties.
#> ColourizeBasedOnPointReturns: Sets the RGB values of a LiDAR point cloud based on the point returns.
#> FilterLidarByReferenceSurface: Filters points within a LiDAR point cloud based on a reference surface.
#> SmoothVegetationResidual: This tool can smooth the residual roughness due to vegetation cover in LiDAR DEMs.
#> SortLidar: Sorts LiDAR points based on their properties.
#> IndividualTreeDetection: Identifies points in a LiDAR point cloud that are associated with the tops of individual trees.
#> SplitLidar: Splits LiDAR points up into a series of new files based on their properties.
#> RecoverFlightlineInfo: Associates LiDAR points by their flightlines.
#> ColourizeBasedOnClass: Sets the RGB values of a LiDAR point cloud based on the point classification values.
#> LidarPointReturnAnalysis: This tool performs a quality control check on the return values of points in a LiDAR file.
#> LidarShift: Shifts the x,y,z coordinates of a LiDAR file.
#> FilterLidarByPercentile: Filters points within a LiDAR point cloud based on local elevation percentile.
#> LidarContour: This tool creates a vector contour coverage from an input LiDAR point file.
#> ImprovedGroundPointFilter: Filters points within a LiDAR point cloud based on a reference surface.
#> LidarSibsonInterpolation: This tool interpolates one or more LiDAR tiles using Sibson's natural neighbour method.
#> ClassifyLidar: Classify points within a LiDAR point cloud based on point properties.
#> LidarEigenvalueFeatures: Calculate eigenvalue-based metrics from a LiDAR point cloud.
#> FilterLidar: Filters points within a LiDAR point cloud based on point properties.
#> NormalizeLidar: Normalizes a LiDAR point cloud.


# Prints the help for a specific tool.
wbt_tool_help("lidar_info")
#> LidarInfo
#> Description:
#> Prints information about a LiDAR (LAS) dataset, including header, point return frequency, and classification data and information about the variable length records (VLRs) and geokeys.
#> Toolbox: LiDAR Tools
#> Parameters:
#> 
#> Flag               Description
#> -----------------  -----------
#> -i, --input        Input LiDAR file.
#> -o, --output       Output HTML file for summary report.
#> --density          Flag indicating whether or not to calculate the average point density and nominal point spacing.
#> --vlr              Flag indicating whether or not to print the variable length records (VLRs).
#> --geokeys          Flag indicating whether or not to print the geokeys.
#> 
#> 
#> Example usage:
#> >>./whitebox_tools -r=LidarInfo -v --wd="/path/to/data/" -i=file.las --vlr --geokeys"
#> ./whitebox_tools -r=LidarInfo --wd="/path/to/data/" -i=file.las


# Retrieves the tool parameter descriptions for a specific tool.
wbt_tool_parameters("slope")
#> {"parameters": [{"name":"Input DEM File","flags":["-i","--dem"],"description":"Input raster DEM file.","parameter_type":{"ExistingFile":"Raster"},"default_value":null,"optional":false},{"name":"Output File","flags":["-o","--output"],"description":"Output raster file.","parameter_type":{"NewFile":"Raster"},"default_value":null,"optional":false},{"name":"Z Conversion Factor","flags":["--zfactor"],"description":"Optional multiplier for when the vertical and horizontal units are not the same.","parameter_type":"Float","default_value":null,"optional":true},{"name":"Units","flags":["--units"],"description":"Units of output raster; options include 'degrees', 'radians', 'percent'","parameter_type":{"OptionList":["degrees","radians","percent"]},"default_value":"degrees","optional":true}]}


# View the source code for a specific tool on the source code repository.
wbt_view_code("breach_depressions")
#> https://github.com/jblindsay/whitebox-tools/blob/master/whitebox-tools-app/src/tools/hydro_analysis/breach_depressions.rs

Available Tools

The WhiteboxTools library currently contains more than 537 tools, which are each grouped based on their main function into one of the following categories: Data Tools, GIS Analysis, Hydrological Analysis, Image Analysis, LiDAR Analysis, Mathematical and Statistical Analysis, Stream Network Analysis, and Terrain Analysis. For a listing of available tools, complete with documentation and usage details, please see the ‘WhiteboxTools’ User Manual.

If you are interested in using the ‘WhiteboxTools’ command-line program, check ‘WhiteboxTools’ Usage

Contributing

If you would like to contribute to the project as a developer, follow these instructions to get started:

  1. Fork the whiteboxR repository (https://github.com/opengeos/whiteboxR)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am ‘Add some feature’)
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion in the work shall be licensed as the MIT license without any additional terms or conditions.

License

The whitebox R package is distributed under the MIT license, a permissive open-source (free software) license.

Reporting Bugs

whitebox is distributed as is and without warranty of suitability for application. If you encounter flaws with the software (i.e. bugs) please report the issue. Providing a detailed description of the conditions under which the bug occurred will help to identify the bug. Use the Issues tracker on GitHub to report issues with the software and to request feature enchancements. Please do not email Dr. Lindsay directly with bugs.

whiteboxr's People

Contributors

brownag avatar cstepper avatar giswqs avatar jsta avatar olivroy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whiteboxr's Issues

What am I missing? (runs in a shell not from R console)

Hi
Excited to find this treasure trove of useful spatial processing functions!

I'm on linux (Ubuntu 18.04) and R 4.0. After installing the package from the sourceforge repo with

install.packages("whitebox", repos="http://R-Forge.R-project.org")

and then running wbt_init() as instructed, on trying to invoke wbt_natural_neighbours_interpolation(...) I get

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[1] "natural_neighbour_interpolation - ********************************************"
Warning message:
In system(args2, intern = TRUE) :
  running command '/path/to/whitebox/WBT/whitebox_tools --run=natural_neighbour_interpolation  --input=controls.shp --output=wbt.tif --field=height --wd=/path/to/data/ -v' had status 101

I can run the same command from a shell and also using system() from R, but no luck using the wbt_ wrapper in R.

I don't really feel equipped for the RUST_BACKTRACE option, and since my command line install is working fine, I wonder if there's something obvious I have missed?

Whitebox will not run any tools with error thread 'main' panicked

I have been using WhiteBox through the R interface for a while now. I haven't had any issues with running wbt functions before, except this week.
I have been trying to run simple DEM processing and watershed commands such as:

watersheds_r <- wbt_watershed(d8_pntr = "~/Desktop/NC_Processed_Geospatial_Data/Elevation/FlowDir_D8.tif", 
pour_pts = "~/Desktop/Projects/Flood_WQ_Modeling/Data/GIS/R_Outputs/snapped_pour_points.shp", 
output = "~/Desktop/Projects/Flood_WQ_Modeling/Data/GIS/R_Outputs/watersheds.tif")

The error I have been receiving is:

thread 'main' panicked at 'No such file or directory (os error 2)', whitebox-tools-app/src/main.rs:72:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Error running WhiteboxTools (watershed)
  whitebox.exe_path: '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/whitebox/WBT/whitebox_tools'; File exists? TRUE
  Arguments: --run=watershed  --d8_pntr=~/Desktop/NC_Processed_Geospatial_Data/Elevation/FlowDir_D8.tif --pour_pts=~/Desktop/Projects/Flood_WQ_Modeling/Data/GIS/R_Outputs/snapped_pour_points.shp --output=~/Desktop/Projects/Flood_WQ_Modeling/Data/GIS/R_Outputs/watersheds.tif -v

System command had status 101
watershed - Elapsed Time: NA [did not run]

I have the executable files present, thanks to the install_whitebox function, and I have trying to debug with no luck. The DEM is pretty large but I used Whitebox tools to previously process this same DEM with no issues. Any ideas what might be causing this?

status 101 when trying to use whitebox in R (windows)

Hi there
I'm trying to use the function 'wbt_natural_neighbour_interpolation' from the package whitebox but it doesn't work properly. I consistently get the following message:
[1] ""
[2] "* Welcome to NaturalNeighbourInterpolation *"
[3] "
"
[4] "thread 'main' panicked at 'called Result::unwrap() on an Err value: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', src\vector\shapefile\mod.rs:238:21"
[5] "note: run with RUST_BACKTRACE=1 environment variable to display a backtrace"
attr(,"status")
[1] 101
Warning message:
In system(args2, intern = TRUE) :
running command ............ --use_z --cell_size=0.01 --clip -v' had status 101

Could you please provide an example to see the format of the input file and advises to better understand what is wrong?
What I have tried so far (unsuccessfully) is to use a shp file with points location, as well as a raster...
Thanks for your help!

Add machine learning tools and improve automation script

Math tools with logical operator names

Note that the Python interface for WhiteboxTools needed to violate the snake-case convention for function names for the Whitebox tools with logical operators (And, Not, Or) because Python uses these as keywords (and, not, or). I believe R uses the more conventional form for logical operators (&&, !, ||) and so there is no potential for name collisions. Can we change these function names to their snake-case equivalents?

CRAN package is stuck on inspect

Hi Qiusheng,
I've just tried to install the Whitebox R package and received an error. When I checked to see the CRAN package page, it appears to be hung on 'inspect'. Thanks again for taking the time to create this. I can't wait to test it out!

System command had status 101

Hello,

I am new to whitebox package in R and am having trouble using functions in the package. I did not find a similar issue here, but sorry if this has been addressed. I tried a basic demo script to see if it works in my computer:

# Set input raster DEM file
dem <- system.file("extdata", "DEM.tif", package = "whitebox")

## 1. FeaturePreservingSmoothing
wbt_feature_preserving_smoothing(
  dem = dem,
  output = "./smoothed.tif",
  filter = 9
)

I got:

Error running WhiteboxTools (feature_preserving_smoothing)
  whitebox.exe_path: "C:/Users/a_terui/OneDrive - UNCG/Documents/R/win-library/4.0/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
  Arguments: --run=feature_preserving_smoothing  --dem=C:/Users/a_terui/OneDrive - UNCG/Documents/R/win-library/4.0/whitebox/extdata/DEM.tif --output=./smoothed.tif --filter=9 --norm_diff=15 --num_iter=3 --max_diff=0.5 -v

System command had status 101
feature_preserving_smoothing - Elapsed Time: NA [did not run]

Any ideas? I got identical errors for any other functions in the package. I appreciate your help.

session info:

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
 [1] maptools_1.1-1  whitebox_2.0.0  raster_3.4-13   sp_1.4-5        sf_0.9-7       
 [6] foreach_1.5.1   forcats_0.5.1   stringr_1.4.0   dplyr_1.0.6     purrr_0.3.4    
[11] readr_2.0.0     tidyr_1.1.3     tibble_3.1.2    ggplot2_3.3.5   tidyverse_1.3.1

loaded via a namespace (and not attached):
 [1] httr_1.4.2         bit64_4.0.5        vroom_1.5.3        jsonlite_1.7.2    
 [5] here_1.0.1         modelr_0.1.8       assertthat_0.2.1   cellranger_1.1.0  
 [9] yaml_2.2.1         pillar_1.6.2       backports_1.2.1    lattice_0.20-44   
[13] glue_1.4.2         digest_0.6.27      rvest_1.0.1        colorspace_2.0-1  
[17] htmltools_0.5.1.1  Matrix_1.3-4       pkgconfig_2.0.3    broom_0.7.9       
[21] haven_2.4.1        scales_1.1.1       tzdb_0.1.2         proxy_0.4-26      
[25] generics_0.1.0     ellipsis_0.3.2     pacman_0.5.1       withr_2.4.2       
[29] TMB_1.7.20         cli_3.0.1          magrittr_2.0.1     crayon_1.4.1      
[33] readxl_1.3.1       evaluate_0.14      fs_1.5.0           fansi_0.5.0       
[37] xml2_1.3.2         foreign_0.8-81     class_7.3-19       tools_4.1.0       
[41] hms_1.1.0          lifecycle_1.0.0    munsell_0.5.0      reprex_2.0.0      
[45] compiler_4.1.0     e1071_1.7-7        rlang_0.4.11       classInt_0.4-3    
[49] units_0.7-2        grid_4.1.0         iterators_1.0.13   rstudioapi_0.13   
[53] rmarkdown_2.9      gtable_0.3.0       codetools_0.2-18   DBI_1.1.1         
[57] R6_2.5.0           lubridate_1.7.10   knitr_1.33         rgdal_1.5-23      
[61] bit_4.0.4          utf8_1.2.1         rprojroot_2.0.2    KernSmooth_2.23-20
[65] stringi_1.6.1      parallel_4.1.0     Rcpp_1.0.7         vctrs_0.3.8       
[69] dbplyr_2.1.1       tidyselect_1.1.1   xfun_0.23  

whiteboxR memory allocation

Hi Guys , I hope you had a nice eastern. I tried the slope tool in R and got the message below. I am trying to calculate the slope of a very large DEM (75 735 714 kb). Is there a work around for this problem.?
thanks in advance

slope(dem, output,zfactor=1, verbose_mode = TRUE)
[1] "" "* Welcome to Slope *"
[3] "
" "Reading data..."
[5] "memory allocation of 77553370898 bytes failed"
attr(,"status")
[1] 1033

fill depression output differs between whiteboxR and whitebox-tools

Hi Wu, I am having an issue where the output from fill_depressions with whiteboxR differs significantly from FillDepressions with whitebox tools (with the latter looking correct, while the whiteboxR output has extremely large nonsensical values). I have attached some code comparing the fill depression tool using the USGS Toutle River 2009 DEM, specifically the 10 M resolution DEM. Is there some additional step I need to take when invoking whitebox tools from within R?

library(raster); library(whitebox); library(dplyr)

dem_10m <- raster("../DEM/10m_DEM/msh2009dem10/w001001.adf") 
wbt <- "~/whitebox-tools/target/release/whitebox_tools"

writeRaster(dem_10m, "../TemporaryObjects/dem.tif", overwrite = TRUE, 
  options = c("COMPRESS=NONE"))`

fill_depressions(dem = "../TemporaryObjects/dem.tif", output = "../TemporaryObjects/dem_filled1.tif", fix_flats = FALSE) 

system(paste0(wbt, " -r=FillDepressions --wd='../TemporaryObjects/' -i='dem.tif' -o='dem_filled2.tif'"))

dem_filled1 <- raster("../TemporaryObjects/dem_filled1.tif")
dem_filled2 <- raster("../TemporaryObjects/dem_filled2.tif")
compareRaster(dem_filled1, dem_filled2, stopiffalse = FALSE)
all.equal(dem_filled1, dem_filled2)
wbR_cells <- data.frame(getValues(dem_filled1))
wbt_cells <- data.frame(getValues(dem_filled2))
temp <- cbind(wbR_cells, wbt_cells) 
names(temp) <- c("wbR", "wbt")
temp2 <- temp %>% filter(wbR!=wbt)
R version 3.5.3 (2019-03-11)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.5

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] dplyr_0.8.0.1  whitebox_0.4.0 raster_2.9-5   sp_1.3-1      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       lattice_0.20-38  codetools_0.2-16 crayon_1.3.4     assertthat_0.2.1 grid_3.5.3       R6_2.4.0         magrittr_1.5     pillar_1.3.1    
[10] rlang_0.3.2      rstudioapi_0.10  rgdal_1.4-3      tools_3.5.3      glue_1.3.1       purrr_0.3.2      yaml_2.2.0       compiler_3.5.3   pkgconfig_2.0.2 
[19] tidyselect_0.2.5 tibble_2.1.1   

Thanks for any advice. I appreciate all your hard work on this package.

Chris

status 101 when trying to use whitebox in R (windows)

Dear Wu
I downloaded the whitebox package for R on a windows machine. Everytime, I try to run a function i R I keep getting this error

[2] "* Welcome to FeaturePreservingDenoise "
[3] "
**************************************"
[4] "Reading data..."
[5] "thread 'main' panicked at 'called Option::unwrap() on a None value', src\libcore\option.rs:355:21"
[6] "note: Run with RUST_BACKTRACE=1 for a backtrace."
attr(,"status")
[1] 101

Any idea what is wrong? . Any help would appreciated
Rengifo

Error in system(args2, intern = TRUE) :

I have installed the R front end of whiteboxtool and run the code below but got the error below. I read online but could not find any consistant answer. I am using a window 10 system

library(whitebox)
dem <- system.file("extdata", "DEM.tif", package="whitebox")
output <- file.path(getwd(), "output.tif")
whitebox::wbt_impoundment_size_index(dem, damlength=40,output)

Error in system(args2, intern = TRUE) :
'\storage.slu.se/Home$/ozho0001/My' not found

Error in system(command, as.integer(flag), f, stdout, stderr, timeout): character string expected as first argument

@brownag - amazing work getting the package ready for CRAN.

Using the current whiteboxR 1.5.1 and running the example code of latest version of hydroweight, I end up with errors related to the system call.

The bug is in wbt_run_tool() and, internally, tool_name <- as.character(match.call()[[1]]). It has to do with the "::" syntax of calling a function from another package. This is a big challenge because hydroweight uses extensive calls to whitebox using ::. I've found the problem in other non-hydroweight code that I've been working on that uses

Any ideas of how to solve (on hydroweight's end or whiteboxR's)?

More details -- this works:

wbt_clip_raster_to_polygon(input = file.path(hydroweight_dir, dem), 
                                       polygons = file.path(hydroweight_dir, "TEMP-clip_region.shp"), 
                                       output = file.path(hydroweight_dir, "TEMP-dem_clip.tif"), 
                                       verbose_mode = TRUE)

But this does not:

whitebox::wbt_clip_raster_to_polygon(input = file.path(hydroweight_dir, dem), 
                                       polygons = file.path(hydroweight_dir, "TEMP-clip_region.shp"), 
                                       output = file.path(hydroweight_dir, "TEMP-dem_clip.tif"), 
                                       verbose_mode = TRUE)

Running the problem a little bit of a lower level, this works:

wbt_run_tool("wbt_clip_raster_to_polygon", args = args, verbose_mode = TRUE)

but this does not:

tool_name <- as.character(match.call()[[1]])
wbt_run_tool(tool_name, args, verbose_mode)

Here is the error:

:: - Error : 
Error running WhiteboxTools (::)
	whitebox.exe_path: "C:/Program Files/R/R-4.1.0/library/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
	Arguments: --run=::  --input=C:\Users\bkielstr\AppData\Local\Temp\Rtmp40bZkH/toy_dem_breached.tif --output=C:\Users\bkielstr\AppData\Local\Temp\Rtmp40bZkH/TEMP-clip_region.tif --reclass_vals=1,min,30000 -v
Error running WhiteboxTools (whitebox)
	whitebox.exe_path: "C:/Program Files/R/R-4.1.0/library/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
	Arguments: --run=whitebox  --input=C:\Users\bkielstr\AppData\Local\Temp\Rtmp40bZkH/toy_dem_breached.tif --output=C:\Users\bkielstr\AppData\Local\Temp\Rtmp40bZkH/TEMP-clip_region.tif --reclass_vals=1,min,30000 -v
Error running WhiteboxTools (reclass)
	whitebox.exe_path: "C:/Program Files/R/R-4.1.0/library/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
	Arguments: --run=reclass  --input=C:\Users\bkielstr\AppData\Local\Temp\Rtmp40bZkH/toy_dem_breached.tif --output=C:\Users\bkielstr\AppData\Local\Temp\Rtmp40bZkH/TEMP-clip_region.tif --reclass_vals=1,min,30000 -v

Error in system(command, as.integer(flag), f, stdout, stderr, timeout): character string expected as first argument

`wbt_laplacian_filter()` variant= OptionList argument type needs shell quoting

This is a note to make aware of some unexpected behavior I found while testing functions systematically.

I made some notes on this but never posted an issue. Still pondering what the general approach should be for sanitizing user input data and types in the autogenerated methods. I have some tools that I have been working for checking the arg string that might be able to be dropped into all of the generated code.

This is an analogue of #20 where arguments plopped into shell can lead to unexpected results. In this issue the shell does not like the parentheses floating around unquoted.


This wbt_laplacian_filter() behavior shows up as Syntax error: "(" unexpected

Fix: Default variant user argument needs to be wrapped in shQuote(). It will fail with the default value "3x3(1)" . A heavy-handed solution might be to shQuote all "OptionList" parameter types. I say heavy handed because it might not happen all that frequently. At a minimum any default arguments should be quoted so they dont error, but probably it should just quote the argument, which would only affect people who may have come up with their own workaround. Note: WBT should handle extra quotes for arguments fine, it replaces anything that evaluates to " or ' with nothing.

Of the other OptionList cases (n=5) where the variant parameter name is used wbt_laplacian_filter() is the only one that is sensitive to this bug because of the parentheses in the option labels.

Fix (to be done in a general way)

Change

args <- paste(args, paste0("--variant=", variant))

where variant
to

args <- paste(args, paste0("--variant=", shQuote(variant)))

So that
--run=laplacian_filter --input=DEM.tif --output=slope.tif --variant=3x3(1) --clip=0 -v
becomes
--run=laplacian_filter --input=DEM.tif --output=slope.tif --variant='3x3(1)' --clip=0 -v


function_name label parameter_type description
wbt_extract_valleys variant OptionList LQ, JandR, PandD Options include 'LQ' (lower quartile), 'JandR' (Johnston and Rosenfeld), and 'PandD' (Peucker and Douglas); default is 'LQ'.
wbt_laplacian_filter variant OptionList 3x3(1), 3x3(2), 3x3(3), 3x3(4), 5x5(1), 5x5(2) Optional variant value. Options include 3x3(1), 3x3(2), 3x3(3), 3x3(4), 5x5(1), and 5x5(2) (default is 3x3(1)).
wbt_line_detection_filter variant OptionList vertical, horizontal, 45, 135 Optional variant value. Options include 'v' (vertical), 'h' (horizontal), '45', and '135' (default is 'v').
wbt_sobel_filter variant OptionList 3x3, 5x5 Optional variant value. Options include 3x3 and 5x5 (default is 3x3).
wbt_tophat_transform variant OptionList white, black Optional variant value. Options include 'white' and 'black'.


R package provides different results than Whitebox GAT for watershed function

Hi,

I have a D8 flow pointer and a set of pour points/areas in the GeoTIFF format.

When I try to run the watershed function using the R package, it provides different output than that of the Whitebox GAT when using the same input for both approaches.

The resulting watershed from the Whitebox GAT looks reasonable, whereas the R package result does not make sense and it ignores some parts of the watershed (see the attached figure).
1

I have tried running the python package but it produced the same wrong result as the R package.

When I tried to run the same function from the cmd, the toolbox was unable to process it and showed the below message:


  • Welcome to Watershed *

Reading data...
thread 'main' panicked at 'The system cannot find the path specified. (os error 3)', src\main.rs:72:21
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.


Can you please help to fix that problem.

Much appreciated.

Downloading Issue from GITHUB

I tried to install whiteboxR via Github, but it fails
Please look into the matter.

devtools::install_github("giswqs/whiteboxR")

Downloading GitHub repo giswqs/whiteboxR@HEAD
Error: Failed to install 'whitebox' from GitHub:
System command 'Rcmd.exe' failed, exit status: -1, stdout + stderr empty

Error while runnig whitebox

I have installed whitebox.
The exe is available and the initiation returns TRUE but running operations, even on test data gives an error.

system(exeargs, intern = TRUE, ignore.stderr = ignore.stderr, :

Any tool i choose returns this error. see example

wbt_feature_preserving_smoothing(
     dem = dem,
     output = "./smoothed.tif",
     filter = 9
 )
feature_preserving_smoothing - Error in system(exeargs, intern = TRUE, ignore.stderr = ignore.stderr,  : 
  'CreateProcess' failed to run 'C:\Users\ejj\AppData\Local\R\WIN-LI~1\4.2\whitebox\WBT\WHITEB~1.EXE --run=FeaturePreservingSmoothing  --dem="C:/WORK/KOMPETANSEUTVIKLING/R/Catchment_delineation/uganda_hydrosheds_af_con_3s.tif" --output="./smoothed.tif" --filter=9 --norm_diff=15 --num_iter=3 --max_diff=0.5 -v'

wbt_mosaic returns error 101

Hi,
I'm trying to mosaic tiles from MERIT-Hydro for Western Canada. I have 121 elevation tif files (tiles) in a folder that I have set as my working directory.

This is what I'm running:
wbt_mosaic(output = "MERIT_mosaic_wbt.tif", inputs = NULL, method = "nn")
Based on the documentation, I don't specify my inputs so it automatically reads all the .tif in my working directory.

After less than a second, I get the following message:

Error running WhiteboxTools (mosaic)
  whitebox.exe_path: "C:/Users/robinne/Documents/R/win-library/4.1/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
  Arguments: --run=mosaic  --output=MERIT_mosaic_wbt.tif --method=nn -v
System command had status 101
mosaic - Elapsed Time: NA [did not run]`

I tried removing the inputs parameter and use a list of .tif files as inputs, but it does not work. Is there an issue with the total size of files to be handled (>7Giga)?

NAs after using wbt_fd8_flow_accumulation

Hi,
I am trying to use whitebox to calculate some hydrological characteristics of European DEM from https://land.copernicus.eu/imagery-in-situ/eu-dem/eu-dem-v1.1?tab=mapview.

I am using this raster:
class : RasterLayer
dimensions : 98, 250, 24500 (nrow, ncol, ncell)
resolution : 32800, 55200 (x, y)
extent : 952657.5, 9152658, 1029407, 6439007 (xmin, xmax, ymin, ymax)
crs : +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs
source : E20N10.tif
names : E20N10
values : 0, 804.12 (min, max)

dem <- "E:/Alenka/pracovni/olsiny_vegetace/vypocty/Present_data/E20N10.tif"
output <- "E:/Alenka/pracovni/olsiny_vegetace/vypocty/Present_data/E20N10_fill.tif"
wbt_fd8_flow_accumulation(dem, output)
fd8_flow_accumulation - **********************************************************************************

Finally, I have new raster but only with NAs:
class : RasterLayer
dimensions : 98, 250, 24500 (nrow, ncol, ncell)
resolution : 32800, 55200 (x, y)
extent : 952657.5, 9152658, 1029407, 6439007 (xmin, xmax, ymin, ymax)
crs : +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs
source : E20N10_fill.tif
names : E20N10_fill

values(d1)
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[62] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA

Please, do you have some idea where is the problem?
Alena

wbt_generalize_classified_raster(): System command had status 101 error

Hi, I am getting a 101 error when trying to use the wbt_generalize_classified_raster() tool in R4.0.2. I am running wrbt_majority_filter() and wbt_geomorphron() without issue. Any ideas what is going wrong?

E.g. code that throughs the 101 error:

r <-"./cod_grounds_geomorphron_100search_10deg_5tdist_masked.tif" #name of geomorphron output
wbt_generalize_classified_raster(
r,
"./cod_grounds_geomorphron_100search_10deg_5tdist_gcr10L.tif",#name of final filtered geomorphron output
min_size=10, #change as needed
method="nearest",#"largest","nearest","longest"
wd = NULL,
verbose_mode = TRUE,
compress_rasters = FALSE
)

Returns:
Error running WhiteboxTools (generalize_classified_raster)
whitebox.exe_path: "C:/Users/jmonk1/Dropbox/My PC (DOM-IMA-FDDM353)/Documents/R/win-library/4.0/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
Arguments: --run=generalize_classified_raster --input=./cod_grounds_geomorphron_100search_10deg_5tdist_masked.tif --output=./cod_grounds_geomorphron_100search_10deg_5tdist_gcr10L.tif --min_size=10 --method=nearest -v

System command had status 101
generalize_classified_raster - Elapsed Time: NA [did not run]

whiteboxR and R objects

I am trying to use the whiteboxR package for some geospatial analysis in R. I found that the tool seems only to use hard drive files as input and output in its functions, but not using regular R objects. Can I use, for example, a raster object in R as the input for whiteboxR functions , and output the result directly to R objects rather than frequently reading and writing data from the hard drive? Thank you.

Add error message for file type?

So, this is probably because I'm monumentally dumb, but - spent a long time trying to figure out why the raster function wasn't working.

It was because I was using a .img file, rather than a geotiff.

Just a potential thought to add an error message about file type. I could do this and submit a pull request, if helpful.

Whitebox cannot create "settings.json" on shiny server after upgrade to 2.1.1

Hi,

we are using whitebox-tools through the R-client from within a shiny-application.
Installation on our shiny-server was performed as documented here by

  • running install.packages("whitebox") as root (package directory is "/usr/local/lib/R/site-library")
  • running whitebox::install_whitebox() likewise as root which installs the WBT executable into the folder of the R-package

So far it was possible to use the app as a standard shiny (=non-root) user.
Today when calling wbt_slope (or any other function) the app crashed with the following error message in the log:
thread 'main' panicked at 'Error creating output settings.json file.: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', whitebox-common/src/configs/mod.rs:57:46 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Error running WhiteboxTools (slope) whitebox.exe_path: '/usr/local/lib/R/site-library/whitebox/WBT/whitebox_tools'; File exists? TRUE Arguments: --run=slope --dem='' --output='/home/shiny/slope.tif' --units=degrees --compress_rasters=FALSE -v --max_procs=-1

To make sure that this is not related to the application itself I executed the code below on the same server in an R session as root user and in another session as non-root user (typically shiny users do not have root privileges) outside the application.

library(whitebox)
dem <- system.file("ex", "elev.tif", package="terra")
wbt_slope(dem, "/home/shiny/slope.tif")

In root mode the code calculates slope as expected and produces the output file.
In user mode I get the same error as when running the application.

The NEWS of the R-client states for version 2.1.1:
Updated how --compress_rasters parameter is passed via command line. Now the flag is added to all commands regardless of whether the value is TRUE or FALSE. This allows update of settings.json accordingly when --compress_rasters=FALSE. RE: https://github.com/jblindsay/whitebox-tools/issues/233#issuecomment-1065955783

Downgrading the R-package to version 2.1.0 resolves the issue.
Can this be changed to also allow non-root users to call the functions?
Best,
Hendrik

Running batch files for impoundment index issue with output

Hi. I am using whitetboxtool in R to compute impoundment index for 1000 tiles of rasters. Since it will be too cumbersome to do it individually I have opted for writing a batch code to do it in parallel as shown in the code below.

library(raster)
library(foreach)
library(doParallel)

###set my working directory
setwd("path")

#setup parallel backend to use many processors
cores=detectCores()
cl <- makeCluster(cores[1]-1)
registerDoParallel(cl)

tiles<-list.files(path = "mypath", pattern = '*tif$', full.names=T)
foreach(i=1:length(tiles),.packages = "whitebox") %dopar%
{
Index<-wbt_impoundment_size_index(
tiles[i],
damlength=40,
out_type = "mean depth",
output = paste0("E:/Gotland_Ditch/ImpIndex", 'T_',i,'.tif'))
}

#stop cluster
stopCluster(cl)

However I got the following error: "Error in summary.connection(connection):invalid connection". when I replace i=1 and run only the wbt_impoundment_size_index it works fine. I think it has to do with the output, writing each file at a time as it is computed. I will appreciate any help.

wbt_stochastic_depression_analysis

Hello - I just installed the whiteboxR package and tried to run two separate DEM's (.tif) and keep getting the same error:

library(raster)
library(whitebox)

demP1 <- raster("D:/R Projects/P1Karst/data/dtm.tif")
rm(dem,output)
wbt_stochastic_depression_analysis(

  • demP1,
  • output="D:/R Projects/P1Karst/data/p1pdep.tif", #pdep=probability of depression output to working directory
  • rmse=0.05, # Point cloud error, in meters
  • range=4, #size of pixel (at least 3X resolution of DEM)
  • iterations = 300, # Play with 100-500 to start
  • wd = "D:/R Projects/P1Karst",
  • verbose_mode = F,
  • compress_rasters = FALSE
  • )

Error running WhiteboxTools (stochastic_depression_analysis)
whitebox.exe_path: "C:/Users/h2obe/Documents/R/win-library/4.1/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
Arguments: --run=stochastic_depression_analysis --dem=raster(ncols=11168, nrows=15633, xmn=786533, xmx=820037, ymn=351145, ymx=398044, crs='+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs') --output=D:/R Projects/P1Karst/data/p1pdep.tif --rmse=0.05 --range=4 --iterations=300 --wd=D:/R Projects/P1Karst -v

System command had status 101
stochastic_depression_analysis - Elapsed Time: NA [did not run]

The DEMs are 1-m LiDAR downloaded from public server.
Does the dem need to be in a specific format to work in whiteboxR?

FYI, I ran the following code and it works just fine:
dem <- system.file("extdata", "DEM.tif", package = "whitebox")

wbt_stochastic_depression_analysis(
dem,
output="D:/R Projects/P1Karst/data/test.tif", #pdep=probability of depression output to working directory
rmse=0.05, # in meters
range=4, # size of pixel (at least 3X resolution of DEM)
iterations = 300, # Play with 100-500 to start
wd = "D:/R Projects/P1Karst/data",
verbose_mode = F,
compress_rasters = FALSE
)

Thus, makes me think the dem format needs to be very specific.

Error in system(args2, intern = TRUE) : 'C:/Program' not found

This is the same lines which are on the description.

library(whitebox)
dem <- system.file("extdata", "DEM.tif", package="whitebox")
wbt_feature_preserving_smoothing(dem, "./output.tif", filter=9, verbose_mode = TRUE)

Getting an error
Error in system(args2, intern = TRUE) : 'C:/Program' not found

Cannot set working directory in Whitebox package in R

The working directory cannot be set when using the package in R.
There is a function to set the working directory in the python library and even when running from terminal/cmd.
Is there any function to do this in R?

Request: Reduce conflicts with base R functions

Hi,

I am prepping a masterclass for GIS students and have been using the whitebox package to help clean, manipulate, and analyze lidar and topographic data. I have been very impressed by the breadth and depth of functionality that the package provides. The functions provided by the underlying whitebox package provides much needed capability to the R GIS ecosystem.

I do have some suggestions, however, in order to have the package play more nicely with the R package ecosystem. Generally, masking R functions provided by the base/stats/graphics package is a poor practice when naming your package's functions. Currently, whitebox overwrites a significant number of these functions, which can confuse users since many of these functions are used in logic control and general non-whitebox-specific programming (min, max, round).

> library(whitebox)
Attaching package:whiteboxThe following objects are masked frompackage:stats:

    anova, power, profile

The following object is masked frompackage:graphics:

    clip

The following objects are masked frompackage:base:

    atan2, cos, cosh, exp, floor, intersect, log10, log2, max, min, round, sin, sinh, sink, tan, tanh, truncate, union, xor

Since these functions are interfacing with the whitebox library, I would suggest making that clear by adding a prefix such as wb_ or wbt_ to the whitebox specific versions. This would both make it clear to the user which version of the function is being called, as well as improve the experience of users using an IDE that supports autocompletion, since entering the prefix would then bring up all the functions provided specifically by the whitebox package (a practice well-demonstrated by the stringr package).

Best regards,
Tyler

Error when calling whitebox::tool

Hi, thanks for the work on this package, it's a great resource! I was trying it out on a problem today and found that if you call a function with out loading the library, e.g. whitebox::idw_interpolation, the system call that gets created errors out. It looks like the problem is here in the function code:

tool_name <- match.call()[[1]]

which doesn't remove the 'whitebox::' from the tool name. I created this workaround that seemed to fix the problem, I think putting this into wbt_run_tool() would solve the problem for most (all?) of the tools.

tool_name <- as.character(match.call()[[1]])  
tool_name <- tool_name[!grepl("(whitebox|::)", tool_name)]

Github installation issue with whiteboxR 1.5.1

whiteboxR 1.5.1 is failing to install on a fresh R 4.1.0 and RStudio 1.4.1717 on both Mac and Windows. The error messages are different but likely related a namespace issue.


Windows:

devtools::install_github("giswqs/whiteboxR") # For latest version
Downloading GitHub repo giswqs/whiteboxR@HEAD
√ checking for file 'C:\Users\bkielstr\AppData\Local\Temp\Rtmp8OkmWJ\remotes9141fb76178\giswqs-whiteboxR-439e248/DESCRIPTION' (666ms)

  • preparing 'whitebox': (2.3s)
    √ checking DESCRIPTION meta-information ...
  • checking for LF line-endings in source and make files and shell scripts (15s)
  • checking for empty or unneeded directories
    Removed empty directory 'whitebox/PY2R'
    Removed empty directory 'whitebox/docs'
    Removed empty directory 'whitebox/misc'
  • building 'whitebox_1.5.1.tar.gz'
  • installing source package 'whitebox' ...
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'whitebox'
    finding HTML links ... done"

    ...

    ** building package indices
    ** testing if installed package can be loaded from temporary location
    *** arch - i386
    Error: package or namespace load failed for 'whitebox':
    .onLoad failed in loadNamespace() for 'whitebox', details:
    call: apply(sapply(token_patterns, function(x) grepl(x, res), simplify = FALSE),
    error: dim(X) must have a positive length
    Error: loading failed
    Execution halted
    *** arch - x64
    Error: package or namespace load failed for 'whitebox':
    .onLoad failed in loadNamespace() for 'whitebox', details:
    call: apply(sapply(token_patterns, function(x) grepl(x, res), simplify = FALSE),
    error: dim(X) must have a positive length
    Error: loading failed
    Execution halted
    ERROR: loading failed for 'i386', 'x64'

  • removing 'C:/Program Files/R/R-4.1.0/library/whitebox'

Session info:

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252

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

loaded via a namespace (and not attached):
[1] rstudioapi_0.13 magrittr_2.0.1 usethis_2.0.1 devtools_2.4.2 pkgload_1.2.1 R6_2.5.0 rlang_0.4.11
[8] fastmap_1.1.0 tools_4.1.0 pkgbuild_1.2.0 sessioninfo_1.1.1 cli_3.0.1 withr_2.4.2 ellipsis_0.3.2
[15] remotes_2.4.0 rprojroot_2.0.2 lifecycle_1.0.0 crayon_1.4.1 processx_3.5.2 purrr_0.3.4 callr_3.7.0
[22] fs_1.5.0 ps_1.6.0 testthat_3.0.4 curl_4.3.2 memoise_2.0.0 glue_1.4.2 cachem_1.0.5
[29] compiler_4.1.0 desc_1.3.0 prettyunits_1.1.1


Mac:

devtools::install_github("giswqs/whiteboxR")
Downloading GitHub repo giswqs/whiteboxR@HEAD
✓ checking for file ‘/private/var/folders/z9/cqjtj3ln135_79r_4cbpc15c0000gn/T/RtmpdvcGRc/remotes53be275b60cb/giswqs-whiteboxR-439e248/DESCRIPTION’ (374ms)
─ preparing ‘whitebox’: (724ms)
✓ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts (1.1s)
─ checking for empty or unneeded directories
Removed empty directory ‘whitebox/PY2R’
Removed empty directory ‘whitebox/docs’
Removed empty directory ‘whitebox/misc’
─ building ‘whitebox_1.5.1.tar.gz’

  • installing source package ‘whitebox’ ...
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    Error: package or namespace load failed for ‘whitebox’:
    .onLoad failed in loadNamespace() for 'whitebox', details:
    call: NULL
    error: C stack usage 7970516 is too close to the limit
    Error: loading failed
    Execution halted
    ERROR: loading failed
  • removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/whitebox’
    Warning message:
    In i.p(...) :
    installation of package ‘/var/folders/z9/cqjtj3ln135_79r_4cbpc15c0000gn/T//RtmpdvcGRc/file53be602fc39c/whitebox_1.5.1.tar.gz’ had non-zero exit status

Session info:

R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
[1] devtools_2.4.2 usethis_2.0.1

loaded via a namespace (and not attached):
[1] rstudioapi_0.13 magrittr_2.0.1 pkgload_1.2.1 R6_2.5.0 rlang_0.4.11
[6] fastmap_1.1.0 tools_4.1.0 pkgbuild_1.2.0 sessioninfo_1.1.1 cli_3.0.1
[11] withr_2.4.2 ellipsis_0.3.2 remotes_2.4.0 rprojroot_2.0.2 lifecycle_1.0.0
[16] crayon_1.4.1 processx_3.5.2 purrr_0.3.4 callr_3.7.0 fs_1.5.0
[21] ps_1.6.0 curl_4.3.2 testthat_3.0.4 memoise_2.0.0 glue_1.4.2
[26] cachem_1.0.5 compiler_4.1.0 desc_1.3.0 prettyunits_1.1.1

install_whitebox not able to download executable in Github Actions

Hi,
we have a set of docker images which we create and maintain using Github Actions.
Running whitebox::install_whitebox() perfectly works when executed in a local docker container, but fails to download the zip-file when executed during a github actions workflow. The same goes when we download the zip file using wget during image creation.

Reprex for installation in a local container (works well):

$ docker pull meterds/r-aws-spatial
$ docker run -it meterds/r-aws-spatial
root@8cd54e265d6a:/# Rscript -e "whitebox::install_whitebox()"

Same goes when instead using wget inside the container:

wget https://www.whiteboxgeo.com/WBT_Linux/WhiteboxTools_linux_amd64.zip
unzip WhiteboxTools_linux_amd64.zip -d /usr/local/bin/

In Github Actions this fails. Maybe the logs are helpful to understand what happens, see https://github.com/meterds/mdsrocker/actions

Any ideas what causes this?
Thanks

working with compressed data and predictors

I tried to run wbt_feature_preserving_smoothing() on a raster which was compressed by DEFLATE with Predictor = 2
(e.g. by terra::writeRaster(dem, "dem.tif", gdal=c("COMPRESS=DEFLATE", "PREDICTOR=2")).

I get a result but just for some pixels at the border and hence its not usable.

When I try to run it on a raster with Predictor = 3, I receive Reading data... thread 'main' panicked at 'The GeoTIFF reader does not currently support floating-point predictors (PREDICTOR=3).', whitebox-tools-app\src\main.rs:72:21

So I guess my case is either a different problem or its not supported as well and the error message is missing?!

Setting raster compression

Hi,

I was wondering how/if it is possible to set raster compression? I believe in the Python version there is a wbt.set_compress_rasters(True) option.
I have been using the mean_filter tool which has been great but the output rasters are huge (e.g. 1.4Gb for a 20,000x20,000 raster which results in a raster full of nodata values). This is for a Float32 raster with TIFFTAG_SOFTWARE=WhiteboxTools

 WhiteboxTools v1.4.0 by Dr. John B. Lindsay (c) 2017-2020"
R version 4.0.0 (2020-04-24)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Where is my fault?

I try to learn WhiteBox usage in R. But I cannot succeed even an easy analysis like below. So, what is my fault?

My codes,

library(sp)
library(raster)
library(whitebox)
dem <- raster("dem.tif")
output <- "D:/R/WTB/slope.tif"
slope2 <- wbt_slope(dem, output, units = "degrees")

Results,

slope2 <- wbt_slope(dem, output, units = "degrees")
Warning message:
In system(args2, intern = TRUE) :
'C:/Users/KEMAL/Documents/R/win-library/4.0/whitebox/WBT/whitebox_tools.exe --run=slope --dem=raster(ncol=4897, nrow=5348, xmn=611459.160047657, xmx=660429.160047657, ymn=4486185.69062748, ymx=4539665.69062748, crs='+proj=utm +zone=37 +datum=WGS84 +units=m +no_defs') --output=D:/R/WTB/slope.tif --units=degrees -v' komutunu çalıştırırken 101 durumu oluştu

Examples in WhiteboxR (Not issue)

Hi,

I am glad that there is a support for R for Whitebox.

However, I found out the help for Whitebox does not include examples how to use the usage especially in LiDAR Tools.

It would have been nice if there is examples how to use the "usage".

Thanks.

Noli

P.S. lidR package has very good examples. It has a lot of LiDAR data as well.

Probably, LiDAR data from lidR can be used for the examples how to use the usage for WhiteboxR.

CRAN download issue

The whitebox R package has been temporarily taken down from CRAN due to issues related to downloading WhiteboxTools binaries during package installation. See below the most recent message I received from a CRAN maintainer. I am not quite sure how to resolve these issues yet. Any help will be appreciated. @jsta

---------- Forwarded message ---------
From: 
Date: Tue, Feb 12, 2019 at 4:33 AM
Subject: Re: CRAN submission whitebox 0.1.1
To: Qiusheng Wu 

Thanks, we see:
- you assume 'Linux' is always x86_64 aka amd64
This is not true, as there may be 32bit devices and installatins around.

- you attempt a download in .onAttach

Suggestion: Change SystemRequirements to

SystemRequirements: WhiteboxTools
         (https://github.com/jblindsay/whitebox-tools/releases/latest)

Do not download anything as the user knows where to download sources 
and/or binaries for the corresponding OS (s)he is using and build 
binaries if needed.

Then in your package check for presence of the binaries in .onLoad (not 
.onAttach).

For Windows, I made the binaries available in the path pointed to by 
environmen variable $WBT_HOME

Mac users will have to install from sources.

TimeInDaylight not working on a full DSM tile

Hello,
I am using the whitebox tool Time In Daylight with a digital surface model tile located in Quebec. I need to know where shading from overhanging vegetation on a river occurs when the sun is at it's heightest point in the sky(about 11h45) on the longest day (june 21st). I am running the algorithm through the terminal on a windows computer.
The parameters I am using are :
input = DEM tile (path towards DEM tile)
output = path towards output file
az_fraction = 30.0
max_dist = 100.0
lat=45.9397013082792
long=-71.6258803600092
utc_offset=-05:00
start_day=172
end_day=172
tart_time=09:45
end_time=14:00

These parameters give me a coherent output (raster with values between 0 and 1) when I run it on a subset of the DSM tile. I've tried 4 different subsets of varying size (one very close to the original tile size). However, when I run the algorithm with the exact same parameters on the entire DSM tile, the output is a raster full of NAs.
I've tried subsetting to the extent of the tile, and still the results are not coherent (raster full of NA)
I have managed to run the algorithm on the entire tile, but for a longer periode of time, but the computation takes a long time, so I would to reduce the window of time in which I'm running the algorithm.

Is there anyway you could help me with this problem.
I can provide the DSM tile if needed.

Thank you very much.

Meghana

Request: option to manually set exe path

Greetings, I use whiteboxtools with limited admin privileges (government work pc) and am unable to run the executable from my R directory. However, I can have WhiteBoxTools installed to my work computer and run via console from the C:/ProgramFiles.. directory. I'd love to be able to script whitebox in R but would need to manually set the exe path. I've tried to see if this is possible in the current version but believe it is not. Thanks for your consideration!

wbt_watershed returns System command had status 101

I am using wbt to delineate watershed. I have flow direction and flow accumulation grid from MERIT-Hydro. I test for one pour point, after extracting stream from flow accumulation and snap pour point to stream. I also cross-checked the snapped pour point and it lies in the stream pixel.
The code is:

wbt_watershed(d8_pntr = "E:/Project/flow_dir.tif",
pour_pts = "E:/Project/snappedpp.shp",
output = "E:/watersheds.tif")

Could it be because of the flow direction file? The Data type of flow direction grid is: Byte - Eight bit unsigned integer.

working with R internal files

Hi,
is there any way to process files internally in R without saving them to disk?

something like e.g.

## 1. FeaturePreservingSmoothing
dem_smoothed <- wbt_feature_preserving_smoothing(
  dem = dem,
  filter = 9
  )

wbt_isobasins() crashed for any size >= 1e5, works well under

Hello,
First of all thank you for this whitebox and its interface in R. I think it's a good tool for reproductible research in GIS, and it certainly makes some fastidious work with rgdal and raster easier.

I found what I think is a bug and I have no competence to fix it as I don't understand Rust.
When I try the to use the iso_basins() it works well for any size < 1e5 and crashes for any size > 1e5 (see exemple and console output below)

#Pre-processing
raw.dem <- dem.path #Any dem (mine is 10m*10m for a 1000 km² area)
wbt_feature_preserving_smoothing(raw.dem, "./smoothed.tif", filter=9, verbose_mode = TRUE)
wbt_breach_depressions("./smoothed.tif", "./breached.tif")
#Create isobasins for given size in cells
wbt_isobasins(dem = "./breached.tif", output = "./isobas_1km.tif", size = 1e4, wd = NULL, verbose_mode = TRUE) #works (exec time = 0.726s)
wbt_isobasins(dem = "./breached.tif", output = "./isobas_9pt99km.tif", size = 9.99e4, wd = NULL, verbose_mode = TRUE) #works (exec time = 0.688s)
wbt_isobasins(dem = "./breached.tif", output = "./isobas_10km.tif", size = 1e5, wd = NULL, verbose_mode = TRUE)  # Crash (immediately)

[1] "thread 'main' panicked at 'called Result::unwrap() on an Err value: ParseIntError { kind: InvalidDigit }', src\tools\hydro_analysis\isobasins.rs:170:21"
[2] "note: run with RUST_BACKTRACE=1 environment variable to display a backtrace"
attr(,"status")
[1] 101
Warning message:
In system(args2, intern = TRUE) :
running command 'C:/Users/me/Documents/R/R-4.0.0/library/whitebox/WBT/whitebox_tools.exe --run=isobasins --dem=./breached.tif --output=./isobas_10km.tif --size=1e+05 -v' had status 101

This bug was reproducted with two different Windows computer (10 standard and 10 Pro), an up-to-date whitebox install and two different R Version (3.61 and 4.0.0).

If you can have a look I would be grateful.

Line across hillshade output

Hi,
First thanks for the excellent package. These tools are very useful.

I'm a total beginner with whitebox, but have a problem with hillshade that I can't resolve and am hoping someone can help with. There is a line across the hillshade output and I don't understand where it is coming from as there doesn't seem to be anything in the DEM that would result in this. The DEM and resulting hillshade are:

image

Code (tif attached):

library(terra)
library(tmap)
library(whitebox)

wbt_init(exe_path = file.path("WBT", "whitebox_tools"))

data_folder <- "data"

dem <- rast(file.path(data_folder, "dem.tif"))

wbt_hillshade(dem = file.path(data_folder, "dem.tif"),
              output = file.path(data_folder, "hillshade.tif"))

hillshade <- rast(file.path(data_folder, "hillshade.tif"))

tm1 <- tm_shape(dem)+
  tm_raster(style = "cont", palette = "BrBG", title = "Height (m)") +
  tm_graticules() +
  tm_layout(legend.outside = TRUE, panel.labels = "DEM") 

tm2 <- tm_shape(hillshade)+
  tm_raster(style = "cont", palette = "-Greys", title = "Hillshade")+
  tm_graticules() +
  tm_layout(legend.outside = TRUE, panel.labels = "Hillshade")

tmap_arrange(tm1, tm2, nrow = 2)

dem.tif.zip

Error in system(args, intern = TRUE) : 'C:/Users/PROJETO' not found

Dear Qiusheng Wu,

I'm trying to access whitebox, but I can't due a to "blank space" in my folder user name.

'C:/Users/PROJETO RENOVA/...

wbt_fill_depressions("E:/rgee/dados/demP.tif", "E:/rgee/dados/demP_teste.tif")
Error in system(args2, intern = TRUE) : 'C:/Users/PROJETO' not found

Do you think there is a way to solve it instead of changing my username folder?

Thanks for developing this package.

In another machine that I use ran each tack in less than 1 second.

Best wishes.

modified_k_means_clustering help

Hi I'm trying to use the wbt_modified_k_means_clustering but I'm having trouble how to figure out how to specify the input raster file. Additionally is there any documentation on how the "optimal" number of clusters is determined and is that dependent on the merge_dist argument?

I tried feeding in a path to a single multiband raster object but I get an error saying that "At least two inputs are required to operate this tool" so I tried splitting the multiband file into several single band files, but then I get an error saying "character string expected as first argument"

library(raster)
library(whitebox)

a<- brick("tempPCA.tif")
nlayers(a) # 9 layer raster band
writeRaster(a, "temp.tif", bylayer=TRUE) #Write out this to individual files

input1<- paste(getwd(), "temp.tif" , sep= "/")
input1
#"C:/Users/socce/Downloads/wb_test/temp.tif"
output1<- paste(getwd(), "tempkmeans1.tif", sep="/")
output1
"C:/Users/socce/Downloads/wb_test/tempkmeans1.tif"
wbt_modified_k_means_clustering(inputs = input1, 
                                output = output1,
                                verbose_mode = TRUE)
# [1] "***************************************"                                                                                                                   
# [2] "* Welcome to ModifiedKMeansClustering *"                                                                                                                   
# [3] "***************************************"                                                                                                                   
# [4] "thread 'main' panicked at 'There is something incorrect about the input files. At least two inputs are required to operate this tool.', src\\main.rs:72:21"
# [5] "note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace"                                                                             
# attr(,"status")
# [1] 101
# Warning message:
#   In system(args2, intern = TRUE) :
#   running command 'C:/Users/socce/OneDrive/Documents/R/win-library/3.6/whitebox/WBT/whitebox_tools.exe --run=modified_k_means_clustering  --inputs=C:/Users/socce/Downloads/wb_test/temp.tif --output=C:/Users/socce/Downloads/wb_test/tempkmeans1.tif --start_clusters=1000 --max_iterations=10 --class_change=2 -v' had status 101


input2<- paste(getwd(), list.files(pattern = "temp_\\d\\.tif$"), sep="/")
input2
# [1] "C:/Users/socce/Downloads/wb_test/temp_1.tif" "C:/Users/socce/Downloads/wb_test/temp_2.tif"
# [3] "C:/Users/socce/Downloads/wb_test/temp_3.tif" "C:/Users/socce/Downloads/wb_test/temp_4.tif"
# [5] "C:/Users/socce/Downloads/wb_test/temp_5.tif" "C:/Users/socce/Downloads/wb_test/temp_6.tif"
# [7] "C:/Users/socce/Downloads/wb_test/temp_7.tif" "C:/Users/socce/Downloads/wb_test/temp_8.tif"
# [9] "C:/Users/socce/Downloads/wb_test/temp_9.tif"
output2<- paste(getwd(), "tempkmeans2.tif", sep="/")
output2
#"C:/Users/socce/Downloads/wb_test/tempkmeans2.tif"
wbt_modified_k_means_clustering(inputs = input2, 
                                output = output2,
                                verbose_mode = TRUE)
# Error in system(command, as.integer(flag), f, stdout, stderr, timeout) : 
#   character string expected as first argument

print(wbt_list_tools()) prints Error

In the documentation it says

# List all available tools in whitebox-tools
print(wbt_list_tools())

Instead an Error is printed

> print(wbt_list_tools())
All 0 Tools containing keywords:
[1] "All 0 Tools containing keywords:"

working with compressed tif-files

I guess its more an issue related to WhiteboxTools, but since i am not sure I state it here.

Trying to run commands for compressed TIF-files results in System command had status 101.

This is just true for certain compression types (e.g. LZMA, DEFLATE with predictor), while others (e.g. DEFLATE, LZW) work. Might be related to underlying GDAL version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.