Skip to content

Commit

Permalink
Merge pull request #124 from brownag/master
Browse files Browse the repository at this point in the history
whitebox 2.4.0
  • Loading branch information
brownag authored May 26, 2024
2 parents 9edd3a4 + c504f56 commit 2cea642
Show file tree
Hide file tree
Showing 32 changed files with 106 additions and 103 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
^data-raw$
^revdep$
^_pkgdown\.yml$
WhiteboxTools_linux_amd64/
WBT/
CRAN/
PY2R/
binder/
docs/
misc/
.vscode/
^LICENSE\.md$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ whiteboxR.Rproj
*.tif
settings.json
__MACOSX
WhiteboxTools_linux_amd64
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: whitebox
Type: Package
Title: 'WhiteboxTools' R Frontend
Version: 2.3.4
Version: 2.4.0
Description: An R frontend for the 'WhiteboxTools' library, which is an advanced geospatial data analysis platform developed by Prof. John Lindsay 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. Suggested citation: Lindsay (2016) <doi:10.1016/j.cageo.2016.07.003>.
Authors@R: c(person("Qiusheng", "Wu", email = "[email protected]", role = c("aut")),
person("Andrew", "Brown", email = "[email protected]", role = c("ctb", "cre")))
Expand All @@ -10,7 +10,7 @@ License: MIT + file LICENSE
SystemRequirements: WhiteboxTools (https://github.com/jblindsay/whitebox-tools/releases/latest)
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
URL: https://whiteboxr.gishub.org/, https://github.com/opengeos/whiteboxR
BugReports: https://github.com/opengeos/whiteboxR/issues
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ RUN install2.r --error \
devtools \
whitebox \
Rcpp \
Matrix \
terra \
sf \
ggplot2 \
Expand All @@ -38,6 +39,4 @@ RUN install2.r --error \
caTools \
rprojroot

COPY misc/install.R /home/rstudio/

RUN Rscript /home/rstudio/install.R
RUN Rscript -e "whitebox::install_whitebox()"
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2019
COPYRIGHT HOLDER: Qiusheng Wu
YEAR: 2024
COPYRIGHT HOLDER: whitebox authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 whitebox authors

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.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# whitebox 2.4.0

* Updates for WhiteboxTools v2.4.0 (https://github.com/jblindsay/whitebox-tools/releases/tag/v2.4.0)

* Fix for new ZIP file folder structure for WhiteboxTools v2.4.0+ in `wbt_install()` / `install_whitebox()`

# whitebox 2.3.4

* Exported `wbt_file_path()`, a function previously used internally for creating safe, expanded, quoted, paths for building WhiteboxTools commands. This function also supports the input of `terra` objects that are backed by file sources supported by WhiteboxTools.
Expand Down
4 changes: 2 additions & 2 deletions PY2R/automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def function_example(fun_name):
dir_path = os.path.dirname(os.path.realpath(__file__))
wbt_py = os.path.join(dir_path, "whitebox_tools.py")
root_dir = os.path.dirname(dir_path)
WBT_dir = os.path.join(root_dir, "WBT")
WBT_dir = os.path.join(root_dir, "WhiteboxTools_linux_amd64", "WBT")

linux_tar = "WhiteboxTools_linux_amd64.zip"
tar_path = os.path.join(root_dir, linux_tar)
Expand All @@ -289,7 +289,7 @@ def function_example(fun_name):
with zipfile.ZipFile(tar_path, "r") as tar_ref:
tar_ref.extractall(root_dir)

shutil.copyfile(os.path.join(WBT_dir, "whitebox_tools.py"), wbt_py)
shutil.copyfile(os.path.join( WBT_dir, "whitebox_tools.py"), wbt_py)

# Generate R functions with documentation
ff = None
Expand Down
4 changes: 2 additions & 2 deletions PY2R/scripts/math_stat_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,11 @@ wbt_conditional_evaluation <- function(input, output, statement="", true=NULL, f
#' @param iterations Maximum iterations (if stopping criteria not reached).
#' @param seed Seed for RNG consistency.
#' @param prob Probability of random resample or resampling worst strata between `[0,1]`.
#' @param threshold Objective function values below the theshold stop the resampling iterations.
#' @param threshold Objective function values below the threshold stop the resampling iterations.
#' @param temp Initial annealing temperature between `[0,1]`.
#' @param temp_decay Annealing temperature decay proportion between `[0,1]`. Reduce temperature by this proportion each annealing cycle.
#' @param cycle Number of iterations before decaying annealing temperature.
#' @param average Weight the continuous objective funtion by the 1/N contributing strata.
#' @param average Weight the continuous objective function by the 1/N contributing strata.
#' @param wd Changes the working directory. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_wd()` for details.
#' @param verbose_mode Sets verbose mode. If verbose mode is `FALSE`, tools will not print output messages. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_verbose()` for details.
#' @param compress_rasters Sets the flag used by 'WhiteboxTools' to determine whether to use compression for output rasters. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_compress_rasters()` for details.
Expand Down
6 changes: 1 addition & 5 deletions PY2R/scripts/stream_network_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -945,15 +945,11 @@ wbt_tributary_identifier <- function(d8_pntr, streams, output, esri_pntr=FALSE,
#'
#' @return Returns the tool text outputs.
#' @export
wbt_vector_stream_network_analysis <- function(streams, dem, output, cutting_height=10.0, snap=0.1, wd=NULL, verbose_mode=NULL, compress_rasters=NULL, command_only=FALSE) {
wbt_vector_stream_network_analysis <- function(streams, output, snap=0.1, wd=NULL, verbose_mode=NULL, compress_rasters=NULL, command_only=FALSE) {
wbt_init()
args <- ""
args <- paste(args, paste0("--streams=", wbt_file_path(streams)))
args <- paste(args, paste0("--dem=", wbt_file_path(dem)))
args <- paste(args, paste0("--output=", wbt_file_path(output)))
if (!is.null(cutting_height)) {
args <- paste(args, paste0("--cutting_height=", cutting_height))
}
if (!is.null(snap)) {
args <- paste(args, paste0("--snap=", snap))
}
Expand Down
2 changes: 1 addition & 1 deletion PY2R/scripts/terrain_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ wbt_average_normal_vector_angular_deviation <- function(dem, output, filter=11,
#'
#' @param dem Name of the input raster image file.
#' @param output Name of the output vector lines file.
#' @param threshold Threshold value (0 - infinity but typcially 1 to 5 works well).
#' @param threshold Threshold value (0 - infinity but typically 1 to 5 works well).
#' @param min_length Minimum line length, in grid cells.
#' @param wd Changes the working directory. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_wd()` for details.
#' @param verbose_mode Sets verbose mode. If verbose mode is `FALSE`, tools will not print output messages. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_verbose()` for details.
Expand Down
8 changes: 4 additions & 4 deletions PY2R/whitebox_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2803,7 +2803,7 @@ def breakline_mapping(self, dem, output, threshold=2.0, min_length=3, callback=N
dem -- Name of the input raster image file.
output -- Name of the output vector lines file.
threshold -- Threshold value (0 - infinity but typcially 1 to 5 works well).
threshold -- Threshold value (0 - infinity but typically 1 to 5 works well).
min_length -- Minimum line length, in grid cells.
callback -- Custom function for handling tool text outputs.
"""
Expand Down Expand Up @@ -8945,11 +8945,11 @@ def conditioned_latin_hypercube(self, inputs, output, samples=500, iterations=25
iterations -- Maximum iterations (if stopping criteria not reached).
seed -- Seed for RNG consistency.
prob -- Probability of random resample or resampling worst strata between [0,1].
threshold -- Objective function values below the theshold stop the resampling iterations.
threshold -- Objective function values below the threshold stop the resampling iterations.
temp -- Initial annealing temperature between [0,1].
temp_decay -- Annealing temperature decay proportion between [0,1]. Reduce temperature by this proportion each annealing cycle.
cycle -- Number of iterations before decaying annealing temperature.
average -- Weight the continuous objective funtion by the 1/N contributing strata.
average -- Weight the continuous objective function by the 1/N contributing strata.
callback -- Custom function for handling tool text outputs.
"""
args = []
Expand Down Expand Up @@ -10652,7 +10652,7 @@ def tributary_identifier(self, d8_pntr, streams, output, esri_pntr=False, zero_b
if zero_background: args.append("--zero_background")
return self.run_tool('tributary_identifier', args, callback) # returns 1 if error

def vector_stream_network_analysis(self, streams, dem, output, cutting_height=10.0, snap=0.1, callback=None):
def vector_stream_network_analysis(self, streams, output, snap=0.1, callback=None):
"""This tool performs common stream network analysis operations on an input vector stream file.
Keyword arguments:
Expand Down
4 changes: 2 additions & 2 deletions R/math_stat_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,11 @@ wbt_conditional_evaluation <- function(input, output, statement="", true=NULL, f
#' @param iterations Maximum iterations (if stopping criteria not reached).
#' @param seed Seed for RNG consistency.
#' @param prob Probability of random resample or resampling worst strata between `[0,1]`.
#' @param threshold Objective function values below the theshold stop the resampling iterations.
#' @param threshold Objective function values below the threshold stop the resampling iterations.
#' @param temp Initial annealing temperature between `[0,1]`.
#' @param temp_decay Annealing temperature decay proportion between `[0,1]`. Reduce temperature by this proportion each annealing cycle.
#' @param cycle Number of iterations before decaying annealing temperature.
#' @param average Weight the continuous objective funtion by the 1/N contributing strata.
#' @param average Weight the continuous objective function by the 1/N contributing strata.
#' @param wd Changes the working directory. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_wd()` for details.
#' @param verbose_mode Sets verbose mode. If verbose mode is `FALSE`, tools will not print output messages. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_verbose()` for details.
#' @param compress_rasters Sets the flag used by 'WhiteboxTools' to determine whether to use compression for output rasters. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_compress_rasters()` for details.
Expand Down
8 changes: 1 addition & 7 deletions R/stream_network_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -932,9 +932,7 @@ wbt_tributary_identifier <- function(d8_pntr, streams, output, esri_pntr=FALSE,
#' @description This tool performs common stream network analysis operations on an input vector stream file.
#'
#' @param streams Name of the input streams vector file.
#' @param dem Name of the input DEM raster file.
#' @param output Name of the output lines shapefile.
#' @param cutting_height Maximum ridge-cutting height (z units).
#' @param snap Snap distance, in xy units (metres).
#' @param wd Changes the working directory. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_wd()` for details.
#' @param verbose_mode Sets verbose mode. If verbose mode is `FALSE`, tools will not print output messages. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_verbose()` for details.
Expand All @@ -945,15 +943,11 @@ wbt_tributary_identifier <- function(d8_pntr, streams, output, esri_pntr=FALSE,
#'
#' @return Returns the tool text outputs.
#' @export
wbt_vector_stream_network_analysis <- function(streams, dem, output, cutting_height=10.0, snap=0.1, wd=NULL, verbose_mode=NULL, compress_rasters=NULL, command_only=FALSE) {
wbt_vector_stream_network_analysis <- function(streams, output, snap=0.1, wd=NULL, verbose_mode=NULL, compress_rasters=NULL, command_only=FALSE) {
wbt_init()
args <- ""
args <- paste(args, paste0("--streams=", wbt_file_path(streams)))
args <- paste(args, paste0("--dem=", wbt_file_path(dem)))
args <- paste(args, paste0("--output=", wbt_file_path(output)))
if (!is.null(cutting_height)) {
args <- paste(args, paste0("--cutting_height=", cutting_height))
}
if (!is.null(snap)) {
args <- paste(args, paste0("--snap=", snap))
}
Expand Down
2 changes: 1 addition & 1 deletion R/terrain_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ wbt_average_normal_vector_angular_deviation <- function(dem, output, filter=11,
#'
#' @param dem Name of the input raster image file.
#' @param output Name of the output vector lines file.
#' @param threshold Threshold value (0 - infinity but typcially 1 to 5 works well).
#' @param threshold Threshold value (0 - infinity but typically 1 to 5 works well).
#' @param min_length Minimum line length, in grid cells.
#' @param wd Changes the working directory. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_wd()` for details.
#' @param verbose_mode Sets verbose mode. If verbose mode is `FALSE`, tools will not print output messages. Default: `NULL` will use the value in WhiteboxTools settings, see `wbt_verbose()` for details.
Expand Down
5 changes: 4 additions & 1 deletion R/wbt.R
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,10 @@ wbt_install <- function(pkg_dir = wbt_data_dir(), platform = NULL, force = FALSE

# unzip to either whitebox package or user specified folder
utils::unzip(exe_zip, exdir = pkg_dir)

ex_dir <- file.path(pkg_dir, gsub("\\.zip$", "", basename(exe_zip)))
file.copy(file.path(ex_dir, "WBT"), pkg_dir, recursive = TRUE)
file.remove(list.files(ex_dir, recursive = TRUE, full.names = TRUE))

# subfolder WBT/whitebox_tools
exe_path_out <- file.path(pkg_dir, "WBT", basename(exe_path))
Sys.chmod(exe_path_out, '755')
Expand Down
10 changes: 5 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ knitr::opts_chunk$set(
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/whitebox)](https://cran.r-project.org/package=whitebox)
[![CRAN download count](https://cranlogs.r-pkg.org/badges/grand-total/whitebox)](https://cranlogs.r-pkg.org/badges/grand-total/whitebox)
[![whitebox Manual](https://img.shields.io/badge/docs-HTML-informational)](https://whiteboxR.gishub.org/reference/index.html)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/MIT/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/MIT)
[![R-CMD-check](https://github.com/opengeos/whiteboxR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/opengeos/whiteboxR/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/opengeos/whiteboxR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/opengeos/whiteboxR)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/brownag/whitebox-r-binder/master?urlpath=rstudio)
[![Donate](https://img.shields.io/badge/Donate-Buy%20me%20a%20coffee-yellowgreen.svg)](https://www.buymeacoffee.com/giswqs)
[![Donate](https://img.shields.io/badge/Donate-Buy%20me%20a%20coffee-yellowgreen.svg)](https://buymeacoffee.com/giswqs)
<!-- badges: end -->

**WhiteboxTools** R Frontend.
Expand All @@ -37,7 +37,7 @@ This repository is related to the **whitebox** R package for geospatial analysis
* CRAN link: <https://cran.r-project.org/package=whitebox>
* WhiteboxTools: <https://github.com/jblindsay/whitebox-tools>
* User Manual: <https://jblindsay.github.io/wbt_book/>
* Free software: [MIT license](https://opensource.org/license/MIT/)
* Free software: [MIT license](https://opensource.org/license/MIT)


**Contents**
Expand Down Expand Up @@ -231,12 +231,12 @@ If you would like to contribute to the project as a developer, follow these inst
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](https://opensource.org/license/MIT/) without any additional terms or conditions.
Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion in the work shall be licensed as the [MIT license](https://opensource.org/license/MIT) without any additional terms or conditions.


## License

The whitebox **R** package is distributed under the [MIT license](https://opensource.org/license/MIT/), a permissive open-source (free software) license.
The whitebox **R** package is distributed under the [MIT license](https://opensource.org/license/MIT), a permissive open-source (free software) license.


## Reporting Bugs
Expand Down
Loading

0 comments on commit 2cea642

Please sign in to comment.