Skip to content

Commit 7863783

Browse files
authored
Merge pull request #21 from giswqs/develop
Update to use WBT backend v1.3.1
2 parents 68bbd6b + 9c36093 commit 7863783

File tree

473 files changed

+1680
-5949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

473 files changed

+1680
-5949
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
config:
1616
- { os: windows-latest, r: '3.6', args: "--no-manual"}
17-
- { os: macOS-latest, r: 'devel', args: "--no-manual"}
17+
# - { os: macOS-latest, r: 'devel', args: "--no-manual"}
1818
# - { os: ubuntu-16.04, r: '3.2', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest", args: "--no-manual" }
1919
# - { os: ubuntu-16.04, r: '3.3', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest", args: "--no-manual" }
2020
# - { os: ubuntu-16.04, r: '3.4', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest", args: "--no-manual" }

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: whitebox
22
Type: Package
33
Title: 'WhiteboxTools' R Frontend
4-
Version: 1.3.0
4+
Version: 1.3.1
55
Description: An R frontend of 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>.
66
Authors@R: person("Qiusheng", "Wu", email = "giswqs@gmail.com", role = c("aut", "cre"))
77
Maintainer: Qiusheng Wu <giswqs@gmail.com>

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export(wbt_hole_proportion)
166166
export(wbt_horizon_angle)
167167
export(wbt_horton_stream_order)
168168
export(wbt_hypsometric_analysis)
169+
export(wbt_hypsometrically_tinted_hillshade)
169170
export(wbt_idw_interpolation)
170171
export(wbt_ihs_to_rgb)
171172
export(wbt_image_autocorrelation)
@@ -223,6 +224,7 @@ export(wbt_lidar_ransac_planes)
223224
export(wbt_lidar_rbf_interpolation)
224225
export(wbt_lidar_remove_duplicates)
225226
export(wbt_lidar_remove_outliers)
227+
export(wbt_lidar_rooftop_analysis)
226228
export(wbt_lidar_segmentation)
227229
export(wbt_lidar_segmentation_based_filter)
228230
export(wbt_lidar_thin)
@@ -281,6 +283,7 @@ export(wbt_modulo)
281283
export(wbt_mosaic)
282284
export(wbt_mosaic_with_feathering)
283285
export(wbt_multi_part_to_single_part)
286+
export(wbt_multidirectional_hillshade)
284287
export(wbt_multiply)
285288
export(wbt_multiscale_elevation_percentile)
286289
export(wbt_multiscale_roughness)

PY2R/scripts/lidar_analysis.R

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,70 @@ wbt_lidar_remove_outliers <- function(input, output, radius=2.0, elev_diff=50.0,
11641164
}
11651165

11661166

1167+
#' Lidar rooftop analysis
1168+
#'
1169+
#' Identifies roof segments in a LiDAR point cloud.
1170+
#'
1171+
#' @param input Input LiDAR file.
1172+
#' @param buildings Input vector build footprint polygons file.
1173+
#' @param output Output vector polygon file.
1174+
#' @param radius Search Radius.
1175+
#' @param num_iter Number of iterations.
1176+
#' @param num_samples Number of sample points on which to build the model.
1177+
#' @param threshold Threshold used to determine inlier points.
1178+
#' @param model_size Acceptable model size.
1179+
#' @param max_slope Maximum planar slope.
1180+
#' @param norm_diff Maximum difference in normal vectors, in degrees.
1181+
#' @param azimuth Illumination source azimuth in degrees.
1182+
#' @param altitude Illumination source altitude in degrees.
1183+
#' @param wd Changes the working directory.
1184+
#' @param verbose_mode Sets verbose mode. If verbose mode is False, tools will not print output messages.
1185+
#'
1186+
#' @return Returns the tool text outputs.
1187+
#' @export
1188+
wbt_lidar_rooftop_analysis <- function(buildings, output, i=NULL, radius=2.0, num_iter=50, num_samples=10, threshold=0.15, model_size=15, max_slope=65.0, norm_diff=10.0, azimuth=180.0, altitude=30.0, wd=NULL, verbose_mode=FALSE) {
1189+
wbt_init()
1190+
args <- ""
1191+
args <- paste(args, paste0("--buildings=", buildings))
1192+
args <- paste(args, paste0("--output=", output))
1193+
if (!is.null(i)) {
1194+
args <- paste(args, paste0("--i=", i))
1195+
}
1196+
if (!is.null(radius)) {
1197+
args <- paste(args, paste0("--radius=", radius))
1198+
}
1199+
if (!is.null(num_iter)) {
1200+
args <- paste(args, paste0("--num_iter=", num_iter))
1201+
}
1202+
if (!is.null(num_samples)) {
1203+
args <- paste(args, paste0("--num_samples=", num_samples))
1204+
}
1205+
if (!is.null(threshold)) {
1206+
args <- paste(args, paste0("--threshold=", threshold))
1207+
}
1208+
if (!is.null(model_size)) {
1209+
args <- paste(args, paste0("--model_size=", model_size))
1210+
}
1211+
if (!is.null(max_slope)) {
1212+
args <- paste(args, paste0("--max_slope=", max_slope))
1213+
}
1214+
if (!is.null(norm_diff)) {
1215+
args <- paste(args, paste0("--norm_diff=", norm_diff))
1216+
}
1217+
if (!is.null(azimuth)) {
1218+
args <- paste(args, paste0("--azimuth=", azimuth))
1219+
}
1220+
if (!is.null(altitude)) {
1221+
args <- paste(args, paste0("--altitude=", altitude))
1222+
}
1223+
if (!is.null(wd)) {
1224+
args <- paste(args, paste0("--wd=", wd))
1225+
}
1226+
tool_name <- as.character(match.call()[[1]])
1227+
wbt_run_tool(tool_name, args, verbose_mode)
1228+
}
1229+
1230+
11671231
#' Lidar segmentation
11681232
#'
11691233
#' Segments a LiDAR point cloud based on differences in the orientation of fitted planar surfaces and point proximity.

PY2R/scripts/terrain_analysis.R

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,62 @@ wbt_hypsometric_analysis <- function(inputs, output, watershed=NULL, wd=NULL, ve
680680
}
681681

682682

683+
#' Hypsometrically tinted hillshade
684+
#'
685+
#' Creates an colour shaded relief image from an input DEM.
686+
#'
687+
#' @param dem Input raster DEM file.
688+
#' @param output Output raster file.
689+
#' @param altitude Illumination source altitude in degrees.
690+
#' @param hs_weight Weight given to hillshade relative to relief (0.0-1.0).
691+
#' @param brightness Brightness factor (0.0-1.0).
692+
#' @param atmospheric Atmospheric effects weight (0.0-1.0).
693+
#' @param palette Options include 'atlas', 'high_relief', 'arid', 'soft', 'muted', 'purple', 'viridi', 'gn_yl', 'pi_y_g', 'bl_yl_rd', and 'deep.
694+
#' @param reverse Optional flag indicating whether to use reverse the palette.
695+
#' @param zfactor Optional multiplier for when the vertical and horizontal units are not the same.
696+
#' @param full_mode Optional flag indicating whether to use full 360-degrees of illumination sources.
697+
#' @param wd Changes the working directory.
698+
#' @param verbose_mode Sets verbose mode. If verbose mode is False, tools will not print output messages.
699+
#'
700+
#' @return Returns the tool text outputs.
701+
#' @export
702+
wbt_hypsometrically_tinted_hillshade <- function(dem, output, altitude=45.0, hs_weight=0.5, brightness=0.5, atmospheric=0.0, palette="atlas", reverse=FALSE, zfactor=1.0, full_mode=FALSE, wd=NULL, verbose_mode=FALSE) {
703+
wbt_init()
704+
args <- ""
705+
args <- paste(args, paste0("--dem=", dem))
706+
args <- paste(args, paste0("--output=", output))
707+
if (!is.null(altitude)) {
708+
args <- paste(args, paste0("--altitude=", altitude))
709+
}
710+
if (!is.null(hs_weight)) {
711+
args <- paste(args, paste0("--hs_weight=", hs_weight))
712+
}
713+
if (!is.null(brightness)) {
714+
args <- paste(args, paste0("--brightness=", brightness))
715+
}
716+
if (!is.null(atmospheric)) {
717+
args <- paste(args, paste0("--atmospheric=", atmospheric))
718+
}
719+
if (!is.null(palette)) {
720+
args <- paste(args, paste0("--palette=", palette))
721+
}
722+
if (reverse) {
723+
args <- paste(args, "--reverse")
724+
}
725+
if (!is.null(zfactor)) {
726+
args <- paste(args, paste0("--zfactor=", zfactor))
727+
}
728+
if (full_mode) {
729+
args <- paste(args, "--full_mode")
730+
}
731+
if (!is.null(wd)) {
732+
args <- paste(args, paste0("--wd=", wd))
733+
}
734+
tool_name <- as.character(match.call()[[1]])
735+
wbt_run_tool(tool_name, args, verbose_mode)
736+
}
737+
738+
683739
#' Max anisotropy dev
684740
#'
685741
#' Calculates the maximum anisotropy (directionality) in elevation deviation over a range of spatial scales.
@@ -930,6 +986,42 @@ wbt_min_downslope_elev_change <- function(dem, output, wd=NULL, verbose_mode=FAL
930986
}
931987

932988

989+
#' Multidirectional hillshade
990+
#'
991+
#' Calculates a multi-direction hillshade raster from an input DEM.
992+
#'
993+
#' @param dem Input raster DEM file.
994+
#' @param output Output raster file.
995+
#' @param altitude Illumination source altitude in degrees.
996+
#' @param zfactor Optional multiplier for when the vertical and horizontal units are not the same.
997+
#' @param full_mode Optional flag indicating whether to use full 360-degrees of illumination sources.
998+
#' @param wd Changes the working directory.
999+
#' @param verbose_mode Sets verbose mode. If verbose mode is False, tools will not print output messages.
1000+
#'
1001+
#' @return Returns the tool text outputs.
1002+
#' @export
1003+
wbt_multidirectional_hillshade <- function(dem, output, altitude=45.0, zfactor=1.0, full_mode=FALSE, wd=NULL, verbose_mode=FALSE) {
1004+
wbt_init()
1005+
args <- ""
1006+
args <- paste(args, paste0("--dem=", dem))
1007+
args <- paste(args, paste0("--output=", output))
1008+
if (!is.null(altitude)) {
1009+
args <- paste(args, paste0("--altitude=", altitude))
1010+
}
1011+
if (!is.null(zfactor)) {
1012+
args <- paste(args, paste0("--zfactor=", zfactor))
1013+
}
1014+
if (full_mode) {
1015+
args <- paste(args, "--full_mode")
1016+
}
1017+
if (!is.null(wd)) {
1018+
args <- paste(args, paste0("--wd=", wd))
1019+
}
1020+
tool_name <- as.character(match.call()[[1]])
1021+
wbt_run_tool(tool_name, args, verbose_mode)
1022+
}
1023+
1024+
9331025
#' Multiscale elevation percentile
9341026
#'
9351027
#' Calculates surface roughness over a range of spatial scales.

PY2R/whitebox_tools.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ def list_tools(self, keywords=[]):
420420

421421

422422

423+
423424

424425

425426
##############
@@ -2680,6 +2681,36 @@ def hypsometric_analysis(self, inputs, output, watershed=None, callback=None):
26802681
args.append("--output='{}'".format(output))
26812682
return self.run_tool('hypsometric_analysis', args, callback) # returns 1 if error
26822683

2684+
def hypsometrically_tinted_hillshade(self, dem, output, altitude=45.0, hs_weight=0.5, brightness=0.5, atmospheric=0.0, palette="atlas", reverse=False, zfactor=1.0, full_mode=False, callback=None):
2685+
"""Creates an colour shaded relief image from an input DEM.
2686+
2687+
Keyword arguments:
2688+
2689+
dem -- Input raster DEM file.
2690+
output -- Output raster file.
2691+
altitude -- Illumination source altitude in degrees.
2692+
hs_weight -- Weight given to hillshade relative to relief (0.0-1.0).
2693+
brightness -- Brightness factor (0.0-1.0).
2694+
atmospheric -- Atmospheric effects weight (0.0-1.0).
2695+
palette -- Options include 'atlas', 'high_relief', 'arid', 'soft', 'muted', 'purple', 'viridi', 'gn_yl', 'pi_y_g', 'bl_yl_rd', and 'deep.
2696+
reverse -- Optional flag indicating whether to use reverse the palette.
2697+
zfactor -- Optional multiplier for when the vertical and horizontal units are not the same.
2698+
full_mode -- Optional flag indicating whether to use full 360-degrees of illumination sources.
2699+
callback -- Custom function for handling tool text outputs.
2700+
"""
2701+
args = []
2702+
args.append("--dem='{}'".format(dem))
2703+
args.append("--output='{}'".format(output))
2704+
args.append("--altitude={}".format(altitude))
2705+
args.append("--hs_weight={}".format(hs_weight))
2706+
args.append("--brightness={}".format(brightness))
2707+
args.append("--atmospheric={}".format(atmospheric))
2708+
args.append("--palette={}".format(palette))
2709+
if reverse: args.append("--reverse")
2710+
args.append("--zfactor={}".format(zfactor))
2711+
if full_mode: args.append("--full_mode")
2712+
return self.run_tool('hypsometrically_tinted_hillshade', args, callback) # returns 1 if error
2713+
26832714
def max_anisotropy_dev(self, dem, out_mag, out_scale, max_scale, min_scale=3, step=2, callback=None):
26842715
"""Calculates the maximum anisotropy (directionality) in elevation deviation over a range of spatial scales.
26852716
@@ -2834,6 +2865,26 @@ def min_downslope_elev_change(self, dem, output, callback=None):
28342865
args.append("--output='{}'".format(output))
28352866
return self.run_tool('min_downslope_elev_change', args, callback) # returns 1 if error
28362867

2868+
def multidirectional_hillshade(self, dem, output, altitude=45.0, zfactor=1.0, full_mode=False, callback=None):
2869+
"""Calculates a multi-direction hillshade raster from an input DEM.
2870+
2871+
Keyword arguments:
2872+
2873+
dem -- Input raster DEM file.
2874+
output -- Output raster file.
2875+
altitude -- Illumination source altitude in degrees.
2876+
zfactor -- Optional multiplier for when the vertical and horizontal units are not the same.
2877+
full_mode -- Optional flag indicating whether to use full 360-degrees of illumination sources.
2878+
callback -- Custom function for handling tool text outputs.
2879+
"""
2880+
args = []
2881+
args.append("--dem='{}'".format(dem))
2882+
args.append("--output='{}'".format(output))
2883+
args.append("--altitude={}".format(altitude))
2884+
args.append("--zfactor={}".format(zfactor))
2885+
if full_mode: args.append("--full_mode")
2886+
return self.run_tool('multidirectional_hillshade', args, callback) # returns 1 if error
2887+
28372888
def multiscale_elevation_percentile(self, dem, out_mag, out_scale, sig_digits=3, min_scale=4, step=1, num_steps=10, step_nonlinearity=1.0, callback=None):
28382889
"""Calculates surface roughness over a range of spatial scales.
28392890
@@ -6164,6 +6215,40 @@ def lidar_remove_outliers(self, i, output, radius=2.0, elev_diff=50.0, use_media
61646215
if classify: args.append("--classify")
61656216
return self.run_tool('lidar_remove_outliers', args, callback) # returns 1 if error
61666217

6218+
def lidar_rooftop_analysis(self, buildings, output, i=None, radius=2.0, num_iter=50, num_samples=10, threshold=0.15, model_size=15, max_slope=65.0, norm_diff=10.0, azimuth=180.0, altitude=30.0, callback=None):
6219+
"""Identifies roof segments in a LiDAR point cloud.
6220+
6221+
Keyword arguments:
6222+
6223+
i -- Input LiDAR file.
6224+
buildings -- Input vector build footprint polygons file.
6225+
output -- Output vector polygon file.
6226+
radius -- Search Radius.
6227+
num_iter -- Number of iterations.
6228+
num_samples -- Number of sample points on which to build the model.
6229+
threshold -- Threshold used to determine inlier points.
6230+
model_size -- Acceptable model size.
6231+
max_slope -- Maximum planar slope.
6232+
norm_diff -- Maximum difference in normal vectors, in degrees.
6233+
azimuth -- Illumination source azimuth in degrees.
6234+
altitude -- Illumination source altitude in degrees.
6235+
callback -- Custom function for handling tool text outputs.
6236+
"""
6237+
args = []
6238+
if i is not None: args.append("--input='{}'".format(i))
6239+
args.append("--buildings='{}'".format(buildings))
6240+
args.append("--output='{}'".format(output))
6241+
args.append("--radius={}".format(radius))
6242+
args.append("--num_iter={}".format(num_iter))
6243+
args.append("--num_samples={}".format(num_samples))
6244+
args.append("--threshold={}".format(threshold))
6245+
args.append("--model_size={}".format(model_size))
6246+
args.append("--max_slope={}".format(max_slope))
6247+
args.append("--norm_diff={}".format(norm_diff))
6248+
args.append("--azimuth={}".format(azimuth))
6249+
args.append("--altitude={}".format(altitude))
6250+
return self.run_tool('lidar_rooftop_analysis', args, callback) # returns 1 if error
6251+
61676252
def lidar_segmentation(self, i, output, radius=2.0, num_iter=50, num_samples=10, threshold=0.15, model_size=15, max_slope=80.0, norm_diff=10.0, maxzdiff=1.0, classes=False, ground=False, callback=None):
61686253
"""Segments a LiDAR point cloud based on differences in the orientation of fitted planar surfaces and point proximity.
61696254

0 commit comments

Comments
 (0)