Skip to content

Commit

Permalink
Merge pull request #113 from brownag/wbt-basearg-1
Browse files Browse the repository at this point in the history
wbt_* `base` argument
  • Loading branch information
brownag committed Jun 18, 2023
2 parents 9d3a466 + 1e3b712 commit 7991c3c
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 50 deletions.
2 changes: 1 addition & 1 deletion 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.1
Version: 2.3.2
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 = "giswqs@gmail.com", role = c("aut")),
person("Andrew", "Brown", email = "brown.andrewg@gmail.com", role = c("ctb", "cre")))
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# whitebox 2.3.2

* Fix for file paths passed to optional `base` argument of `wbt_resample()`; thanks to @Pentaonia for reporting

* Also fixed are: `wbt_vector_lines_to_raster()`, `wbt_vector_points_to_raster()`, `wbt_vector_polygons_to_raster()`, `wbt_block_maximum_gridding()`, `wbt_block_minimum_gridding()`, `wbt_heat_map()`, `wbt_idw_interpolation()`, `wbt_natural_neighbour_interpolation()`, `wbt_nearest_neighbour_gridding()`, `wbt_radial_basis_function_interpolation()`, `wbt_tin_gridding()`

# whitebox 2.3.1

* `wbt_install()` and `wbt_install_extension()` gain optional `platform` argument that is used as a suffix on ZIP file, allowing download of alternate binaries on Linux and macOS (Darwin).
Expand Down
2 changes: 1 addition & 1 deletion PY2R/automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def function_block(line, ff):
+ "\n"
)
ff.write(" }" + "\n")
elif '"' not in para and "wd" in para:
elif '"' not in para and "wd" in para or ("base" in para and "=NULL" in item):
ff.write(" if (!missing(" + para + ")) {" + "\n")
ff.write(
' args <- paste(args, paste0("--'
Expand Down
12 changes: 6 additions & 6 deletions PY2R/scripts/data_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,8 @@ wbt_vector_lines_to_raster <- function(input, output, field="FID", nodata=TRUE,
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -890,8 +890,8 @@ wbt_vector_points_to_raster <- function(input, output, field="FID", assign="last
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -937,8 +937,8 @@ wbt_vector_polygons_to_raster <- function(input, output, field="FID", nodata=TRU
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down
32 changes: 16 additions & 16 deletions PY2R/scripts/gis_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ wbt_block_maximum_gridding <- function(input, field, output, use_z=FALSE, cell_s
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -113,8 +113,8 @@ wbt_block_minimum_gridding <- function(input, field, output, use_z=FALSE, cell_s
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -682,8 +682,8 @@ wbt_heat_map <- function(input, output, weight_field=NULL, bandwidth="", kernel=
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -739,8 +739,8 @@ wbt_idw_interpolation <- function(input, field, output, use_z=FALSE, weight=2.0,
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -993,8 +993,8 @@ wbt_natural_neighbour_interpolation <- function(input, output, field=NULL, use_z
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (clip) {
args <- paste(args, "--clip")
Expand Down Expand Up @@ -1042,8 +1042,8 @@ wbt_nearest_neighbour_gridding <- function(input, field, output, use_z=FALSE, ce
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!is.null(max_dist)) {
args <- paste(args, paste0("--max_dist=", max_dist))
Expand Down Expand Up @@ -1230,8 +1230,8 @@ wbt_radial_basis_function_interpolation <- function(input, field, output, use_z=
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -1586,8 +1586,8 @@ wbt_tin_gridding <- function(input, output, field=NULL, use_z=FALSE, resolution=
if (!is.null(resolution)) {
args <- paste(args, paste0("--resolution=", resolution))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!is.null(max_triangle_edge_length)) {
args <- paste(args, paste0("--max_triangle_edge_length=", max_triangle_edge_length))
Expand Down
4 changes: 2 additions & 2 deletions PY2R/scripts/image_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ wbt_resample <- function(inputs, output, cell_size=NULL, base=NULL, method="cc",
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!is.null(method)) {
args <- paste(args, paste0("--method=", method))
Expand Down
12 changes: 6 additions & 6 deletions R/data_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,8 @@ wbt_vector_lines_to_raster <- function(input, output, field="FID", nodata=TRUE,
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -890,8 +890,8 @@ wbt_vector_points_to_raster <- function(input, output, field="FID", assign="last
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -937,8 +937,8 @@ wbt_vector_polygons_to_raster <- function(input, output, field="FID", nodata=TRU
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down
32 changes: 16 additions & 16 deletions R/gis_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ wbt_block_maximum_gridding <- function(input, field, output, use_z=FALSE, cell_s
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -113,8 +113,8 @@ wbt_block_minimum_gridding <- function(input, field, output, use_z=FALSE, cell_s
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -682,8 +682,8 @@ wbt_heat_map <- function(input, output, weight_field=NULL, bandwidth="", kernel=
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -739,8 +739,8 @@ wbt_idw_interpolation <- function(input, field, output, use_z=FALSE, weight=2.0,
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -993,8 +993,8 @@ wbt_natural_neighbour_interpolation <- function(input, output, field=NULL, use_z
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (clip) {
args <- paste(args, "--clip")
Expand Down Expand Up @@ -1042,8 +1042,8 @@ wbt_nearest_neighbour_gridding <- function(input, field, output, use_z=FALSE, ce
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!is.null(max_dist)) {
args <- paste(args, paste0("--max_dist=", max_dist))
Expand Down Expand Up @@ -1230,8 +1230,8 @@ wbt_radial_basis_function_interpolation <- function(input, field, output, use_z=
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!missing(wd)) {
args <- paste(args, paste0("--wd=", wbt_file_path(wd)))
Expand Down Expand Up @@ -1586,8 +1586,8 @@ wbt_tin_gridding <- function(input, output, field=NULL, use_z=FALSE, resolution=
if (!is.null(resolution)) {
args <- paste(args, paste0("--resolution=", resolution))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!is.null(max_triangle_edge_length)) {
args <- paste(args, paste0("--max_triangle_edge_length=", max_triangle_edge_length))
Expand Down
4 changes: 2 additions & 2 deletions R/image_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ wbt_resample <- function(inputs, output, cell_size=NULL, base=NULL, method="cc",
if (!is.null(cell_size)) {
args <- paste(args, paste0("--cell_size=", cell_size))
}
if (!is.null(base)) {
args <- paste(args, paste0("--base=", base))
if (!missing(base)) {
args <- paste(args, paste0("--base=", wbt_file_path(base)))
}
if (!is.null(method)) {
args <- paste(args, paste0("--method=", method))
Expand Down

0 comments on commit 7991c3c

Please sign in to comment.