Skip to content

Commit f5cc363

Browse files
committed
Fixed a minor bug with the VectorPolygonsToRaster tool
Fixed a minor bug with the VectorPolygonsToRaster tool
1 parent 6aba2cb commit f5cc363

9 files changed

Lines changed: 96 additions & 12 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[package]
33
name = "whitebox_tools"
4-
version = "1.0.0"
4+
version = "1.0.1"
55
authors = ["John Lindsay <jlindsay@uoguelph.ca>"]
66
description = "A library for analyzing geospatial data."
77
keywords = ["geospatial", "GIS", "remote sensing", "geomatics", "image processing", "lidar", "spatial analysis"]

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ for more details.
5656
* Release Notes: *
5757
******************
5858

59+
Version 1.0.1 (XX-XX-2019)
60+
- Fixed a minor bug with the VectorPolygonToRaster tool.
61+
5962
Version 1.0.0 (29-09-2019)
6063
- Added support for reading and writing the BigTIFF format. This has resulted in numerous changes
6164
throughout the codebase as a result of significant modification of ByteOrderReader and addition

src/tools/data_tools/vector_polygons_to_raster.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,9 @@ impl WhiteboxTool for VectorPolygonsToRaster {
453453
ending_col = columns - 1;
454454
}
455455

456-
for r in starting_row..ending_row {
456+
for r in starting_row..=ending_row {
457457
y = output.get_y_from_row(r);
458-
for c in starting_col..ending_col {
458+
for c in starting_col..=ending_col {
459459
x = output.get_x_from_column(c);
460460
if point_in_poly(
461461
&Point2D { x: x, y: y },
@@ -467,7 +467,7 @@ impl WhiteboxTool for VectorPolygonsToRaster {
467467
}
468468
if verbose {
469469
progress = (100.0_f64 * r as f64
470-
/ (ending_row - starting_row) as f64)
470+
/ (ending_row - starting_row + 1) as f64)
471471
as usize;
472472
if progress != old_progress {
473473
println!(
@@ -540,9 +540,9 @@ impl WhiteboxTool for VectorPolygonsToRaster {
540540
ending_col = columns - 1;
541541
}
542542

543-
for r in starting_row..ending_row {
543+
for r in starting_row..=ending_row {
544544
y = output.get_y_from_row(r);
545-
for c in starting_col..ending_col {
545+
for c in starting_col..=ending_col {
546546
x = output.get_x_from_column(c);
547547
if point_in_poly(
548548
&Point2D { x: x, y: y },
@@ -556,7 +556,7 @@ impl WhiteboxTool for VectorPolygonsToRaster {
556556
}
557557
if verbose {
558558
progress = (100.0_f64 * r as f64
559-
/ (ending_row - starting_row) as f64)
559+
/ (ending_row - starting_row + 1) as f64)
560560
as usize;
561561
if progress != old_progress {
562562
println!(

src/tools/hydro_analysis/dinf_flow_accum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use std::thread;
4848
/// elevation models. Water resources research, 33(2), 309-319.
4949
///
5050
/// # See Also
51-
/// `BreachDepressions`, `FillDepressions`
51+
/// `DInfPointer`, `BreachDepressions`, `FillDepressions`
5252
pub struct DInfFlowAccumulation {
5353
name: String,
5454
description: String,

src/tools/hydro_analysis/dinf_pointer.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This tool is part of the WhiteboxTools geospatial analysis library.
33
Authors: Dr. John Lindsay
4-
Created: June 26, 2017
4+
Created: 26/06/2017
55
Last Modified: 12/10/2018
66
License: MIT
77
*/
@@ -18,6 +18,27 @@ use std::sync::mpsc;
1818
use std::sync::Arc;
1919
use std::thread;
2020

21+
/// This tool is used to generate a flow pointer grid (i.e. flow direction) using the D-infinity
22+
/// (Tarboton, 1997) algorithm. Dinf is a multiple-flow-direction (MFD) method because the flow
23+
/// entering each grid cell is routed one or two downslope neighbours, i.e. flow divergence is permitted.
24+
/// The user must specify the name of a digital elevation model (DEM; `--dem`) that has been hydrologically
25+
/// corrected to remove all spurious depressions and flat areas (`BreachDepressions`, `FillDepressions`).
26+
/// DEM pre-processing is usually achieved using the `BreachDepressions` or `FillDepressions` tool1. Flow
27+
/// directions are specified in the output flow-pointer grid (`--output`) as azimuth degrees measured from
28+
/// north, i.e. any value between 0 and 360 degrees is possible. A pointer value of -1 is used to designate
29+
/// a grid cell with no flow-pointer. This occurs when a grid cell has no downslope neighbour, i.e. a pit
30+
/// cell or topographic depression. Like aspect grids, Dinf flow-pointer grids are best visualized using
31+
/// a circular greyscale palette.
32+
///
33+
/// Grid cells possessing the NoData value in the input DEM are assigned the NoData value in the output
34+
/// image. The output raster is of the float data type and continuous data scale.
35+
///
36+
/// # Reference
37+
/// Tarboton, D. G. (1997). A new method for the determination of flow directions and upslope areas in
38+
/// grid digital elevation models. Water resources research, 33(2), 309-319.
39+
///
40+
/// # See Also
41+
/// `DInfFlowAccumulation`, `BreachDepressions`, `FillDepressions`
2142
pub struct DInfPointer {
2243
name: String,
2344
description: String,

src/tools/hydro_analysis/downslope_flowpath_length.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This tool is part of the WhiteboxTools geospatial analysis library.
33
Authors: Dr. John Lindsay
4-
Created: July 8, 2017
4+
Created: 08/07/2017
55
Last Modified: 29/10/2018
66
License: MIT
77
*/
@@ -14,6 +14,29 @@ use std::f64;
1414
use std::io::{Error, ErrorKind};
1515
use std::path;
1616

17+
/// This tool can be used to calculate the downslope flowpath length from each grid cell in a raster to
18+
/// an outlet cell either at the edge of the grid or at the outlet point of a watershed. The user must
19+
/// specify the name of a flow pointer grid (`--d8_pntr`) derived using the D8 flow algorithm (`D8Pointer`).
20+
/// This grid should be derived from a digital elevation model (DEM) that has been pre-processed to remove
21+
/// artifact topographic depressions and flat areas (`BreachDepressions`, `FillDepressions`). The user may also
22+
/// optionally provide watershed (`--watersheds`) and weights (`--weights`) images. The optional watershed
23+
/// image can be used to define one or more irregular-shaped watershed boundaries. Flowpath lengths are
24+
/// measured within each watershed in the watershed image (each defined by a unique identifying number) as
25+
/// the flowpath length to the watershed's outlet cell.
26+
///
27+
/// The optional weight image is multiplied by the flow-length through each grid cell. This can be useful
28+
/// when there is a need to convert the units of the output image. For example, the default unit of
29+
/// flowpath lengths is the same as the input image(s). Thus, if the input image has X-Y coordinates
30+
/// measured in metres, the output image will likely contain very large values. A weight image containing
31+
/// a value of 0.001 for each grid cell will effectively convert the output flowpath lengths into kilometres.
32+
/// The weight image can also be used to convert the flowpath distances into travel times by multiplying the
33+
/// flow distance through a grid cell by the average velocity.
34+
///
35+
/// NoData valued grid cells in any of the input images will be assigned NoData values in the output image.
36+
/// The output raster is of the float data type and continuous data scale.
37+
///
38+
/// # See Also
39+
/// `D8Pointer`, `ElevationAboveStream`, `BreachDepressions`, `FillDepressions`, `Watershed`
1740
pub struct DownslopeFlowpathLength {
1841
name: String,
1942
description: String,

src/tools/hydro_analysis/num_inflowing_neighbours.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This tool is part of the WhiteboxTools geospatial analysis library.
33
Authors: Dr. John Lindsay
4-
Created: June 25, 2017
4+
Created: 25/06/2017
55
Last Modified: 12/10/2018
66
License: MIT
77
*/
@@ -18,6 +18,16 @@ use std::sync::mpsc;
1818
use std::sync::Arc;
1919
use std::thread;
2020

21+
/// This tool calculates the number of inflowing neighbours for each grid cell in a raster file. The user
22+
/// must specify the names of an input digital elevation model (DEM) file (`--dem`) and the output raster
23+
/// file (`--output`). The tool calculates the D8 pointer file internally in order to identify inflowing
24+
/// neighbouring cells.
25+
///
26+
/// Grid cells in the input DEM that contain the NoData value will be assigned the NoData value in the
27+
/// output image. The output image is of the integer data type and continuous data scale.
28+
///
29+
/// # See Also
30+
/// `NumDownslopeNeighbours`, `NumUpslopeNeighbours`
2131
pub struct NumInflowingNeighbours {
2232
name: String,
2333
description: String,

src/tools/hydro_analysis/rho8_pointer.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This tool is part of the WhiteboxTools geospatial analysis library.
33
Authors: Dr. John Lindsay
4-
Created: July 16, 2017
4+
Created: 16/07/2017
55
Last Modified: 12/10/2018
66
License: MIT
77
*/
@@ -18,6 +18,33 @@ use std::sync::mpsc;
1818
use std::sync::Arc;
1919
use std::thread;
2020

21+
/// This tool is used to generate a flow pointer grid (i.e. flow direction) using the stochastic
22+
/// Rho8 (J. Fairfield and P. Leymarie, 1991) algorithm. Like the D8 flow algorithm (`D8Pointer`),
23+
/// Rho8 is a single-flow-direction (SFD) method because the flow entering each grid cell is routed
24+
/// to only one downslope neighbour, i.e. flow divergence is not permitted. The user must specify the
25+
/// name of a digital elevation model (DEM) file (`--dem`) that has been hydrologically corrected to
26+
/// remove all spurious depressions and flat areas (`BreachDepressions`, `FillDepressions`).
27+
///
28+
/// By default, the Rho8 flow pointers use the following clockwise, base-2 numeric index convention:
29+
///
30+
/// | . | . | . |
31+
/// |:--:|:---:|:--:|
32+
/// | 64 | 128 | 1 |
33+
/// | 32 | 0 | 2 |
34+
/// | 16 | 8 | 4 |
35+
///
36+
/// Notice that grid cells that have no lower neighbours are assigned a flow direction of zero. In a DEM that has been
37+
/// pre-processed to remove all depressions and flat areas, this condition will only occur along the edges of the grid.
38+
/// If the pointer file contains ESRI flow direction values instead, the `--esri_pntr` parameter must be specified.
39+
///
40+
/// Grid cells possessing the NoData value in the input DEM are assigned the NoData value in the output image.
41+
///
42+
/// # References
43+
/// Fairfield, J., & Leymarie, P. (1991). Drainage networks from grid digital elevation models. Water
44+
/// Resources Research, 27(5), 709-717.
45+
///
46+
/// # See Also
47+
/// `D8Pointer`, `FD8Pointer`, `DInfPointer`, `BreachDepressions`, `FillDepressions`
2148
pub struct Rho8Pointer {
2249
name: String,
2350
description: String,

0 commit comments

Comments
 (0)