Skip to content

Commit

Permalink
Added IdwInterpolation, StochasticDepressionAnalysis, and FastAlmostG…
Browse files Browse the repository at this point in the history
…aussianFilter tools

Added IdwInterpolation, StochasticDepressionAnalysis, and
FastAlmostGaussianFilter tools
  • Loading branch information
jblindsay committed May 21, 2018
1 parent f6d6ee3 commit 7874ad5
Show file tree
Hide file tree
Showing 57 changed files with 2,155 additions and 596 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 2 additions & 18 deletions Cargo.toml
Expand Up @@ -9,25 +9,10 @@ readme = "README.md"
repository = "https://github.com/jblindsay/whitebox-geospatial-analysis-tools/whitebox_tools/"
license = "MIT"

# [lib]
# name = "whitebox_tools"
# crate-type = ["dylib"]
# # crate-type = ["rdylib"]
# # crate-type = ["rlib"]
# # crate-type = ["staticlib"]
# path = "src/lib.rs"

# [[bin]]
# name = "whitebox_tools"
# path = "src/main.rs"

# The release profile, used for `cargo build --release`.
# [profile.release]
# codegen-units = 16

[dependencies]
byteorder = "^1.1.0"
# kdtree = "0.4.0"
kdtree = "0.5.1"
lzw = "0.10.0"
nalgebra = "0.14.0"
num_cpus = "1.6.2"
rand = "0.4.2"
Expand All @@ -37,4 +22,3 @@ serde_json = "1.0.9"
statrs = "0.9.0"
time = "^0.1.37"
zip = "0.3.0"
lzw = "0.10.0"
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -161,13 +161,14 @@ The *WhiteboxTools Runner* does not rely on the *Whitebox GAT* user interface at

Eventually most of *Whitebox GAT's* approximately 450 tools [will be ported](tool_porting.md) to *WhiteboxTools*, although this is an immense task. Support for vector data (Shapefile/GeoJSON) reading/writing and a topological analysis library (like the Java Topology Suite) will need to be added in order to port the tools involving vector spatial data. Opportunities to parallelize algorithms will be sought during porting. All new plugin tools will be added to *Whitebox GAT* using this library of functions.

The library currently contains the following 318 tools, which are each grouped based on their main function into one of the following categories: Data Tools, GIS Analysis, Hydrological Analysis, Image Analysis, LiDAR Analysis, Mathematical and Statistical Analysis, Stream Network Analysis, and Terrain Analysis. The following is a complete listing of available tools, with brief tool descriptions.
The library currently contains the following 321 tools, which are each grouped based on their main function into one of the following categories: Data Tools, GIS Analysis, Hydrological Analysis, Image Analysis, LiDAR Analysis, Mathematical and Statistical Analysis, Stream Network Analysis, and Terrain Analysis. The following is a complete listing of available tools, with brief tool descriptions.

**Data Tools**

- ***ConvertNodataToZero***: Converts nodata values in a raster to zero.
- ***ConvertRasterFormat***: Converts raster data from one format to another.
- ***ExportTableToCsv***: Exports an attribute table to a CSV text file.
- ***IdwInterpolation***: Interpolates vector points into a raster surface using an inverse-distance weighted scheme.
- ***NewRasterFromBase***: Creates a new raster using a base image.
- ***PrintGeoTiffTags***: Prints the tags within a GeoTIFF.
- ***SetNodataValue***: Assign a specified value in an input image to the NoData value.
Expand Down Expand Up @@ -298,6 +299,7 @@ The library currently contains the following 318 tools, which are each grouped b
- ***Rho8Pointer***: Calculates a stochastic Rho8 flow pointer raster from an input DEM.
- ***Sink***: Identifies the depressions in a DEM, giving each feature a unique identifier.
- ***SnapPourPoints***: Moves outlet points used to specify points of interest in a watershedding operation to the cell with the highest flow accumulation in its neighbourhood.
- ***StochasticDepressionAnalysis***: Preforms a stochastic analysis of depressions within a DEM.
- ***StrahlerOrderBasins***: Identifies Strahler-order basins from an input stream network.
- ***Subbasins***: Identifies the catchments, or sub-basin, draining to each link in a stream network.
- ***TraceDownslopeFlowpaths***: Traces downslope flowpaths from one or more target sites (i.e. seed points).
Expand All @@ -320,6 +322,7 @@ The library currently contains the following 318 tools, which are each grouped b
- ***DiversityFilter***: Assigns each cell in the output grid the number of different values in a moving window centred on each grid cell in the input raster.
- ***EdgePreservingMeanFilter***: Performs a simple edge-preserving mean filter on an input image.
- ***EmbossFilter***: Performs an emboss filter on an image, similar to a hillshade operation.
- ***FastAlmostGaussianFilter***: Performs a fast approximate Gaussian filter on an image.
- ***FlipImage***: Reflects an image in the vertical or horizontal axis.
- ***GammaCorrection***: Performs a sigmoidal contrast stretch on input images.
- ***GaussianFilter***: Performs a Gaussian filter on an image.
Expand Down
23 changes: 14 additions & 9 deletions build.py
Expand Up @@ -5,6 +5,7 @@
import sys
from subprocess import call


def main():
''' main function
'''
Expand All @@ -23,25 +24,28 @@ def main():
# Update #
retcode = call(['cargo', 'update'], shell=False)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
print("Child was terminated by signal", -
retcode, file=sys.stderr)
else:
print >>sys.stderr, "Update successful"
print("Update successful", file=sys.stderr)

if clean_code:
# Clean #
retcode = call(['cargo', 'clean'], shell=False)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
print("Child was terminated by signal", -
retcode, file=sys.stderr)
else:
print >>sys.stderr, "Clean successful"
print("Clean successful", file=sys.stderr)

if doc_code:
# Clean #
retcode = call(['cargo', 'doc'], shell=False)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
print("Child was terminated by signal", -
retcode, file=sys.stderr)
else:
print >>sys.stderr, "Clean successful"
print("Clean successful", file=sys.stderr)

if build_code:
# Build #
Expand All @@ -54,12 +58,13 @@ def main():
retcode = call(['cargo', 'build'], shell=False)

if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
print("Child was terminated by signal", -
retcode, file=sys.stderr)
else:
print >>sys.stderr, "Build executed successfully"
print("Build executed successfully", file=sys.stderr)

except OSError as err:
print >>sys.stderr, "Execution failed:", err
print("Execution failed:", err, file=sys.stderr)


main()
3 changes: 3 additions & 0 deletions readme.txt
Expand Up @@ -59,7 +59,10 @@ for more details.
Version 0.8.0 (DD-MM-2018)
- Added the following tools:
CornerDetection
FastAlmostGaussianFilter
IdwInterpolation
LidarThin
StochasticDepressionAnalysis
UnsharpMasking
WeightedOverlay
- Modified some filters to take RGB inputs by operating on the intensity value.
Expand Down
8 changes: 6 additions & 2 deletions src/lidar/las.rs
Expand Up @@ -54,6 +54,10 @@ impl Index<usize> for LasFile {

impl LasFile {

/// Constructs a new `LasFile` based on a file.
/// The function takes the name of an existing raster file (`file_name`)
/// and the `file_mode`, wich can be 'r' (read), 'rh' (read header), and
/// 'w' (write).
pub fn new<'a>(file_name: &'a str, file_mode: &'a str) -> Result<LasFile, Error> { //LasFile {
let mut lf = LasFile { file_name: file_name.to_string(), ..Default::default() };
lf.file_mode = file_mode.to_lowercase();
Expand All @@ -68,8 +72,8 @@ impl LasFile {
Ok(lf)
}

/// This function returns a new LasFile that has been initialized using another
/// LasFile.
/// This function returns a new `LasFile` that has been initialized using another
/// `LasFile`.
/// Input Parameters:
/// * file_name: The name of the LAS file to be created.
/// * input: An existing LAS file.
Expand Down
5 changes: 5 additions & 0 deletions src/lidar/mod.rs
Expand Up @@ -18,6 +18,11 @@ pub use self::las::PointRecord2;
pub use self::las::PointRecord3;
pub use self::las::PointRecord4;
pub use self::las::PointRecord5;
pub use self::las::PointRecord6;
pub use self::las::PointRecord7;
pub use self::las::PointRecord8;
pub use self::las::PointRecord9;
pub use self::las::PointRecord10;
pub use self::point_data::PointData;
pub use self::point_data::ColourData;
pub use self::point_data::WaveformPacket;
Expand Down
33 changes: 30 additions & 3 deletions src/main.rs
Expand Up @@ -6,15 +6,42 @@ Last Modified: February 7, 2018
License: MIT
*/

/*!
WhiteboxTools is an advanced geospatial data analysis platform developed at
the University of Guelph's Geomorphometry and Hydrogeomatics Research Group (GHRG).
WhiteboxTools is a command-line program and can be run either by calling it,
with appropriate commands and arguments, from a terminal application, or, more
conveniently, by calling it from a script. The following commands are recognized
by the WhiteboxTools library:
| Command | Description |
| ----------------- | ------------------------------------------------------------------------------------------------- |
| --cd, --wd | Changes the working directory; used in conjunction with --run flag. |
| -h, --help | Prints help information. |
| -l, --license | Prints the whitebox-tools license. |
| --listtools | Lists all available tools, with tool descriptions. Keywords may also be used, --listtools slope. |
| -r, --run | Runs a tool; used in conjunction with --cd flag; -r="LidarInfo". |
| --toolbox | Prints the toolbox associated with a tool; --toolbox=Slope. |
| --toolhelp | Prints the help associated with a tool; --toolhelp="LidarInfo". |
| --toolparameters | Prints the parameters (in json form) for a specific tool; --toolparameters=\"LidarInfo\". |
| -v | Verbose mode. Without this flag, tool outputs will not be printed. |
| --viewcode | Opens the source code of a tool in a web browser; --viewcode=\"LidarInfo\". |
| --version | Prints the version information. |
*/


extern crate byteorder;
extern crate kdtree;
extern crate lzw;
extern crate nalgebra as na;
extern crate num_cpus;
extern crate serde;
extern crate serde_json;
extern crate nalgebra as na;
extern crate time;
extern crate num_cpus;
extern crate rand;
extern crate statrs;
extern crate lzw;

pub mod io_utils;
pub mod lidar;
Expand Down
23 changes: 23 additions & 0 deletions src/structures/array2d.rs
Expand Up @@ -5,6 +5,7 @@ use std::io::Error;
use std::io::ErrorKind;
use std::ops::{AddAssign, SubAssign, Index, IndexMut};

#[derive(Debug)]
pub struct Array2D<T: Copy + AddAssign + SubAssign> {
pub columns: isize,
pub rows: isize,
Expand Down Expand Up @@ -83,6 +84,28 @@ impl<T> Array2D<T> where T: Copy + AddAssign + SubAssign {
values
}

/// Increments an entire row of data at one time.
pub fn increment_row_data(&mut self, row: isize, values: Vec<T>) {
for column in 0..values.len() as isize {
if row >= 0 {
if column < self.columns && row < self.rows {
self.data[(row * self.columns + column) as usize] += values[column as usize];
}
}
}
}

/// Decrements an entire row of data at one time.
pub fn decrement_row_data(&mut self, row: isize, values: Vec<T>) {
for column in 0..values.len() as isize {
if row >= 0 {
if column < self.columns && row < self.rows {
self.data[(row * self.columns + column) as usize] -= values[column as usize];
}
}
}
}

pub fn set_data_from_other(&mut self, other: &Array2D<T>) -> Result<(), Error> {
if self.rows != other.rows || self.columns != other.columns {
return Err(Error::new(ErrorKind::Other,
Expand Down

0 comments on commit 7874ad5

Please sign in to comment.