Skip to content

Commit

Permalink
Update in prep for v0.14
Browse files Browse the repository at this point in the history
Update in prep for v0.14
  • Loading branch information
jblindsay committed Jan 27, 2019
1 parent 3609a99 commit 03ebe93
Show file tree
Hide file tree
Showing 42 changed files with 1,806 additions and 486 deletions.
421 changes: 1 addition & 420 deletions README.md

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,20 @@ for more details.
* Release Notes: *
******************

Version 0.14.0 (xx-xx-2019)
Version 0.14.0 (27-01-2019)
- The release largely focusses on bug-fixes rather than adding new features. The
following tools were added to the project:
CircularVarianceOfAspect
EdgeDensity
SurfaceAreaRatio

- Fixed a bug that resulted in rasters with projected coordinate systems being
interpreted as geographic coordinates, thereby messing up the calculation of
inter-cell distances for tools like slope, aspect, curvature, etc.
- Fixed a bug with several of the math tools; output files took their data type
from the input file. In some cases, this does not work well because the input
is integer and the output must be floating point data.


Version 0.13.0 (08-01-2019)
- The release largely focusses on bug-fixes rather than adding new features. The
Expand Down
10 changes: 5 additions & 5 deletions src/raster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,13 @@ impl Raster {
output.configs.geo_key_directory = input.configs.geo_key_directory.clone();
output.configs.geo_double_params = input.configs.geo_double_params.clone();
output.configs.geo_ascii_params = input.configs.geo_ascii_params.clone();

if output.raster_type == RasterType::SurferAscii
|| output.raster_type == RasterType::Surfer7Binary
{
output.configs.nodata = 1.71041e38;
}

output.data = vec![output.configs.nodata; output.configs.rows * output.configs.columns];

output
}

Expand Down Expand Up @@ -1000,7 +998,7 @@ impl Raster {
return true;
}
let wkt = self.configs.coordinate_ref_system_wkt.to_lowercase();
if !wkt.contains("projcs[") {
if !wkt.contains("projcs[") && !wkt.to_lowercase().contains("not specified") {
return true;
}
if self.configs.xy_units.to_lowercase().contains("deg") {
Expand Down Expand Up @@ -1115,7 +1113,9 @@ fn get_raster_type_from_file(file_name: String, file_mode: String) -> RasterType
Some(n) => n.to_string().to_lowercase(),
None => "".to_string(),
};

if extension.is_empty() {
panic!("The file type could not be determined for the file:\n{}\n due to missing extension.", file_name);
}
if extension == "tas" || extension == "dep" {
return RasterType::Whitebox;
} else if extension == "tif" || extension == "tiff" {
Expand Down
35 changes: 17 additions & 18 deletions src/tools/data_tools/set_nodata_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 10/09/2017
Last Modified: 12/10/2018
Last Modified: 24/01/2019
License: MIT
*/

Expand Down Expand Up @@ -151,26 +151,25 @@ impl WhiteboxTool for SetNodataValue {
if vec.len() > 1 {
keyval = true;
}
if vec[0].to_lowercase() == "-i" || vec[0].to_lowercase() == "--input" {
if keyval {
input_file = vec[1].to_string();
let flag_val = vec[0].to_lowercase().replace("--", "-");
if flag_val == "-i" || flag_val == "-input" {
input_file = if keyval {
vec[1].to_string()
} else {
input_file = args[i + 1].to_string();
}
} else if vec[0].to_lowercase() == "-o" || vec[0].to_lowercase() == "--output" {
if keyval {
output_file = vec[1].to_string();
args[i + 1].to_string()
};
} else if flag_val == "-o" || flag_val == "-output" {
output_file = if keyval {
vec[1].to_string()
} else {
output_file = args[i + 1].to_string();
}
} else if vec[0].to_lowercase() == "-back_value"
|| vec[0].to_lowercase() == "--back_value"
{
if keyval {
back_value = vec[1].to_string().parse().unwrap();
args[i + 1].to_string()
};
} else if flag_val == "-back_value" {
back_value = if keyval {
vec[1].to_string().parse().unwrap()
} else {
back_value = args[i + 1].parse().unwrap();
}
args[i + 1].parse().unwrap()
};
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/tools/gis_analysis/average_overlay.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: June 22 2017
Created: 22/06/2017
Last Modified: 13/10/2018
License: MIT
*/
Expand All @@ -15,6 +15,15 @@ use std::i16;
use std::io::{Error, ErrorKind};
use std::path;

/// This tool can be used to find the average value in each cell of a grid from a set of input images (`--inputs`).
/// It is therefore similar to the `WeightedSum` tool except that each input image is given equal weighting. This
/// tool operates on a cell-by-cell basis. Therefore, each of the input rasters must share the same number of rows
/// and columns and spatial extent. An error will be issued if this is not the case. At least two input rasters are
/// required to run this tool. Like each of the WhiteboxTools overlay tools, this tool has been optimized for
/// parallel processing.
///
/// # See Also
/// `WeightedSum`
pub struct AverageOverlay {
name: String,
description: String,
Expand Down
11 changes: 11 additions & 0 deletions src/tools/gis_analysis/clip_raster_to_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ use std::env;
use std::io::{Error, ErrorKind};
use std::path;

/// This tool can be used to clip an input raster (`--input`) to the extent of a vector polygon (shapefile). The user
/// must specify the name of the input clip file (`--polygons`), wich must be a vector of a Polygon base shape type.
/// The clip file may contain multiple polygon features. Polygon hole parts will be respected during clipping, i.e.
/// polygon holes will be removed from the output raster by setting them to a NoData background value. Raster grid
/// cells that fall outside of a polygons in the clip file will be assigned the NoData background value in the output
/// file. By default, the output raster will be cropped to the spatial extent of the clip file, unless the
/// `--maintain_dimensions` parameter is used, in which case the output grid extent will match that of the input raster.
/// The grid resolution of output raster is the same as the input raster.
///
/// # See Also
/// `ErasePolygonFromRaster`
pub struct ClipRasterToPolygon {
name: String,
description: String,
Expand Down
8 changes: 8 additions & 0 deletions src/tools/gis_analysis/count_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ use std::f64;
use std::io::{Error, ErrorKind};
use std::path;

/// This tool counts the number of occurrences of a specified value (`--value`) in a stack of input rasters
/// (`--inputs`). Each grid cell in the output raster (`--output`) will contain the number of occurrences
/// of the specified value in the stack of cooresponding cells in the input image. At least two input rasters
/// are required to run this tool. Each of the input rasters must share the same number of rows and columns and
/// spatial extent. An error will be issued if this is not the case.
///
/// # See Also
/// `PickFromList`
pub struct CountIf {
name: String,
description: String,
Expand Down
3 changes: 3 additions & 0 deletions src/tools/gis_analysis/eliminate_coincident_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use std::path;
/// distance. All points that are within the specified tolerance distance will be
/// eliminated from the output file. A tolerance distance of 0.0 indicates that
/// points must be exactly coincident to be removed.
///
/// # See Also
/// `LidarRemoveDuplicates`
pub struct EliminateCoincidentPoints {
name: String,
description: String,
Expand Down
8 changes: 8 additions & 0 deletions src/tools/gis_analysis/erase_polygon_from_raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ use std::env;
use std::io::{Error, ErrorKind};
use std::path;

/// This tool can be used to set values an input raster (`--input`) to a NoData background value with a vector
/// erasing polygon (`--polygons`). The input erase polygon file must be a vector of a Polygon base shape type.
/// The erase file may contain multiple polygon features. Polygon hole parts will be respected during clipping, i.e.
/// polygon holes will not be removed from the output raster. Raster grid cells that fall inside of a polygons in
/// the erase file will be assigned the NoData background value in the output file.
///
/// # See Also
/// `ClipRasterToPolygon`
pub struct ErasePolygonFromRaster {
name: String,
description: String,
Expand Down
14 changes: 13 additions & 1 deletion src/tools/gis_analysis/pick_from_list.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: June 22 2017
Created: 22/06/2017
Last Modified: 13/10/2018
License: MIT
*/
Expand All @@ -13,6 +13,18 @@ use std::f64;
use std::io::{Error, ErrorKind};
use std::path;

/// This tool outputs the cell value from a raster stack specified (`--inputs`) by a position raster (`--pos_input`). The
/// user must specify the name of the position raster, the names of the raster files contained in the stack (i.e. group
/// of rasters), and an output raster file name (`--output`). The tool, working on a cell-by-cell basis, will assign the
/// value to the output grid cell contained in the corresponding cell in the stack image in the position specified by the
/// cell value in the position raster. Importantly, the positions raster should be in zero-based order. That is, the first
/// image in the stack should be assigned the value zero, the second raster is assigned 1, and so on.
///
/// At least two input rasters are required to run this tool. Each of the input rasters must share the same number of rows
/// and columns and spatial extent. An error will be issued if this is not the case.
///
/// # See Also
/// `CountIf`
pub struct PickFromList {
name: String,
description: String,
Expand Down
24 changes: 23 additions & 1 deletion src/tools/hydro_analysis/fill_depressions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: June 28, 2017
Created: 28/06/2017
Last Modified: 12/10/2018
License: MIT
*/
Expand All @@ -17,6 +17,28 @@ use std::i32;
use std::io::{Error, ErrorKind};
use std::path;

/// This tool can be used to fill all of the depressions in a digital elevation model (DEM) and to remove the f
/// lat areas. This is a common pre-processing step required by many flow-path analysis tools to ensure continuous
/// flow from each grid cell to an outlet located along the grid edge. The `FillDepressions` algorithm is based on
/// the computationally efficient approach of examining each cell based on its spill elevation, starting from the
/// edge cells, and visiting cells from lowest order using a priority queue. As such, it is based on the algorithm
/// first proposed by Wang and Liu (2006). It is currently the most efficient depression-removal algorithm available
/// in WhiteboxTools, although it is not significantly more efficient than the `BreachDepressions` tool, which is
/// known to provide a solution to depression removal with less impact of the DEM.
///
/// If the input DEM has gaps, or missing-data holes, that contain NoData values, it is better to use the
/// `FillMissingData` tool to repair these gaps. This tool will interpolate values across the gaps and produce
/// a more natural-looking surface than the flat areas that are produced by depression filling. Importantly, the
/// `FillDepressions` tool algorithm implementation assumes that there are no 'donut hole' NoData gaps within the area
/// of valid data. Any NoData areas along the edge of the grid will simply be ignored and will remain NoData areas in
/// the output image.
///
/// # Reference
/// Wang, L. and Lui, H. 2006. An efficient method for identifying and filling surface depressions in digital elevation
/// models for hydrologic analysis and modelling. International Journal of Geographical Information Science, 20(2): 193-213.
///
/// # See Also
/// `BreachDepressions`, `FillMissingData`
pub struct FillDepressions {
name: String,
description: String,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/image_analysis/fast_almost_gaussian_filter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 19/05/2019
Created: 19/05/2018
Last Modified: 19/05/2018
License: MIT
*/
Expand Down
13 changes: 12 additions & 1 deletion src/tools/image_analysis/gaussian_contrast_stretch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@ use std::sync::mpsc;
use std::sync::Arc;
use std::thread;

/// Performs a Gaussian contrast stretch on input images.
/// This tool performs a Gaussian stretch on a raster image. The observed histogram of the input image is fitted
/// to a Gaussian histogram, i.e. normal distribution. A histogram matching technique is used to map the values from
/// the input image onto the output Gaussian distribution. The user must the number of tones (`--num_tones`) used in the
/// output image.
///
/// This tool is related to the more general `HistogramMatching` tool, which can be used to fit any frequency distribution
/// to an input image, and other contrast enchancement tools such as `HistogramEqualization`, `MinMaxContrastStretch`,
/// `PercentageContrastStretch`, `SigmoidalContrastStretch`, and `StandardDeviationContrastStretch`.
///
/// # See Also
/// `HistogramEqualization`, `MinMaxContrastStretch`, `PercentageContrastStretch`, `SigmoidalContrastStretch`,
/// `StandardDeviationContrastStretch`, `HistogramMatching`
pub struct GaussianContrastStretch {
name: String,
description: String,
Expand Down
19 changes: 19 additions & 0 deletions src/tools/image_analysis/min_max_contrast_stretch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ use std::sync::mpsc;
use std::sync::Arc;
use std::thread;

/// This tool performs a minimum-maximum contrast stretch on a raster image. This operation maps each grid cell
/// value in the input raster image (z) onto a new scale that ranges from the user-specified lower-tail clip
/// value (`min_val`) to the upper-tail clip value (`max_val`), with the specified number of tonal values
/// (`num_tones`), such that:
///
/// > z<sub>out</sub> = ((z<sub>in</sub> – min_val)/(max_val – min_val)) x num_tones
///
/// where z<sub>out</sub> is the output value. Notice that any values in the input image that are less than
/// `min_val` are assigned a value of `min_val` in the output image. Similarly, any input values greater than
/// `max_val` are assigned a value of `max_val` in the output image.
///
/// This is a type of linear contrast stretch with saturation at the tails of the frequency distribution. This is
/// the same kind of stretch that is used to display raster type data on the fly in many GIS software packages,
/// such that the lower and upper tail values are set using the minimum and maximum display values and the number
/// of tonal values is determined by the number of palette entries.
///
/// # See Also
/// `GaussianContrastStretch`, `HistogramEqualization`, `PercentageContrastStretch`, `SigmoidalContrastStretch`,
/// `StandardDeviationContrastStretch`
pub struct MinMaxContrastStretch {
name: String,
description: String,
Expand Down
21 changes: 20 additions & 1 deletion src/tools/image_analysis/percentage_contrast_stretch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,26 @@ use std::sync::mpsc;
use std::sync::Arc;
use std::thread;

/// Performs a percentage linear contrast stretch on input images.
/// This tool performs a percentage contrast stretch on a raster image. This operation maps each grid cell value
/// in the input raster image (z<sub>in</sub>) onto a new scale that ranges from a lower-tail clip value (`min_val`)
/// to the upper-tail clip value (`max_val`), with the user-specified number of tonal values (`num_tones`), such that:
///
/// > z<sub>out</sub> = ((z<sub>in</sub> – min_val)/(max_val – min_val)) x num_tones
///
/// where z<sub>out</sub> is the output value. The values of `min_val` and `max_val` are determined from the frequency
/// distribution and the user-specified tail clip value (`--clip`). For example, if a value of 1% is specified, the tool
/// will determine the values in the input image for which 1% of the grid cells have a lower value `min_val` and 1% of
/// the grid cells have a higher value `max_val`. The user must also specify which tails (upper, lower, or both) to clip
/// (`--tail`).
///
/// This is a type of linear contrast stretch with saturation at the tails of the frequency distribution. This is
/// the same kind of stretch that is used to display raster type data on the fly in many GIS software packages,
/// such that the lower and upper tail values are set using the minimum and maximum display values and the number
/// of tonal values is determined by the number of palette entries.
///
/// # See Also
/// `GaussianContrastStretch`, `HistogramEqualization`, `MinMaxContrastStretch`, `SigmoidalContrastStretch`,
/// `StandardDeviationContrastStretch`
pub struct PercentageContrastStretch {
name: String,
description: String,
Expand Down
8 changes: 6 additions & 2 deletions src/tools/lidar_analysis/remove_duplicates.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: March 1, 2018
Created: 01/03/2018
Last Modified: 12/10/2018
License: MIT
*/
Expand All @@ -18,7 +18,11 @@ use std::sync::mpsc;
use std::sync::Arc;
use std::thread;

/// Removes duplicate points from a LiDAR data set.
/// This tool removes duplicate points from a LiDAR data set. Duplicates are determined
/// by their x, y, and optionally (`--include_z`) z coordinates.
///
/// # See Also
/// `EliminateCoincidentPoints`
pub struct LidarRemoveDuplicates {
name: String,
description: String,
Expand Down
Loading

0 comments on commit 03ebe93

Please sign in to comment.