LSDTopoTools
 All Classes Files Functions Variables Friends Pages
Public Member Functions | Protected Attributes | Friends | List of all members
LSDRaster Class Reference

Main analysis object to interface with other LSD objects. More...

#include <LSDRaster.hpp>

Inheritance diagram for LSDRaster:
LSDCatchmentModel LSDRasterMaker LSDRasterSpectral LSDSoilHydroRaster LSDModelDriver LSDRasterModel LSDModelDriver

Public Member Functions

 LSDRaster ()
 The create function. This is default and throws an error.
 
 LSDRaster (string filename, string extension)
 Create an LSDRaster from a file. Uses a filename and file extension. More...
 
 LSDRaster (int nrows, int ncols, float xmin, float ymin, float cellsize, float ndv, Array2D< float > data)
 Create an LSDRaster from memory. More...
 
 LSDRaster (int nrows, int ncols, double xmin, double ymin, double cellsize, double ndv, Array2D< double > data)
 Create an LSDRaster from memory, with the elvation data stored as double precision floats. More...
 
 LSDRaster (int nrows, int ncols, float xmin, float ymin, float cellsize, float ndv, Array2D< float > data, map< string, string > temp_GRS)
 Create an LSDRaster from memory, includes georeferencing. More...
 
int get_NRows () const
 
int get_NCols () const
 
float get_XMinimum () const
 
float get_YMinimum () const
 
float get_DataResolution () const
 
int get_NoDataValue () const
 
Array2D< float > get_RasterData () const
 
Array2D< double > get_RasterData_dbl () const
 Get the raw raster data, double format. More...
 
Array2D< int > get_RasterData_int () const
 Get the raw raster data, integer format. More...
 
map< string, string > get_GeoReferencingStrings () const
 
float get_data_element (int row, int column)
 Get the raster data at a specified location. More...
 
void set_data_element (int row, int column, float value)
 Sets the raster data at a specified location. More...
 
LSDRasteroperator= (const LSDRaster &LSDR)
 Assignment operator.
 
void read_raster (string filename, string extension)
 Read a raster into memory from a file. More...
 
TNT::Array2D< double > get_ascii_raster (string FILENAME)
 Reads a raster from an ascii file for use in LSDCatchmentModel. More...
 
void read_ascii_raster (string FILENAME)
 
void read_ascii_raster_integers (string FILENAME)
 Reads a raster of integers and populates LSDRaster integer array member data. More...
 
void write_raster (string filename, string extension)
 Read a raster from memory to a file. More...
 
void write_double_raster (string filename, string extension)
 This calls raster write functions, writing from Arrays of type <double> to raster format. More...
 
void write_double_asc_raster (string string_filename)
 Writes out a double array to an ascii.
 
void write_double_flt_raster (string filename, string string_filename)
 Writes out a double array to a binary flt file.
 
void write_double_bil_raster (string filename, string string_filename)
 Writes out a double array to a ENVI bil file (untested!) More...
 
bool does_raster_have_same_dimensions (LSDRaster &Compare_raster)
 Checks to see if two rasters have the same dimensions Does NOT check georeferencing. More...
 
bool does_raster_have_same_dimensions (LSDIndexRaster &Compare_raster)
 Checks to see if two rasters have the same dimensions Does NOT check georeferencing. More...
 
bool does_raster_have_same_dimensions_and_georeferencing (LSDRaster &Compare_raster)
 Checks to see if two rasters have the same georeferencing. More...
 
bool does_raster_have_same_dimensions_and_georeferencing (LSDIndexRaster &Compare_raster)
 Checks to see if two rasters have the same georeferencing. More...
 
map< string, string > Update_GeoReferencingStrings (float NewXmin, float NewYmax)
 Method which takes a new xmin and ymax value and modifys the GeoReferencingStrings map_info line to contain these new values. More...
 
void Update_GeoReferencingStrings ()
 Method which updates the map info element of the georeferencing strings based on information within the datamembers of the raster. More...
 
void impose_georeferencing_UTM (int zone, string NorS)
 This method imposes georefereing strings assuming the coordinate system is UTM. More...
 
int Find_UTM_central_meridian (int UTM_zone)
 This method looks up the central meridian given a UTM zone. More...
 
void get_UTM_information (int &UTM_zone, bool &is_North)
 this function gets the UTM_zone and a boolean that is true if the map is in the northern hemisphere More...
 
void get_x_and_y_locations (int row, int col, double &x_loc, double &y_loc)
 this gets the x and y location of a node at row and column More...
 
void get_x_and_y_locations (int row, int col, float &x_loc, float &y_loc)
 this gets the x and y location of a node at row and column More...
 
void get_lat_and_long_locations (int row, int col, double &lat, double &longitude, LSDCoordinateConverterLLandUTM Converter)
 a function to get the lat and long of a node in the raster Assumes WGS84 ellipsiod More...
 
void get_easting_and_northing_vectors (vector< float > &Eastings, vector< float > &Northings)
 This returns vectors of all the easting and northing points in the raster Used for interpolations. More...
 
vector< float > interpolate_points_bilinear (vector< float > UTMEvec, vector< float > UTMNvec)
 This interpolates a vector of points onto the raster. Uses bilinear interpolation. More...
 
LSDRaster fill_with_interpolated_data (vector< int > rows_of_nodes, vector< int > cols_of_nodes, vector< float > interpolated_data)
 This fills a raster with precalculated interpolated data. More...
 
float get_value_of_point (float UTME, float UTMN)
 This gets the value at a point in UTM coordinates. More...
 
bool check_if_point_is_in_raster (float X_coordinate, float Y_coordinate)
 this check to see if a point is within the raster More...
 
void get_row_and_col_of_a_point (float X_coordinate, float Y_coordinate, int &row, int &col)
 Gets the row and column of a point in the raster. More...
 
vector< float > get_XY_MinMax ()
 This function returns a vector with the X adn Y minimum and max values. More...
 
vector< float > get_RasterData_vector ()
 This function returns the raster data as a vector. More...
 
vector< float > get_RasterData_vector_No_NDVs ()
 This function returns the raster data as a vector, ignoring NDVs. More...
 
void write_RasterData_to_text_file (string filename)
 This function returns the raster data as text file. More...
 
void rewrite_with_random_values (float range)
 rewrite all the data array values with random numbers (with a uniform distribution). More...
 
LSDRaster create_raster_nodata ()
 Create a raster in of the same number of rows and cols with nodata. More...
 
LSDRaster RasterTrimmer ()
 Calculate the minimum bounding rectangle for an LSDRaster Object and crop out all the surrounding NoDataValues to reduce the size and load times of output rasters. More...
 
LSDRaster RasterTrimmerPadded (int padded_pixels)
 Calculate the minimum bounding rectangle for an LSDRaster Object and crop out all the surrounding NoDataValues to reduce the size and load times of output rasters. Similar to RasterTrimmer but has a pixel buffer. Useful for CRN data since sometimes the channel in the DEM does not correspond exactly with the data point. More...
 
LSDRaster RasterTrimmerSpiral ()
 Takes a raster and trims nodata from around the edges to result in a rectangular LSDRaster. More...
 
LSDRaster clip_to_smaller_raster (LSDRaster &smaller_raster)
 This returns a clipped raster that has the same dimensions as the smaller raster. More...
 
LSDRaster clip_to_smaller_raster (LSDIndexRaster &smaller_raster)
 This returns a clipped raster that has the same dimensions as the smaller raster. More...
 
LSDRaster LSDRasterTemplate (Array2D< float > InputData)
 Make LSDRaster object using a 'template' raster and an Array2D of data. More...
 
void strip_raster_padding ()
 Strips the edge rows/columns of a LSDRaster on each side of the array. More...
 
LSDRaster BufferRasterData (float window_radius)
 Buffers a raster using a circular kernel of a user-defined radius (m) More...
 
LSDRaster calculate_relief (float kernelWidth, int kernelType)
 Calculates a relief raster. More...
 
float mean_elevation (void)
 Calculates mean elevation of a raster. More...
 
float max_elevation (void)
 Calculates max elevation of a raster. More...
 
float mean_relief (float kernelsize)
 Calculates mean relief of a raster, it defaults to a circular kernal. More...
 
float difference_rasters (LSDRaster &compare_raster)
 Calculates the mean difference between two rasters. More...
 
void raster_multiplier (float multiplier)
 This multiplies the raster data by a multiplier Note that values are replaced. More...
 
LSDRaster MapAlgebra_multiply (LSDRaster &M_raster)
 This multiplies two rasters, elementwise Simple elementwise multiplictation. More...
 
LSDRaster MapAlgebra_divide (LSDRaster &M_raster)
 This divides two rasters, elementwise Simple elementwise division. More...
 
LSDRaster MapAlgebra_add (LSDRaster &M_raster)
 This add two rasters, elementwise Simple elementwise addition. More...
 
LSDRaster MapAlgebra_subtract (LSDRaster &M_raster)
 This subtracts two rasters, elementwise Simple elementwise subtraction. More...
 
float WrapSample (int row, int col)
 This returns a value from the array data element but wraps around the array dimensions so that row > NRows (for example) returns a value. More...
 
void SetWrapSample (int row, int col, float value)
 This sets a value in the data array withthe added feature that it wraps beyond NRows and NCols. More...
 
void DSSetFeatureCorners (int featuresize, float scale)
 This sets the corners of features as the first step in the diamond square algorithm. More...
 
void DSSampleSquare (int row, int col, int size, float value)
 This is the square sampling step of the diamond square algorithm: it takes the average of the four corners and adds a random number to set the centrepoint of a square. More...
 
void DSSampleDiamond (int row, int col, int size, float value)
 This is the diamond sampling step of the diamond square algorithm: it takes the average of the four corners and adds a random number to set the centrepoint of a diamond. More...
 
void DiamondSquare_SampleStep (int stepsize, float scale)
 This is the sampling function for the diamond square algorithm: it runs both a diamond and a square sampling for each step. More...
 
LSDRaster DiamondSquare (int feature_order, float scale)
 This is the driving function for the diamond square algorithm. More...
 
LSDRaster hillshade ()
 This function generates a hillshade raster. More...
 
LSDRaster hillshade (float altitude, float azimuth, float z_factor)
 
Array2D< float > Shadow (int theta, int phi)
 This function generates a hillshade derivative raster using the algorithm outlined in Codilean (2006). More...
 
LSDRaster CastShadows (int Azimuth, int ZenithAngle)
 Function to determine areas of a DEM that are in shadow from a given radiation source defined by an Azimuth and Zenith following Codilean (2006). More...
 
Array2D< float > Shadows (int Azimuth, int ZenithAngle)
 Function to determine areas of a DEM that are in shadow from a given radiation source defined by an Azimuth and Zenith following Codilean (2006). More...
 
LSDRaster TopographicShielding (int theta_step, int phi_step)
 This function generates a topographic shielding raster using the algorithm outlined in Codilean (2006). More...
 
LSDRaster TopographicShielding ()
 
vector< LSDRastercalculate_polyfit_surface_metrics (float window_radius, vector< int > raster_selection)
 Surface polynomial fitting and extraction of topographic metrics. More...
 
vector< LSDRastercalculate_polyfit_roughness_metrics (float window_radius1, float window_radius2, vector< int > raster_selection)
 Surface polynomial fitting and extraction of roughness metrics. More...
 
void calculate_polyfit_coefficient_matrices (float window_radius, Array2D< float > &a, Array2D< float > &b, Array2D< float > &c, Array2D< float > &d, Array2D< float > &e, Array2D< float > &f)
 This function calculates 6 coefficient matrices that allow the user to then calcualte slope, curvature, aspect, a classification for finding saddles and peaks and other metrics. More...
 
LSDRaster calculate_polyfit_elevation (Array2D< float > &f)
 This function calculates the elevation based on a polynomial fit. More...
 
LSDRaster calculate_polyfit_slope (Array2D< float > &d, Array2D< float > &e)
 This function calculates the slope based on a polynomial fit. More...
 
LSDRaster calculate_polyfit_aspect (Array2D< float > &d, Array2D< float > &e)
 This function calculates the aspect based on a polynomial fit. More...
 
LSDRaster calculate_polyfit_curvature (Array2D< float > &a, Array2D< float > &b)
 This function calculates the curvature based on a polynomial fit. More...
 
LSDRaster calculate_polyfit_planform_curvature (Array2D< float > &a, Array2D< float > &b, Array2D< float > &c, Array2D< float > &d, Array2D< float > &e)
 This function calculates the planform curvature based on a polynomial fit. More...
 
LSDRaster calculate_polyfit_profile_curvature (Array2D< float > &a, Array2D< float > &b, Array2D< float > &c, Array2D< float > &d, Array2D< float > &e)
 This function calculates the profile curvature based on a polynomial fit. More...
 
LSDRaster calculate_polyfit_tangential_curvature (Array2D< float > &a, Array2D< float > &b, Array2D< float > &c, Array2D< float > &d, Array2D< float > &e)
 This function calculates the tangential curvature based on a polynomial fit. More...
 
LSDIndexRaster calculate_polyfit_classification (Array2D< float > &a, Array2D< float > &b, Array2D< float > &c, Array2D< float > &d, Array2D< float > &e)
 This function identifies approximate position of stationary points within discrete surface using a threshold slope. More...
 
LSDRaster get_hilltop_curvature (LSDRaster &curvature, LSDRaster &Hilltops)
 Gets the hilltop curvature raster. More...
 
LSDRaster remove_positive_hilltop_curvature (LSDRaster &hilltop_curvature)
 Removes positive hilltop curvature values. More...
 
void remove_positive_values ()
 Removes positive values from a raster. More...
 
float get_percentage_bedrock_ridgetops (LSDRaster &roughness, LSDRaster &hilltop_curvature, float threshold)
 Gets the percentage of bedrock ridges. More...
 
LSDRaster calculate_slope_angles ()
 Calculates slope angle in radians. Needs the slope raster. More...
 
LSDRaster calculate_water_supply_rate_for_saturation (float soil_thick, float K, LSDRaster &ContributingArea, LSDRaster &SlopeAngle)
 Calculates the water supply rate required for saturation of the hillslope soil. More...
 
LSDRaster calculate_factor_of_safety_at_saturation (float C_r, float rho_s, float soil_thick, float tan_phi, LSDRaster &SlopeAngle)
 This calculates the factor of safety if the soil is completely saturated. More...
 
void calculate_polyfit_directional_cosines (Array2D< float > &d, Array2D< float > &e, Array2D< float > &l, Array2D< float > &m, Array2D< float > &n)
 Algorithm that assesses surface roughness based on a polynomial fit. More...
 
void calculate_orientation_matrix_eigenvalues (float window_radius, Array2D< float > &l, Array2D< float > &m, Array2D< float > &n, Array2D< float > &s1, Array2D< float > &s2, Array2D< float > &s3)
 Find eigenvalues for orientation matrix. More...
 
void calculate_plane_coefficient_matrices (float window_radius, Array2D< float > &a_plane, Array2D< float > &b_plane, Array2D< float > &c_plane)
 This function is a wrapper to get the three roughness eigenvalues s1, s2 and s3. More...
 
LSDRaster calculate_REI (Array2D< float > &a_plane, Array2D< float > &b_plane, float CriticalSlope)
 Create the REI raster. More...
 
LSDRaster calculate_REI (float window_radius, float CriticalSlope)
 Create the REI raster (imporoved wrapper) Rock exposure index defined as areas with local slope exceeding some critical slope as defined by DiBiase et al. (2012) More...
 
void calculate_and_print_polyfit_rasters (float window_radius, string file_prefix, vector< int > file_list)
 this function takes the polyfit functions and requires a window radius and a vector telling the function which rasters to print to file. More...
 
void calculate_and_print_polyfit_and_roughness_rasters (float window_radius, float roughness_radius, string file_prefix, vector< int > file_list)
 This function takes the combines the polyfit functions and the roughness function in one package. More...
 
void calculate_roughness_rasters (float window_radius, float roughness_radius, string file_prefix, vector< int > file_code)
 This function takes the combines the roughness functions in one package. More...
 
void remove_seas ()
 This function changes any elevation <= 0 to NoDataValue. More...
 
void mask_to_nodata_below_threshold (float threshold)
 This function changes any elevation <= threshold to NoDataValue. More...
 
LSDRaster mask_to_nodata_using_threshold (float threshold, bool belowthresholdisnodata)
 This function changes any data point either above or below threshold to NoDataValue. More...
 
LSDRaster mask_to_nodata_using_threshold_using_other_raster (float threshold, bool belowthresholdisnodata, LSDRaster &MaskingRaster)
 This function changes any data point either above or below threshold to NoDataValue The threshold is determined by a second raster. More...
 
LSDIndexRaster mask_to_indexraster_using_threshold (float threshold, bool belowthresholdisnodata)
 This function creats an LSDIndexRaster mask (with true == 1 and otherwise nodata) from an LSDRaster. Can mask either above or below a threshold. More...
 
LSDRaster mask_to_nodata_with_mask_raster (LSDIndexRaster &Mask_raster, int mask_value)
 This function masks a raster to nodata based on a mask value and a mask raster. More...
 
LSDRaster fill ()
 This function fills pits/sinks in a DEM by incrementing elevations for cells with no downslope neighbour. The process is repeated adnausium until no cells require incrementing. More...
 
void fill_iterator (Array2D< float > &fill_data, int i, int j)
 This is a recursive algorithm that is called by the fill function. More...
 
LSDRaster fill (float &MinSlope)
 This function fills pits/sinks in a DEM by checking for pits from lowest to highest elevation, starting at the DEM boundary (raster edge or adjacent to NDVs). More...
 
LSDRaster MDFlow (vector< string > BoundaryConditions)
 Generate a flow area raster using a multi direction algorithm. More...
 
LSDRaster FreemanMDFlow ()
 Generate a flow area raster using a multi direction algorithm. More...
 
LSDRaster FreemanMDFlow_SingleSource (int i_source, int j_source)
 Route flow from one source pixel using FreemanMDFlow. Adapted from SWDG's code above. More...
 
LSDRaster FMDChannelsFromChannelHeads (vector< int > &channel_heads_rows, vector< int > &channel_heads_cols, float R_threshold)
 Extracts a multi-pixel channel network, as opposed to a single thread channel, using method outlined in Pelletier, 2013, WRR; A robust, two-parameter method for the extraction of drainage networks from high-resolution digital elevation models (DEMs): Evaluation using synthetic and real-world DEMs. More...
 
LSDRaster QuinnMDFlow ()
 Generate a flow area raster using a multi direction algorithm. More...
 
LSDRaster M2DFlow ()
 Generate a flow area raster using a multi 2-direction algorithm. More...
 
LSDRaster RidgeSample (Array2D< float > &Ridges)
 Module to sample LSDRaster values running along a ridgetop network. More...
 
LSDRaster RidgeSmoother (int WindowRadius)
 Pass a smoothing window over a ridge LSDRaster object to calculate an average value running along the ridgetop. More...
 
LSDRaster RidgeBuffer (int BufferRadius)
 Pass a buffer over a ridge LSDRaster object to increase sampling area. More...
 
LSDRaster BasinAverager (LSDIndexRaster &Basins)
 Module assigns an average LSDRaster value to each basin. More...
 
float SingleBasinAverager (LSDIndexRaster &Basin)
 Module calculates an average value to each for a given raster from within a basin. More...
 
LSDRaster BasinArea (LSDIndexRaster Basins)
 Write the area(in spatial units) of each basin to the basin's pixels. More...
 
void GetBasinVector (LSDIndexRaster Basins, int BasinOfInterest)
 Convert a basin, given by a basin ID, into a chain of xy coordinates for fast plotting of vector basin outlines. More...
 
vector< LSDRasterBasinPuncher (vector< int > basin_ids, LSDIndexRaster BasinArray)
 Punch basins out of an LSDRaster to create DEMs of a single catchment. More...
 
LSDRaster CookieCutRaster (LSDRaster Cutter)
 Cookie cut a raster using a smaller raster. More...
 
void CollectBasinMetrics (LSDIndexRaster &Basins, LSDRaster &Slope, LSDRaster &Elevation, LSDRaster &Aspect, LSDRaster &Area, LSDRaster &DrainageDensity, LSDRaster &Cht, LSDRaster &HillslopeLength, LSDRaster &MeanSlope, LSDRaster &Relief, LSDRaster &MeanAspect, LSDRaster &LH_drainage_density, Array2D< float > LH_Data, float CriticalSlope, string RasterFilename)
 Collect all basin average metrics into a single file. More...
 
void raster_statistics_by_index (LSDIndexRaster &IndexRaster, vector< float > &mean_vector, vector< float > &sd_vector, vector< float > &serr_vector, vector< int > &Npts_vector)
 Takes a raster and a corresponding index raster, and calculates the mean, sd and standard error by index. Returns four vectors: mean, st.dev., st.err and Number of points for each category. More...
 
pair< float, float > Boomerang (LSDRaster &Slope, LSDRaster &D_inf, string RasterFilename, float log_bin_width=0.1, int SplineResolution=200, float bin_threshold=0.05)
 Generate data in two text files to create a boomerang plot as in Roering et al [2007]. More...
 
LSDRaster DrainageDensity (LSDIndexRaster &StreamNetwork, LSDIndexRaster &Basins, Array2D< int > FlowDir)
 Calculate drainage density of a set of input basins. More...
 
float get_drainage_density_of_raster (LSDIndexRaster &StreamNetwork, Array2D< int > FlowDir)
 Calculate drainage density of a DEM. More...
 
LSDRaster HillslopeLengthFromDrainageDensity (LSDIndexRaster &StreamNetwork, LSDIndexRaster &Basins, Array2D< int > FlowDir)
 Simple method to calculate drainage density for each basin and then convert these values into a hillslope length raster. More...
 
void GetVectors (LSDRaster Magnitude, LSDRaster Direction, string output_file, int step)
 Method to export thinned vector field data to a text file. More...
 
LSDRaster NonLocalMeansFilter (int WindowRadius=2, int SimilarityRadius=2, int DegreeFiltering=2, float Sigma=1.25)
 Perform Non-local means filtering on a DEM following Baude et al [2005]. More...
 
void PadRasterSymmetric (Array2D< float > &PaddedRasterData, int &SimilarityRadius)
 Creates a buffer around an array (of size SimilarityRadius) and gives the new border mirror symmetric values of the original array reflected across the boundary. More...
 
void MakeGaussianKernel (Array2D< float > &Kernel, float sigma, int SimilarityRadius)
 Generate gaussian weighted kernel. More...
 
LSDRaster GaussianFilter (float sigma, int kr=0)
 Filters the raster using a square 2D Gaussian filter. The filter is applied using a moving kernel of gaussian weights with a radius of 3*sigma. More...
 
LSDRaster PeronaMalikFilter (int timesteps, float percentile_for_lambda, float dt)
 Filters the raster using a Perona-Malik non-linear diffusion filter. More...
 
Array2D< float > D_inf_FlowDir ()
 D-infinity flow direction algorithm after Tarboton (1997). More...
 
LSDRaster D_inf_FlowArea (Array2D< float > FlowDir_array)
 Main function for generating a D-infinity flow area raster after Tarboton (1997). More...
 
void D_infAccum (int i, int j, Array2D< float > CountGrid, Array2D< float > Flowarea_Raster, Array2D< float > FlowDir_array)
 Recursive function to calculate accumulating area for a given pixel. More...
 
LSDRaster D_inf ()
 Wrapper Function to create a D-infinity flow area raster with one function call. More...
 
LSDRaster D_inf_units ()
 Wrapper Function to create a D-infinity flow area raster, in spatial units, with one function call. More...
 
LSDRaster D_inf_ConvertFlowToArea ()
 Wrapper Function to convert a D-infinity flow raster into spatial units. More...
 
LSDRaster write_dinf_flowdir_to_LSDRaster (Array2D< float > dinflow)
 Function to write the D-infinity flow directions to an LSDRaster. More...
 
LSDIndexRaster D_inf_watershed (LSDRaster D_inf_FlowDir, int PourRow, int PourCol)
 Function to generate upslope contributing area extent from the D-infinity flow directions to an LSDRaster. More...
 
LSDRaster calculate_topographic_index (LSDRaster &AccumulationArea, LSDRaster &Slope)
 Function to calculate the topographic index, a moisture distribution indicator. More...
 
LSDIndexRaster PointShapefileToRaster (string FileName)
 Method to turn a point shapefile into an LSDIndexRaster. More...
 
LSDIndexRaster PolylineShapefileToRaster (string FileName)
 Method to turn a polyline shapefile into an LSDIndexRaster. More...
 
LSDRaster Resample (float OutputResolution)
 Method to resample an LSDRaster to a lower resolution. More...
 
Array2D< int > create_mask (float window_radius, int neighbourhood_switch)
 creates a circular mask for neighbourhood statistics More...
 
LSDRaster neighbourhood_statistics_spatial_average (float window_radius, int neighbourhood_switch)
 gets mean value for specified circular neighbourhood More...
 
vector< LSDRasterneighbourhood_statistics_spatial_average_and_SD (float window_radius, int neighbourhood_switch)
 gets mean & standard deviation value specified circular neighbourhood More...
 
LSDRaster neighbourhood_statistics_local_relief (float window_radius, int neighbourhood_switch)
 gets relief within value specified circular neighbourhood More...
 
LSDRaster neighbourhood_statistics_fraction_condition (float window_radius, int neighbourhood_switch, int condition_switch, float test_value)
 tests neighbourhood for the fraction of values for which the specified condition is met. More...
 
LSDRaster border_with_nodata (int border_width, int irregular_switch=0)
 Function to change border pixels to nodata. More...
 
LSDIndexRaster find_cells_bordered_by_nodata ()
 This function creates a mask that has the value of 1 for cells that are either on the edge or bordered by nodata (from their 9 neighbors) More...
 
void check_isolated_nodata ()
 This looks for isolated instances of no data. More...
 
void rudimentary_nodata_fill ()
 a very rudimentay filling routine that just fills nodata nodes with the average elevation of its neighbors More...
 
LSDRaster alternating_direction_nodata_fill (int window_width)
 A routine that fills nodata holes. It cannot recognise nodata around the edges so the spiral trimmer should be used first The routine sweeps the raster looking for nodata and filling this nodata with an average value from surrounding nodes. The sweeping changes directions, four sweep directions in all (+ rows, - rows, + cols, -cols) and it alternates between these directions until the raster is filled. More...
 
LSDIndexRaster create_binary_isdata_raster ()
 This returns an index raster with 1 for data and 0 for nodata. More...
 
LSDRaster alternating_direction_nodata_fill_with_trimmer (int window_width)
 A routine that fills nodata holes. It first prepares the data with the sprial trimmer so nodata around the edges is removed. The routine sweeps the raster looking for nodata and filling this nodata with an average value from surrounding nodes. The sweeping changes directions, four sweep directions in all (+ rows, - rows, + cols, -cols) and it alternates between these directions until the raster is filled. The routine is particularly useful for data with holes that is to be prepared for spectral analysis. More...
 
LSDRaster nodata_fill_irregular_raster (int window_radius)
 Function to fill in no data holes in an irregular raster. Pixel must have all neighbours not equal to no data value within the specified window radius. Data is filled based on mean of pixels within the window radius.
 
LSDRaster alternating_direction_nodata_fill_irregular_raster (int window_width)
 A routine that fills nodata holes. Modified by FJC to only fill holes surrounded in all directions by pixels with valid elevation values. More...
 
LSDIndexRaster Create_Mask (string Condition, float TestValue)
 Function to create a masked LSDIndexRaster raster based on a conditional statement. More...
 
LSDRaster ExtractByMask (LSDIndexRaster Mask)
 Function to extract an LSDRaster based on a LSDIndexRaster mask. More...
 
void MaskRaster (LSDIndexRaster Mask)
 Function to update an LSDRaster based on a LSDIndexRaster mask. More...
 
LSDIndexRaster IsolateChannelsLashermesCurvature (float sigma, string q_q_filename)
 method to locate channel pixels outlined by Lashermes. More...
 
LSDIndexRaster IsolateChannelsLashermesAspect (float sigma, string q_q_filename)
 
LSDIndexRaster IsolateChannelsLashermesFull (float sigma, string q_q_filename_prefix)
 
LSDIndexRaster IsolateChannelsLashermesCurvatureArea (float sigma, float area_threshold, string q_q_filename)
 
LSDIndexRaster IsolateChannelsGeonet (float timesteps, float area_threshold, float window_radius, string q_q_filename)
 method to locate channel pixels outlined by Passalacqua et al. (2010). More...
 
LSDIndexRaster IsolateChannelsQuantileQuantile (string q_q_filename)
 uses quantile-quantile analysis to pick departure from gaussian behaviour, then uses this as a threshold to create a binary dataset. More...
 
LSDIndexRaster IsolateChannelsQuantileQuantileAdaptive (int half_width)
 
Array2D< float > CalculateAdaptiveCurvatureThresholdSD (int half_width)
 Function to calculate the curvature threshold used for DrEICH channel extraction which varies across the landscape. More...
 
LSDIndexRaster CreateHilltopPatches (int minimum_patch_size)
 Method to convert an LSDRaster hilltop file into a series of contigiuous hilltop patches. More...
 
LSDIndexRaster CreateHilltopPatchesNEW (int minimum_patch_size)
 
void FlattenToFile (string FileName)
 Simple method to flatten an LSDRaster to a text file, with a sigle value on each line. More...
 
void FlattenToCSV (string FileName)
 Method to flatten an LSDRaster and place the non NDV values in a csv file. More...
 
void FlattenToWGS84CSV (string FileName)
 Method to flatten an LSDRaster and place the non NDV values in a csv file. More...
 
LSDRaster RemoveBelow (float Value)
 Simple method to remove any values below a user supplied value from an LSDRaster. More...
 
LSDRaster RemoveAbove (float Value)
 Simple method to remove any values above a user supplied value from an LSDRaster. More...
 
LSDRaster apply_mask (LSDIndexRaster &mask)
 apply a mask to a raster dataset, converts pixels to nodata where mas=k=1 More...
 
LSDIndexRaster ConvertToBinary (int Value, int ndv)
 Method to convert all values in an LSDRaster to a single value. More...
 
LSDRaster MergeRasters (LSDRaster &RasterToAdd)
 Method to merge data from two LSDRasters WITH SAME EXTENT together. /// The data from the raster specified as an argument will be added (will overwrite the original raster if there is a conflict). More...
 
void OverwriteRaster (LSDRaster &RasterToAdd)
 Method to merge data from two LSDRasters WITH SAME EXTENT together. /// The data from the raster specified as an argument will be added (will overwrite the original raster if there is a conflict). Overloaded function to rewrite original raster rather than creating a new one. More...
 
LSDIndexRaster get_potential_floodplain_patches (LSDRaster &Relief, LSDRaster &Slope, float relief_threshold, float slope_threshold)
 Function to get potential floodplain patches using a slope and relief threshold. More...
 
float get_threshold_for_floodplain (float bin_width, float peak_threshold, int peak_distance)
 Function to get threshold from a raster using a histogram of Probability-Density values. The function identifies the peaks in the PDF, and sets the threshold to the peak with the lowest value. This can be used to set the floodplain threshold. More...
 
float get_threshold_for_floodplain_QQ (string q_q_filename, float threshold_condition, int lower_percentile, int upper_percentile)
 Function to get threshold from a raster using qq plots. More...
 
string ChannelLengthByOrder (LSDIndexRaster &StreamNetwork, Array2D< int > FlowDir)
 Get the lengths in spatial units of each part of the channel network, divided by strahler order. More...
 
LSDRaster PoupulateRasterGaussian (float minimum, float mean)
 Populate a raster with random noise drawn from a gaussian distribution of given mean and minimum values. More...
 
LSDRaster PoupulateRasterSingleValue (float value)
 Populate a raster with a single value. More...
 
void HilltopsToCSV (LSDRaster &CHT, LSDRaster &CHT_gradient, LSDRaster &gradient, int UTMZone, bool isNorth, int eId, string filename)
 Write CHT and hilltop gradient data to a *.csv file, coded by UTM coordinates as well as lat/long. More...
 
vector< vector< float > > Sample_Along_Ridge (LSDRaster &Raster1, LSDRaster &Raster2, LSDRaster &Raster3, int a, int b, int threshold)
 Sample the values of 3 input rasters that intersect with the point a,b within the area defined by threshold. More...
 
LSDRaster convert_from_feet_to_metres ()
 function to convert feet to metres using US international feet, where 1 foot = 0.3048006096012192 metres. More...
 
LSDRaster convert_from_centimetres_to_metres ()
 function to convert elevations from centimetres to metres More...
 

Protected Attributes

int NRows
 Number of rows.
 
int NCols
 Number of columns.
 
float XMinimum
 Minimum X coordinate.
 
float YMinimum
 Minimum Y coordinate.
 
float DataResolution
 Data resolution.
 
int NoDataValue
 No data value.
 
map< string, string > GeoReferencingStrings
 A map of strings for holding georeferencing information.
 
Array2D< float > RasterData
 Raster data.
 
Array2D< double > RasterData_dbl
 These are used primarily by LSDCatchmentModel.
 
Array2D< int > RasterData_int
 

Friends

class LSDFlowInfo
 Object to perform flow routing.
 

Detailed Description

Main analysis object to interface with other LSD objects.

Constructor & Destructor Documentation

LSDRaster::LSDRaster ( string  filename,
string  extension 
)
inline

Create an LSDRaster from a file. Uses a filename and file extension.

Returns
LSDRaster
Parameters
filenameA String, the file to be loaded.
extensionA String, the file extension to be loaded.
LSDRaster::LSDRaster ( int  nrows,
int  ncols,
float  xmin,
float  ymin,
float  cellsize,
float  ndv,
Array2D< float >  data 
)
inline

Create an LSDRaster from memory.

Returns
LSDRaster
Parameters
nrowsAn integer of the number of rows.
ncolsAn integer of the number of columns.
xminA float of the minimum X coordinate.
yminA float of the minimum Y coordinate.
cellsizeA float of the cellsize.
ndvAn integer of the no data value.
dataAn Array2D of floats in the shape nrows*ncols, containing the data to be written.
LSDRaster::LSDRaster ( int  nrows,
int  ncols,
double  xmin,
double  ymin,
double  cellsize,
double  ndv,
Array2D< double >  data 
)
inline

Create an LSDRaster from memory, with the elvation data stored as double precision floats.

Returns
LSDRaster

Created to maintain compatibility with LSDCatchmentModel

Author
DAV
LSDRaster::LSDRaster ( int  nrows,
int  ncols,
float  xmin,
float  ymin,
float  cellsize,
float  ndv,
Array2D< float >  data,
map< string, string >  temp_GRS 
)
inline

Create an LSDRaster from memory, includes georeferencing.

Returns
LSDRaster
Parameters
nrowsAn integer of the number of rows.
ncolsAn integer of the number of columns.
xminA float of the minimum X coordinate.
yminA float of the minimum Y coordinate.
cellsizeA float of the cellsize.
ndvAn integer of the no data value.
dataAn Array2D of floats in the shape nrows*ncols,
temp_GRSa map of strings containing georeferencing information. Used mainly with ENVI format files containing the data to be written.

Member Function Documentation

LSDRaster LSDRaster::alternating_direction_nodata_fill ( int  window_width)

A routine that fills nodata holes. It cannot recognise nodata around the edges so the spiral trimmer should be used first The routine sweeps the raster looking for nodata and filling this nodata with an average value from surrounding nodes. The sweeping changes directions, four sweep directions in all (+ rows, - rows, + cols, -cols) and it alternates between these directions until the raster is filled.

Parameters
window_sizethe number of pixles around the centre pixel to take the spatial average
Author
SMM
Date
09/12/2014
LSDRaster LSDRaster::alternating_direction_nodata_fill_irregular_raster ( int  window_width)

A routine that fills nodata holes. Modified by FJC to only fill holes surrounded in all directions by pixels with valid elevation values.

The routine sweeps the raster looking for nodata and filling this nodata with an average value from surrounding nodes. The sweeping changes directions, four sweep directions in all (+ rows, - rows, + cols, -cols)

Parameters
window_sizethe number of pixles around the centre pixel to take the spatial average
Author
FJC
Date
09/12/2014
LSDRaster LSDRaster::alternating_direction_nodata_fill_with_trimmer ( int  window_width)

A routine that fills nodata holes. It first prepares the data with the sprial trimmer so nodata around the edges is removed. The routine sweeps the raster looking for nodata and filling this nodata with an average value from surrounding nodes. The sweeping changes directions, four sweep directions in all (+ rows, - rows, + cols, -cols) and it alternates between these directions until the raster is filled. The routine is particularly useful for data with holes that is to be prepared for spectral analysis.

Parameters
window_sizethe number of pixles around the centre pixel to take the spatial average
Author
SMM
Date
09/12/2014
LSDRaster LSDRaster::apply_mask ( LSDIndexRaster mask)

apply a mask to a raster dataset, converts pixels to nodata where mas=k=1

Author
DTM
Date
25/08/2015
LSDRaster LSDRaster::BasinArea ( LSDIndexRaster  Basins)

Write the area(in spatial units) of each basin to the basin's pixels.

Big optimisation following the Drainage density's design pattern. Works by flattening the raster into a 1D vector, sorting it and summing each run of Basin IDs. Gives a fast count of the number of pixels per basin, which is multiplied by the cellsize to get an area in spatial units.

Parameters
BasinsLSDIndexRaster of drainage basins to measure.
Returns
LSDRaster of basin areas.
Author
SWDG
Date
20/11/2013
LSDRaster LSDRaster::BasinAverager ( LSDIndexRaster Basins)

Module assigns an average LSDRaster value to each basin.

Works by searching for every hilltop value that falls within a basin, summing these values and writing the final average to every cell identified as the basin in question.

Very inefficent at present. Module loops through every cell in LSDRaster (2 * number of basins) + 1 times. Beware!

Parameters
BasinsLSDIndexRaster of Drainage basins, generated using ChannelNetwork::ExtractBasinsOrder.

Bug fixed in assignment of basin IDs - SWDG 2/9/13.
Returns
LSDRaster of average basin value for each identified basin.
Author
SWDG
Date
04/2013
vector< LSDRaster > LSDRaster::BasinPuncher ( vector< int >  basin_ids,
LSDIndexRaster  BasinArray 
)

Punch basins out of an LSDRaster to create DEMs of a single catchment.

Writes files in the user supplied format (flt or asc) and returns a vector of LSDRasters so they can be loaded into other functions. Updated 24/9/13 to return a vector of LSDRasters - SWDG.

Parameters
basin_idsVector of basins to punch out.
BasinArrayBasin outlines used to punch out the LSDRasters.
Returns
Vector of output filenames.
Author
SWDG
Date
27/8/13
pair< float, float > LSDRaster::Boomerang ( LSDRaster Slope,
LSDRaster D_inf,
string  RasterFilename,
float  log_bin_width = 0.1,
int  SplineResolution = 200,
float  bin_threshold = 0.05 
)

Generate data in two text files to create a boomerang plot as in Roering et al [2007].

Should now do all it needs to do: if it gets any more complex I'll look at refactoring it into a few methods. The latest addition is to take a bin_threshold to allow different sizes of bins to be removed from the final analysis - SWDG 11/11/13.

Parameters
SlopeLSDRaster of slope.
D_infD-infinity Flowarea LSDRaster.
RasterFilenameFilename used to give unique name to output data.
log_bin_widthWidth (in log space) of the bins, with respect to D_inf.
SplineResolutionNumber of values between each point for the spline curve.
bin_thresholdThreshold fraction of values needed to keep a bin.
Returns
A pair of floats containing the two LH values in the order LH(bins), LH(splines).
Author
SWDG
Date
27/8/13
LSDRaster LSDRaster::border_with_nodata ( int  border_width,
int  irregular_switch = 0 
)

Function to change border pixels to nodata.

Parameters
intborder_width
intirregular_switch (0 (default) -> only creates border pixels around raster edge; 1 -> creates border around edges and nodata values e.g. for irregularly shaped datasets)
Returns
Updated LSDRaster
Author
DTM
Date
29/05/2014
LSDRaster LSDRaster::BufferRasterData ( float  window_radius)

Buffers a raster using a circular kernel of a user-defined radius (m)

Parameters
window_radiusradius in metres
Author
FJC
Date
10/02/17
void LSDRaster::calculate_and_print_polyfit_and_roughness_rasters ( float  window_radius,
float  roughness_radius,
string  file_prefix,
vector< int >  file_list 
)

This function takes the combines the polyfit functions and the roughness function in one package.

The function is data efficient since one does not need to recalculate the polyfit coefficeint matrices. Itakes the window radius of the polyfit and the window of the roughness calculation the file codes in the vector are:
0 slope
1 aspect
2 curvature
3 planform curvature
4 profile curvature
6 tangential curvature
7 classification
8 roughness s1
9 roughness s2
10 roughness s3

Parameters
window_radiusRadius of the mask.
roughness_radiusRadius of the roughness window.
file_prefixOutput filename string.
file_listVector of files to be created.
Author
SMM
Date
19-12-2012
void LSDRaster::calculate_and_print_polyfit_rasters ( float  window_radius,
string  file_prefix,
vector< int >  file_list 
)

this function takes the polyfit functions and requires a window radius and a vector telling the function which rasters to print to file.

The function is data efficient since one does not need to recalculate the polyfit coefficeint matrices. It also takes a string which is the prename of the data files the file codes in the vector are:
0 slope
1 aspect
2 curvature
3 planform curvature
4 profile curvature
6 tangential curvature
7 classification

Parameters
window_radiusRadius of the mask.
file_prefixOutput filename string.
file_listVector of files to be created.
Author
SMM
Date
19-12-2012
LSDRaster LSDRaster::calculate_factor_of_safety_at_saturation ( float  C_r,
float  rho_s,
float  soil_thick,
float  tan_phi,
LSDRaster SlopeAngle 
)

This calculates the factor of safety if the soil is completely saturated.

Factor of safety <1 == unstable

Parameters
C_rroot cohesion in N/m^2
rho_ssoil density in kg/m^3
soil_thicksoil thickness in m
tan_phithe friction angle of the soil
SlopeAnglethe angle of the slope (you need to use the function calculate_slope_angles) to get this
Returns
Factor_of_safety The factor of safety when the soil is saturated rate required for saturation. The units will be the same as hydraulic conductivity but the lenght unit must be metres (to match contributing area)
Author
SMM
Date
13/11/14
void LSDRaster::calculate_orientation_matrix_eigenvalues ( float  window_radius,
Array2D< float > &  l,
Array2D< float > &  m,
Array2D< float > &  n,
Array2D< float > &  s1,
Array2D< float > &  s2,
Array2D< float > &  s3 
)

Find eigenvalues for orientation matrix.

Parameters
window_radius
lcoefficeint l.
mcoefficeint m.
ncoefficeint n.
s1coefficeint s1.
s2coefficeint s2.
s3coefficeint s3.
Author
DTM
Date
13/09/2012
void LSDRaster::calculate_plane_coefficient_matrices ( float  window_radius,
Array2D< float > &  a_plane,
Array2D< float > &  b_plane,
Array2D< float > &  c_plane 
)

This function is a wrapper to get the three roughness eigenvalues s1, s2 and s3.

Parameters
window_radius
a_plane
b_plane
c_plane
Author
DTM
Date
15/7/2013
LSDRaster LSDRaster::calculate_polyfit_aspect ( Array2D< float > &  d,
Array2D< float > &  e 
)

This function calculates the aspect based on a polynomial fit.

the window is determined by the calculate_polyfit_coefficient_matrices this function also calculates the a,b,c,d,e and f coefficient matrices.

Parameters
dcoefficeint d.
ecoefficeint e.
Returns
LSDRaster of aspect.
Author
DTM, SMM
Date
01/01/12
LSDIndexRaster LSDRaster::calculate_polyfit_classification ( Array2D< float > &  a,
Array2D< float > &  b,
Array2D< float > &  c,
Array2D< float > &  d,
Array2D< float > &  e 
)

This function identifies approximate position of stationary points within discrete surface using a threshold slope.

The nature of the stationary point is then determined to discriminate peaks, depressions and saddles.
0 = Non-stationary
1 = Peak
2 = Depression
3 = Saddle

Parameters
acoefficeint a.
bcoefficeint b.
ccoefficeint c.
dcoefficeint d.
ecoefficeint e.
Returns
LSDRaster of classified elevation data.
Author
DTM
Date
17/09/2012
void LSDRaster::calculate_polyfit_coefficient_matrices ( float  window_radius,
Array2D< float > &  a,
Array2D< float > &  b,
Array2D< float > &  c,
Array2D< float > &  d,
Array2D< float > &  e,
Array2D< float > &  f 
)

This function calculates 6 coefficient matrices that allow the user to then calcualte slope, curvature, aspect, a classification for finding saddles and peaks and other metrics.

The coefficient matrices are overwritten during the running of this member function.

Have N simultaneous linear equations, and N unknowns. => b = Ax, where x is a 1xN array containing the coefficients we need for surface fitting. A is constructed using different combinations of x and y, thus we only need to compute this once, since the window size does not change. For 2nd order surface fitting, there are 6 coefficients, therefore A is a 6x6 matrix. Updated 15/07/2013 to use a circular mask for surface fitting - DTM. Updated 24/07/2013 to check window_radius size and correct values below data resolution - SWDG.

Parameters
window_radiusRadius of the mask in spatial units.
acoefficeint a.
bcoefficeint b.
ccoefficeint c.
dcoefficeint d.
ecoefficeint e.
fcoefficeint f.
Author
DTM, SMM
Date
01/01/12
LSDRaster LSDRaster::calculate_polyfit_curvature ( Array2D< float > &  a,
Array2D< float > &  b 
)

This function calculates the curvature based on a polynomial fit.

the window is determined by the calculate_polyfit_coefficient_matrices this function also calculates the a,b,c,d,e and f coefficient matrices.

Parameters
acoefficeint a.
bcoefficeint b.
Returns
LSDRaster of curvature.
Author
DTM, SMM
Date
01/01/12
void LSDRaster::calculate_polyfit_directional_cosines ( Array2D< float > &  d,
Array2D< float > &  e,
Array2D< float > &  l,
Array2D< float > &  m,
Array2D< float > &  n 
)

Algorithm that assesses surface roughness based on a polynomial fit.

Runs a moving window across the DEM and assesses the variability of surface normals within that window. Specifically the components of the normals are combined into an orientation matrix, which is then solved to find the eigenvalues s1, s2, s3 (Woodcock, 1977).

Parameters
dcoefficeint d.
ecoefficeint e.
lcoefficeint l.
mcoefficeint m.
ncoefficeint n.
Author
DTM
Date
13/09/2012
LSDRaster LSDRaster::calculate_polyfit_elevation ( Array2D< float > &  f)

This function calculates the elevation based on a polynomial fit.

the window is determined by the calculate_polyfit_coefficient_matrices this function also calculates the a,b,c,d,e and f coefficient matrices.

Parameters
fcoefficeint f.
Returns
LSDRaster of elevations.
Author
FC
Date
24/03/13
LSDRaster LSDRaster::calculate_polyfit_planform_curvature ( Array2D< float > &  a,
Array2D< float > &  b,
Array2D< float > &  c,
Array2D< float > &  d,
Array2D< float > &  e 
)

This function calculates the planform curvature based on a polynomial fit.

the window is determined by the calculate_polyfit_coefficient_matrices this function also calculates the a,b,c,d,e and f coefficient matrices.

Parameters
acoefficeint a.
bcoefficeint b.
ccoefficeint c.
dcoefficeint d.
ecoefficeint e.
Returns
LSDRaster of planform curvature.
Author
DTM, SMM
Date
01/01/12
LSDRaster LSDRaster::calculate_polyfit_profile_curvature ( Array2D< float > &  a,
Array2D< float > &  b,
Array2D< float > &  c,
Array2D< float > &  d,
Array2D< float > &  e 
)

This function calculates the profile curvature based on a polynomial fit.

the window is determined by the calculate_polyfit_coefficient_matrices this function also calculates the a,b,c,d,e and f coefficient matrices.

Parameters
acoefficeint a.
bcoefficeint b.
ccoefficeint c.
dcoefficeint d.
ecoefficeint e.
Returns
LSDRaster of profile curvature.
Author
DTM, SMM
Date
01/01/12
vector< LSDRaster > LSDRaster::calculate_polyfit_roughness_metrics ( float  window_radius1,
float  window_radius2,
vector< int >  raster_selection 
)

Surface polynomial fitting and extraction of roughness metrics.

A six term polynomial surface is fitted to all the points that lie within circular neighbourhood that is defined by the designated window radius. This surface is used to determine the orientation of the surface normal vector at each cell. The algorithm then searches through the grid again, using a second search window to look for the local variability in normal vector orientation. The user also inputs a binary raster, which tells the program which rasters it wants to create (label as "1" to produce them, "0" to ignore them. This has 3 elements, as listed below: 0 -> s1 -> describes clustering of normals around the major axis 1 -> s2 -> describes clustering of normals around semi major axis 2 -> s3 -> describes clustering around minor axis The program returns a vector of LSDRasters. For options marked "0" in binary input raster, the returned LSDRaster houses a blank raster, as this metric has not been calculated. The desired LSDRaster can be retrieved from the output vector by using the same cell reference shown in the list above i.e. it is the same as the reference in the input binary vector.

Parameters
window_radius1-> the radius of the circular window over which to fit the surface
window_radius2-> the radius of the circular window over which to look for local variability of surface normal orientation
raster_selection-> a binary raster, with 3 elements, which identifies which metrics you want to calculate.
Returns
A vector of LSDRaster objects. Those that you have not asked to be calculated are returned as a 1x1 Raster housing a NoDataValue
Author
DTM
Date
01/04/2014
LSDRaster LSDRaster::calculate_polyfit_slope ( Array2D< float > &  d,
Array2D< float > &  e 
)

This function calculates the slope based on a polynomial fit.

the window is determined by the calculate_polyfit_coefficient_matrices this function also calculates the a,b,c,d,e and f coefficient matrices.

Parameters
dcoefficeint d.
ecoefficeint e.
Returns
LSDRaster of slope.
Author
DTM, SMM
Date
01/01/12
vector< LSDRaster > LSDRaster::calculate_polyfit_surface_metrics ( float  window_radius,
vector< int >  raster_selection 
)

Surface polynomial fitting and extraction of topographic metrics.

A six term polynomial surface is fitted to all the points that lie within circular neighbourhood that is defined by the designated window radius. The user also inputs a binary raster, which tells the program which rasters it wants to create (label as "1" to produce them, "0" to ignore them. This has 8 elements, as listed below: 0 -> Elevation (smoothed by surface fitting) 1 -> Slope 2 -> Aspect 3 -> Curvature 4 -> Planform Curvature 5 -> Profile Curvature 6 -> Tangential Curvature 7 -> Stationary point classification (1=peak, 2=depression, 3=saddle) The program returns a vector of LSDRasters. For options marked "false" in boolean input raster, the returned LSDRaster houses a blank raster, as this metric has not been calculated. The desired LSDRaster can be retrieved from the output vector by using the cell reference shown in the list above i.e. it is the same as the reference in the input boolean vector.

Parameters
window_radius-> the radius of the circular window over which to fit the surface
raster_selection-> a binary raster, with 8 elements, which identifies which metrics you want to calculate.
Returns
A vector of LSDRaster objects. Those that you have not asked to be calculated are returned as a 1x1 Raster housing a NoDataValue
Author
DTM
Date
28/03/2014
LSDRaster LSDRaster::calculate_polyfit_tangential_curvature ( Array2D< float > &  a,
Array2D< float > &  b,
Array2D< float > &  c,
Array2D< float > &  d,
Array2D< float > &  e 
)

This function calculates the tangential curvature based on a polynomial fit.

the window is determined by the calculate_polyfit_coefficient_matrices this function also calculates the a,b,c,d,e and f coefficient matrices.

Parameters
acoefficeint a.
bcoefficeint b.
ccoefficeint c.
dcoefficeint d.
ecoefficeint e.
Returns
LSDRaster of tangential curvature.
Author
DTM, SMM
Date
01/01/12
LSDRaster LSDRaster::calculate_REI ( Array2D< float > &  a_plane,
Array2D< float > &  b_plane,
float  CriticalSlope 
)

Create the REI raster.

Parameters
a_plane
b_plane
CriticalSlope
Returns
LSDIndexRaster of rock exposure.
Author
DTM
LSDRaster LSDRaster::calculate_REI ( float  window_radius,
float  CriticalSlope 
)

Create the REI raster (imporoved wrapper) Rock exposure index defined as areas with local slope exceeding some critical slope as defined by DiBiase et al. (2012)

Parameters
windowradius
CriticalSlope
Returns
LSDIndexRaster of rock exposure.
Author
DTM
LSDRaster LSDRaster::calculate_relief ( float  kernelWidth,
int  kernelType 
)

Calculates a relief raster.

Parameters
Thewidth in metres of the kernal you wnat to use for resolution
ifthis ==1 then you use a circular kernal. Otherwise kernal is square
Returns
The spatially distributed relief
Author
JAJ (entered into trunk SMM)
Date
6/06/2014 Happy 3rd Birthday Skye!!!
void LSDRaster::calculate_roughness_rasters ( float  window_radius,
float  roughness_radius,
string  file_prefix,
vector< int >  file_code 
)

This function takes the combines the roughness functions in one package.

The function is data efficient since one does not need to recalculate the polyfit coefficeint matrices. I takes the window radius of the polyfit and the window of the roughness calculation the file codes in the vector are:
0 roughness s1
1 roughness s2
2 roughness s3

Parameters
window_radiusRadius of the mask.
roughness_radiusRadius of the roughness window.
file_prefixOutput filename string.
file_codeVector of files to be created.
Author
DTM
Date
15-07-2013
LSDRaster LSDRaster::calculate_slope_angles ( )

Calculates slope angle in radians. Needs the slope raster.

Returns
LSDRaster containing the slope angle in radians. For use in trigonometric calculations
Author
SMM
Date
13/11/14
LSDRaster LSDRaster::calculate_topographic_index ( LSDRaster AccumulationArea,
LSDRaster Slope 
)

Function to calculate the topographic index, a moisture distribution indicator.

Calculates the topographic index, defined as ln(A/S) (Kirkby, 1975), where A is the accumulation area and S is the slope. This is an indicator of the distribution of moisture within the topography.

Parameters
LSDRasterof Accumulations Area, calculated ideally with D-inf
LSDRasterof Slope
Returns
LSDRaster of Topographic Index
Author
DTM
Date
01/04/2014
LSDRaster LSDRaster::calculate_water_supply_rate_for_saturation ( float  soil_thick,
float  K,
LSDRaster ContributingArea,
LSDRaster SlopeAngle 
)

Calculates the water supply rate required for saturation of the hillslope soil.

Water supply rate is the precipitation rate minus recharge and ET

Parameters
soil_thicksoil thickness in m
Khydraulic conductivity in m/ (some time unit)
ConstributingAreathe contributing area raster, should be in m^2
SlopeAnglethe angle of the slope (you need to use the function calculate_slope_angles) to get this
Returns
Water_supply_rate_for_saturation a raster holding the water supply rate required for saturation. The units will be the same as hydraulic conductivity but the lenght unit must be metres (to match contributing area)
Author
SMM
Date
13/11/14
Array2D< float > LSDRaster::CalculateAdaptiveCurvatureThresholdSD ( int  half_width)

Function to calculate the curvature threshold used for DrEICH channel extraction which varies across the landscape.

Parameters
half_widthradius over which to calculate the curvature threshold
Returns
Array2D<float> array with curvature threshold for each row and col
Author
FJC
Date
20/07/15
LSDRaster LSDRaster::CastShadows ( int  Azimuth,
int  ZenithAngle 
)

Function to determine areas of a DEM that are in shadow from a given radiation source defined by an Azimuth and Zenith following Codilean (2006).

Performs a coordinate transformation, rotating the x,y,z coordinates about the Azimuth and Zenith such that the coordinates are aligned with the Azimuth and Zenith. Shaded cells are then found by tracking in the direction of the radiation source and looking for transformed z values greater than that at the cell of interest which would therefore cast a shadow.

Parameters
Azimuthof the illumination source in degrees.
ZenithAngleof the illumination source in degrees
Returns
Hillshaded LSDIndexRaster
Author
MDH
Date
Feb 2015
string LSDRaster::ChannelLengthByOrder ( LSDIndexRaster StreamNetwork,
Array2D< int >  FlowDir 
)

Get the lengths in spatial units of each part of the channel network, divided by strahler order.

Parameters
StreamNetworkRaster of the stream network coded by strahler order.
FlowDirArray of flowdirections from FlowInfo (Not D-inf).
Author
SWDG
Date
17/1/16
bool LSDRaster::check_if_point_is_in_raster ( float  X_coordinate,
float  Y_coordinate 
)

this check to see if a point is within the raster

Parameters
X_coordinatethe x location of the point
Y_coordinatethe y location of the point
Returns
is_in_raster a boolean telling if the point is in the raster
Author
SMM
Date
13/11/2014
void LSDRaster::check_isolated_nodata ( )

This looks for isolated instances of no data.

Does nothing else but print their location to the screen.

Author
MDH, DTM
Date
01/01/12
LSDRaster LSDRaster::clip_to_smaller_raster ( LSDRaster smaller_raster)

This returns a clipped raster that has the same dimensions as the smaller raster.

Parameters
smaller_rasterthe raster to which the bigger raster should be clipped
Author
SMM
Date
20/03/2015
LSDRaster LSDRaster::clip_to_smaller_raster ( LSDIndexRaster smaller_raster)

This returns a clipped raster that has the same dimensions as the smaller raster.

Parameters
smaller_rasterthe raster to which the bigger raster should be clipped
Author
SMM
Date
20/03/2015
void LSDRaster::CollectBasinMetrics ( LSDIndexRaster Basins,
LSDRaster Slope,
LSDRaster Elevation,
LSDRaster Aspect,
LSDRaster Area,
LSDRaster DrainageDensity,
LSDRaster Cht,
LSDRaster HillslopeLength,
LSDRaster MeanSlope,
LSDRaster Relief,
LSDRaster MeanAspect,
LSDRaster LH_drainage_density,
Array2D< float >  LH_Data,
float  CriticalSlope,
string  RasterFilename 
)

Collect all basin average metrics into a single file.

File is written with the format:

"basin_id slope elevation aspect area drainage_density hilltop_curvature hillslope_length mean_slope hilltop_relief hilltop_aspect E* R* LH_bins LH_splines LH_density"

Parameters
BasinsLSDIndexRaster of drainage basins to sample.
Slope
Elevation
Aspect
Area
DrainageDensity
Cht
HillslopeLength
MeanSlope
Relief
MeanAspect
LH_drainage_densityHillslope length for each basin calculated as in Tucker et al 2001 - Added 6/11/13 SWDG.
LH_DataArray of LH data generated from the Boomerang plotting function and compiled using the BasinMetrics Driver - Added 1/11/13 SWDG.
CriticalSlopeThreshold value for E* and R* values.
RasterFilenameFilename of the input raster data.
Author
SWDG
Date
27/8/13
LSDRaster LSDRaster::convert_from_centimetres_to_metres ( )

function to convert elevations from centimetres to metres

Returns
raster of elevations in metres
Author
FJC
Date
18/10/17
LSDRaster LSDRaster::convert_from_feet_to_metres ( )

function to convert feet to metres using US international feet, where 1 foot = 0.3048006096012192 metres.

Returns
raster of elevations in metres
Author
FJC
Date
16/10/17
LSDIndexRaster LSDRaster::ConvertToBinary ( int  Value,
int  ndv 
)

Method to convert all values in an LSDRaster to a single value.

Parameters
Value,aninteger value that will be assigned to every non NDV cell in the raster.
ndvan integer no data value.
Author
SWDG
Date
24/07/2015
LSDRaster LSDRaster::CookieCutRaster ( LSDRaster  Cutter)

Cookie cut a raster using a smaller raster.

Requires that both rasters share a spatial extent.

Parameters
Cutteran LSDRaster to be used as the template.
Returns
LSDRaster of the data cut to the other ratser's shape.
Author
SWDG
Date
06/07/15
LSDIndexRaster LSDRaster::create_binary_isdata_raster ( )

This returns an index raster with 1 for data and 0 for nodata.

Returns
index raster 1 == data, 0 == nodata
Author
SMM
Date
17/03/2017
Array2D< int > LSDRaster::create_mask ( float  window_radius,
int  neighbourhood_switch 
)

creates a circular mask for neighbourhood statistics

The second argument (neighbourhood_switch) specifies the neighbourhood type: 0 Square neighbourhood 1 Circular window

Parameters
windowradius of mask
intneighbourhood_switch -> see above
Returns
a binary array with the mask
Author
DTM
Date
20/06/2014
LSDIndexRaster LSDRaster::Create_Mask ( string  Condition,
float  TestValue 
)

Function to create a masked LSDIndexRaster raster based on a conditional statement.

Parameters
stringCondition ("<", ">", "==", "!=")
floatTestValue The value that the condition is tested against
Returns
LSDIndexRaster of the mask
Author
MDH
Date
27/08/2014
LSDRaster LSDRaster::create_raster_nodata ( )

Create a raster in of the same number of rows and cols with nodata.

Author
FJC
Date
07/04/17
LSDIndexRaster LSDRaster::CreateHilltopPatches ( int  minimum_patch_size)

Method to convert an LSDRaster hilltop file into a series of contigiuous hilltop patches.

Connects all contiguous patches of hilltop via a unique ID, allowing hilltop patches to be generated in a manner similar to the methodology employed by Hurst et al. (2012) and (2013) to spatially average data for E*R* calculations. Currently has no method to limit the maximum size of segments.

Parameters
minimum_patch_sizeInteger of the minimum number of pixels required for a patch to be created
Returns
An LSDIndexRaster of hilltop patches.
Author
SWDG
Date
5/6/15
LSDRaster LSDRaster::D_inf ( )

Wrapper Function to create a D-infinity flow area raster with one function call.

Returns
LSDRaster of D-inf flow areas in pixels.
Author
SWDG
Date
26/07/13
LSDRaster LSDRaster::D_inf_ConvertFlowToArea ( )

Wrapper Function to convert a D-infinity flow raster into spatial units.

Returns
LSDRaster of D-inf flow areas in spatial units.
Author
MDH (after SWDG)
Date
5/9/14
LSDRaster LSDRaster::D_inf_FlowArea ( Array2D< float >  FlowDir_array)

Main function for generating a D-infinity flow area raster after Tarboton (1997).

Calls the recurisve D_infAccum function to get flow area for each pixel. Returns flow area in pixels.

Code is ported and optimised from a Java implementation of the algorithm supplied under the GNU GPL licence through WhiteBox GAT: http://www.uoguelph.ca/~hydrogeo/Whitebox/ and provides identical results to the whitebox tool.

Parameters
FlowDir_arrayArray of Flowdirections generated by D_inf_FlowDir().
Returns
LSDRaster of D-inf flow areas in pixels.
Author
SWDG
Date
26/07/13
Array2D< float > LSDRaster::D_inf_FlowDir ( )

D-infinity flow direction algorithm after Tarboton (1997).

Algorithm takes a filled DEM and for each cell calculates the steepest descent based on 8 triangular facets. Flow direction is assigned as an angle from 0-360 degrees with -1 used to flag unresolved areas such as pits.

Code is ported and optimised from a Java implementation of the algorithm supplied under the GNU GPL licence through WhiteBox GAT: http://www.uoguelph.ca/~hydrogeo/Whitebox/ and provides identical results to the whitebox tool.

Returns
Array of Flow directions in degrees.
Author
SWDG
Date
26/07/13
LSDRaster LSDRaster::D_inf_units ( )

Wrapper Function to create a D-infinity flow area raster, in spatial units, with one function call.

Returns
LSDRaster of D-inf flow areas in spatial units.
Author
SWDG
Date
16/10/13
LSDIndexRaster LSDRaster::D_inf_watershed ( LSDRaster  D_inf_FlowDir,
int  PourRow,
int  PourCol 
)

Function to generate upslope contributing area extent from the D-infinity flow directions to an LSDRaster.

Parameters
dinflowLSDRaster of Flowdirections generated by D_inf_FlowDir().
iand j indices of pour point node
Returns
LSDIndexRaster of catchment
Author
MDH (after SWDG)
Date
26/08/14
void LSDRaster::D_infAccum ( int  i,
int  j,
Array2D< float >  CountGrid,
Array2D< float >  Flowarea_Raster,
Array2D< float >  FlowDir_array 
)

Recursive function to calculate accumulating area for a given pixel.

Called by the driver for every cell which has no contributing cells - eg the highest points on the landscape. Avoids the need to flatten and sort the DEM as required in the original Tarboton (1997) implementation. For more detail on the recursive algorithm following channels see Mark (1998) "Network Models in Geomorphology".

Code is ported and optimised from a Java implementation of the algorithm supplied under the GNU GPL licence through WhiteBox GAT: http://www.uoguelph.ca/~hydrogeo/Whitebox/ and provides identical results to the whitebox tool.

Parameters
iRow index of the target cell.
jColumn index of the target cell.
CountGridArray showing the number of cells flowing into each cell.
Flowarea_RasterArray of the flow areas which is populated using this function.
FlowDir_arrayArray of Flowdirections generated by D_inf_FlowDir().
Author
SWDG
Date
26/07/13
LSDRaster LSDRaster::DiamondSquare ( int  feature_order,
float  scale 
)

This is the driving function for the diamond square algorithm.

The driving function takes the current raster and then pads it in each direction to have rows and columns that are the nearest powers of 2. The xllocation and yllocation data values are preserved. The function returns a pseudo fractal landscape generated with the diamond square algorithm Believe it or not this algorithm is absed on code poseted by Notch, the creator of Minecraft, who then had it modified by Charles Randall https://www.bluh.org/code-the-diamond-square-algorithm/

Parameters
featureorder is an interger n where the feature size consists of 2^n nodes. If the feature order is set bigger than the dimensions of the parent raster then this will default to the order of the parent raster.
Scaleis a floating point number that sets the maximum relief of the resultant raster.
Returns
Returns a diamond square pseudo-fractal surface in and LSDRaster object.
Author
SMM
Date
16/02/2014
void LSDRaster::DiamondSquare_SampleStep ( int  stepsize,
float  scale 
)

This is the sampling function for the diamond square algorithm: it runs both a diamond and a square sampling for each step.

Parameters
Thestepsize, which is the size of the diamonds and the squares.
Thescale which sets the maxmum relief within a particular square or diamond and is scaled by the stepsize (that is smaller squares have smaller scales).
Author
SMM
Date
16/02/2014
float LSDRaster::difference_rasters ( LSDRaster compare_raster)

Calculates the mean difference between two rasters.

checks raster dimensions but not georeferencing since it is used to compare asc format model results

Author
SMM
Date
04/05/2015
bool LSDRaster::does_raster_have_same_dimensions ( LSDRaster Compare_raster)

Checks to see if two rasters have the same dimensions Does NOT check georeferencing.

Parameters
Compare_rasterthe raster to compare
Author
SMM
Date
04/05/2015
bool LSDRaster::does_raster_have_same_dimensions ( LSDIndexRaster Compare_raster)

Checks to see if two rasters have the same dimensions Does NOT check georeferencing.

Parameters
Compare_rasterthe raster to compare
Author
SMM
Date
04/05/2015
bool LSDRaster::does_raster_have_same_dimensions_and_georeferencing ( LSDRaster Compare_raster)

Checks to see if two rasters have the same georeferencing.

Parameters
Compare_rasterthe raster to compare
Author
SMM
Date
02/03/2015
bool LSDRaster::does_raster_have_same_dimensions_and_georeferencing ( LSDIndexRaster Compare_raster)

Checks to see if two rasters have the same georeferencing.

Parameters
Compare_rasterthe raster to compare
Author
SMM
Date
02/03/2015
LSDRaster LSDRaster::DrainageDensity ( LSDIndexRaster StreamNetwork,
LSDIndexRaster Basins,
Array2D< int >  FlowDir 
)

Calculate drainage density of a set of input basins.

Calculated as flow length/basin area and written to every cell of the identified basin. Completely rewritten to optimise performance. Now only traverses the DEM 3 times regardless of the number of input basins, previously traversed the DEM (2*No of Basins + 2) times.

Works by creating a pair of vectors of basin IDs and stream length for each pixel which are then sorted by basin ID and summed in order to calculate DD in a single pass over the DEM.

Parameters
StreamNetworkLSDIndexRaster of the stream network.
BasinsLSDIndexRaster of the basins to be analysed.
FlowDirArray2D of flowdirections generated by FlowInfo.get_FlowDirection().
Returns
LSDRaster of basins coded with drainage density.
Author
SWDG
Date
19/11/13
void LSDRaster::DSSampleDiamond ( int  row,
int  col,
int  size,
float  value 
)

This is the diamond sampling step of the diamond square algorithm: it takes the average of the four corners and adds a random number to set the centrepoint of a diamond.

Parameters
Therow of the centrepoint.
Thecolumn of the centrepoint.
Thesize of this diamond (in pixels, must be divisible by 2).
Therandom value added to the average of teh four corners.
Author
SMM
Date
16/02/2014
void LSDRaster::DSSampleSquare ( int  row,
int  col,
int  size,
float  value 
)

This is the square sampling step of the diamond square algorithm: it takes the average of the four corners and adds a random number to set the centrepoint of a square.

Parameters
Therow of the centrepoint.
Thecolumn of the centrepoint.
Thesize of this square (in pixels, must be divisible by 2).
Therandom value added to the average of the four corners.
Author
SMM
Date
16/02/2014
void LSDRaster::DSSetFeatureCorners ( int  featuresize,
float  scale 
)

This sets the corners of features as the first step in the diamond square algorithm.

Parameters
Thefirst parameter is the feature size. This needs to be a power of 2, but this is set by the parent DiamondSquare function (that is, this function should not be called independantly.
Thescale is effectivly the maximum relief of the surface to be produced by the algorithm.
Author
SMM
Date
16/02/2014
LSDRaster LSDRaster::ExtractByMask ( LSDIndexRaster  Mask)

Function to extract an LSDRaster based on a LSDIndexRaster mask.

Parameters
LSDIndexRasterTheMask
Returns
masked LSDRaster
Author
MDH
Date
27/08/2014
LSDRaster LSDRaster::fill ( )

This function fills pits/sinks in a DEM by incrementing elevations for cells with no downslope neighbour. The process is repeated adnausium until no cells require incrementing.

Inputs required are a DEM file in ascii raster format as created by ARCMap and a file name to create a filled DEM grid.

This code was built ontop of code made available by Jon D. Pelletier as part of his book:

Pelletier,J.D.,'Quantitative Modelling of Landscapes' Cambridge University Press


v1.3 reduced fill increment to 1mm to avoid 'overfilling'

Martin Hurst, October 2011


v1.2 modified to read *.flt files

Martin Hurst, November 2010


v1.1 function incorporated to allow the tool to fill adjacent pixels immediately after filling a given pixel, should speed things up.

Martin Hurst, October 2010


v1.0 is slow as it requires many iterations through the dem

Martin Hurst, June 2010

Returns
Filled LSDRaster.
Author
MDH
Date
01/06/10
LSDRaster LSDRaster::fill ( float &  MinSlope)

This function fills pits/sinks in a DEM by checking for pits from lowest to highest elevation, starting at the DEM boundary (raster edge or adjacent to NDVs).

Utilises a priority queue to progressively populate the stack and pop out the the lowest value before checking that the neighbouring cells that are yet to be visited must be higher in a hydrologically correct DEM. This method is substantially faster on datasets with pits consisting of multiple cells since each cell only needs to be visited once.

Method taken from Wang and Liu (2006), Int. J. of GIS. 20(2), 193-213

Parameters
MinSlopeThe minimum slope between two Nodes once filled. If set to zero will create flats.
Returns
Filled LSDRaster object.
Author
Martin Hurst
Date
12/3/13
void LSDRaster::fill_iterator ( Array2D< float > &  fill_data,
int  i,
int  j 
)

This is a recursive algorithm that is called by the fill function.

Parameters
fill_data
i
j
Author
MDH
Date
01/06/10
LSDRaster LSDRaster::fill_with_interpolated_data ( vector< int >  rows_of_nodes,
vector< int >  cols_of_nodes,
vector< float >  interpolated_data 
)

This fills a raster with precalculated interpolated data.

Parameters
rows_of_nodesthe rows of the interpolated points
cols_of_nodesthe colss of the interpolated points
interpolateddata the actual data that has been interpolated
Author
SMM
Date
17/02/2017
LSDIndexRaster LSDRaster::find_cells_bordered_by_nodata ( )

This function creates a mask that has the value of 1 for cells that are either on the edge or bordered by nodata (from their 9 neighbors)

Returns
and LSDIndexRaster with the mask
Author
SMM
Date
29/10/2014
int LSDRaster::Find_UTM_central_meridian ( int  UTM_zone)

This method looks up the central meridian given a UTM zone.

Parameters
UTM_zonethe UTM zone
Returns
central_meridian an integer of the central meridian of this UTM zone
Author
SMM
Date
6/11/14
void LSDRaster::FlattenToCSV ( string  FileName)

Method to flatten an LSDRaster and place the non NDV values in a csv file.

Each value is placed on its own line, so that it can be read more quickly in python etc. It includes the x and y locations so it can be read by GIS software

Parameters
FileName_prefixThe prefix of the file to write, if no path is included it will write to the current directory. The csv extension is added automatically.
Author
SMM
Date
29/6/15
void LSDRaster::FlattenToFile ( string  FileName)

Simple method to flatten an LSDRaster to a text file, with a sigle value on each line.

Parameters
FileNameThe name of the file to write, if no path is included it will write to the current directory.
Author
SWDG
Date
9/2/15
void LSDRaster::FlattenToWGS84CSV ( string  FileName)

Method to flatten an LSDRaster and place the non NDV values in a csv file.

Each value is placed on its own line, so that it can be read more quickly in python etc. It includes the lat long coordinates in CSV

Parameters
FileName_prefixThe prefix of the file to write, if no path is included it will write to the current directory. The csv extension is added automatically.
Author
SMM
Date
12/11/16
LSDRaster LSDRaster::FMDChannelsFromChannelHeads ( vector< int > &  channel_heads_rows,
vector< int > &  channel_heads_cols,
float  R_threshold 
)

Extracts a multi-pixel channel network, as opposed to a single thread channel, using method outlined in Pelletier, 2013, WRR; A robust, two-parameter method for the extraction of drainage networks from high-resolution digital elevation models (DEMs): Evaluation using synthetic and real-world DEMs.

First runs Freeman MD flow routing algorithm from previously identified source. Then removes all pixels from the channel network if the ratio of discharge to upstream channel heads is below a user-specified threshold

Parameters
vector<int>channel_heads_rows - a vector of source node row indices
vector<int>channel_heads_cols - a vector of source node column indices
floatR_threshold - the threshold ratio of discharge:upstream channel heads; Pelletier (2013) reccomends a value of 0.1
Author
DTM
Date
22/05/2014
LSDRaster LSDRaster::FreemanMDFlow ( )

Generate a flow area raster using a multi direction algorithm.

Computes the proportion of all downslope flows for each cell in the input DEM, and weights them using the equation from Freeman et al 1991 and routes the flow accordingly.

Paper link: http://www.sciencedirect.com/science/article/pii/009830049190048I

Cardinal Weighting = (elevation_drop/total_elevation_drop)^1.1
Diagonal Weighting = ((elevation_drop/total_elevation_drop)*(1/root(2)))^1.1

Can NOT handle DEMs containing flats or pits - must be filled using the new LSDRaster fill. Function built around original c++ code by Martin Hurst.

Returns
LSDRaster of flow area.
Author
SWDG
Date
18/4/13
LSDRaster LSDRaster::FreemanMDFlow_SingleSource ( int  i_source,
int  j_source 
)

Route flow from one source pixel using FreemanMDFlow. Adapted from SWDG's code above.

Parameters
i_source-> the row index of the source pixel
j_source-> the column index of the source pixel
Author
DTM
Date
07/11/2013
LSDRaster LSDRaster::GaussianFilter ( float  sigma,
int  kr = 0 
)

Filters the raster using a square 2D Gaussian filter. The filter is applied using a moving kernel of gaussian weights with a radius of 3*sigma.

Equivalent lenghtscale of smoothing (from Lashermes et al., 2007) original data -> 4*sigma 1st derivative -> 2*pi*sigma 2nd derivative -> sqrt(2)*pi*sigma

Parameters
sigma
kr(an optional integer halfwidth for the smoothing window. If not supplied then the window is set to cover at least three*sigma)
Returns
a filtered raster
Author
David Milodowski
Date
Feb 2015
TNT::Array2D<double> LSDRaster::get_ascii_raster ( string  FILENAME)

Reads a raster from an ascii file for use in LSDCatchmentModel.

Bug:
You can't return a TNT::Array properly in a function. See google for details.
Author
DAV
Returns
Returns a 2D Array of the raster file.
float LSDRaster::get_data_element ( int  row,
int  column 
)
inline

Get the raster data at a specified location.

Parameters
rowAn integer, the X coordinate of the target cell.
columnAn integer, the Y coordinate of the target cell.
Returns
The raster value at the position (row, column).
Author
SMM
Date
01/01/12
float LSDRaster::get_DataResolution ( ) const
inline
Returns
Data resolution as an integer.
float LSDRaster::get_drainage_density_of_raster ( LSDIndexRaster StreamNetwork,
Array2D< int >  FlowDir 
)

Calculate drainage density of a DEM.

Calculated as flow length/raster area

Parameters
StreamNetworkLSDIndexRaster of the stream network.
FlowDirArray2D of flowdirections generated by FlowInfo.get_FlowDirection().
Returns
float with drainage density of raster
Author
FJC
Date
27/03/15
void LSDRaster::get_easting_and_northing_vectors ( vector< float > &  Eastings,
vector< float > &  Northings 
)

This returns vectors of all the easting and northing points in the raster Used for interpolations.

Parameters
Eastingsa vector of easting coordinates. Will be replaced by method.
Northingsa vector of northing coordinates. Will be replaced by method.
Author
SMM
Date
17/03/2017
map<string,string> LSDRaster::get_GeoReferencingStrings ( ) const
inline
Returns
map containing the georeferencing strings
LSDRaster LSDRaster::get_hilltop_curvature ( LSDRaster curvature,
LSDRaster Hilltops 
)

Gets the hilltop curvature raster.

Modified to take an LSDRaster of hilltops - SWDG 29/8/13

Parameters
curvatureLSDRaster of curvatures.
HilltopsLSDRaster of hilltops.
Returns
LSDRaster of hilltop curvatures.
Author
DTM
Date
30/04/13
void LSDRaster::get_lat_and_long_locations ( int  row,
int  col,
double &  lat,
double &  longitude,
LSDCoordinateConverterLLandUTM  Converter 
)

a function to get the lat and long of a node in the raster Assumes WGS84 ellipsiod

Parameters
rowthe row of the node
colthe col of the node
latthe latitude of the node (in decimal degrees, replaced by function) Note: this is a double, because a float does not have sufficient precision relative to a UTM location (which is in metres)
longthe longitude of the node (in decimal degrees, replaced by function) Note: this is a double, because a float does not have sufficient precision relative to a UTM location (which is in metres)
Convertera converter object (from LSDShapeTools)
Author
SMM
Date
22/12/2014
int LSDRaster::get_NCols ( ) const
inline
Returns
Number of columns as an integer.
int LSDRaster::get_NoDataValue ( ) const
inline
Returns
No Data Value as an integer.
int LSDRaster::get_NRows ( ) const
inline
Returns
Number of rows as an integer.
float LSDRaster::get_percentage_bedrock_ridgetops ( LSDRaster roughness,
LSDRaster hilltop_curvature,
float  threshold 
)

Gets the percentage of bedrock ridges.

Uses the hilltop curvature raster and the roughness raster. If the roughness value is greater than the threshold (set to 0.015) then the pixel is designated bedrock.

Parameters
roughnessroughness input raster
hilltop_curvaturehilltop curvature input raster
thresholdthreshold value to be designated bedrock
Returns
float with percentage bedrock pixels
Author
FJC
Date
01/04/15
LSDIndexRaster LSDRaster::get_potential_floodplain_patches ( LSDRaster Relief,
LSDRaster Slope,
float  relief_threshold,
float  slope_threshold 
)

Function to get potential floodplain patches using a slope and relief threshold.

Parameters
Reliefraster with relief values
Sloperaster with slope values
relief_thresholdthreshold value for relief (floodplain must be lower than this)
slope_thresholdthreshold value for slope (floodplain must be lower than this)
Author
FJC
Date
20/10/15
Array2D<float> LSDRaster::get_RasterData ( ) const
inline
Returns
Raster values as a 2D Array.
Array2D<double> LSDRaster::get_RasterData_dbl ( ) const
inline

Get the raw raster data, double format.

Author
DAV
Array2D<int> LSDRaster::get_RasterData_int ( ) const
inline

Get the raw raster data, integer format.

Author
DAV
vector< float > LSDRaster::get_RasterData_vector ( )

This function returns the raster data as a vector.

Returns
vector<float> with raster data
Author
FJC
Date
06/11/15
vector< float > LSDRaster::get_RasterData_vector_No_NDVs ( )

This function returns the raster data as a vector, ignoring NDVs.

Returns
vector<float> with raster data
Author
MDH
Date
06/02/17
void LSDRaster::get_row_and_col_of_a_point ( float  X_coordinate,
float  Y_coordinate,
int &  row,
int &  col 
)

Gets the row and column of a point in the raster.

Parameters
X_coordinatethe x location of the point
Y_coordinatethe y location of the point
rowthe row of the point, replaced upon running the routine
colthe col of the point, replaced upon running the routine
Author
SMM
Date
22/01/2016
float LSDRaster::get_threshold_for_floodplain ( float  bin_width,
float  peak_threshold,
int  peak_distance 
)

Function to get threshold from a raster using a histogram of Probability-Density values. The function identifies the peaks in the PDF, and sets the threshold to the peak with the lowest value. This can be used to set the floodplain threshold.

Parameters
bin_widthBin width for histogram
peak_thresholdThreshold probability-density value above which peaks will be selected
peak_distanceThreshold distance between identified peaks (will remove smaller peaks close to the largest ones)
Author
FJC
Date
16/11/15
float LSDRaster::get_threshold_for_floodplain_QQ ( string  q_q_filename,
float  threshold_condition,
int  lower_percentile,
int  upper_percentile 
)

Function to get threshold from a raster using qq plots.

Parameters
q_q_filenameFilename for the txt file with the data to visualise the qq plot
Author
FJC
Date
16/11/15
void LSDRaster::get_UTM_information ( int &  UTM_zone,
bool &  is_North 
)

this function gets the UTM_zone and a boolean that is true if the map is in the northern hemisphere

Parameters
UTM_zonethe UTM zone. Replaced in function.
is_Northa boolean that is true if the DEM is in the northern hemisphere. replaced in function
Author
SMM
Date
22/12/2014
float LSDRaster::get_value_of_point ( float  UTME,
float  UTMN 
)

This gets the value at a point in UTM coordinates.

Parameters
UTMEthe easting coordinate
UTMNthe northing coordinate
Returns
The value at that point
Author
SMM
Date
14/03/2017
void LSDRaster::get_x_and_y_locations ( int  row,
int  col,
double &  x_loc,
double &  y_loc 
)

this gets the x and y location of a node at row and column

Parameters
rowthe row of the node
colthe column of the node
x_locthe x location (Northing) of the node
y_locthe y location (Easting) of the node
Author
SMM
Date
22/12/2014
void LSDRaster::get_x_and_y_locations ( int  row,
int  col,
float &  x_loc,
float &  y_loc 
)

this gets the x and y location of a node at row and column

Parameters
rowthe row of the node
colthe column of the node
x_locthe x location (Northing) of the node
y_locthe y location (Easting) of the node
Author
SMM
Date
22/12/2014
float LSDRaster::get_XMinimum ( ) const
inline
Returns
Minimum X coordinate as an integer.
vector< float > LSDRaster::get_XY_MinMax ( )

This function returns a vector with the X adn Y minimum and max values.

Returns
XYMinMax a vector with four elements XYMinMax[0] = XMinimum XYMinMax[1] = YMinimum XYMinMax[2] = XMaximum XYMinMax[3] = XMaximum
Author
SMM
Date
3/7/2015
float LSDRaster::get_YMinimum ( ) const
inline
Returns
Minimum Y coordinate as an integer.
void LSDRaster::GetBasinVector ( LSDIndexRaster  Basins,
int  BasinOfInterest 
)

Convert a basin, given by a basin ID, into a chain of xy coordinates for fast plotting of vector basin outlines.

Produces a generalised polygon and will not cope well with complex geometries.

Needs to be updated to write data into an esri ascii format so the files can be loaded into arc. Currently writes to a text file called chain.txt.

Parameters
BasinsIndexRaster of basins
BasinOfInterestinteger of the basin ID to be converted.
Author
SWDG
Date
21/11/2013
void LSDRaster::GetVectors ( LSDRaster  Magnitude,
LSDRaster  Direction,
string  output_file,
int  step 
)

Method to export thinned vector field data to a text file.

The file is written with the format "i j Magnitude Direction".

Parameters
MagnitudeLSDRaster of the vector's magnitude.
DirectionLSDRaster of the vector's direction.
output_fileFilename for the output text file.
stepInteger value used to thin the data, 1 preserves all the data, 2 keeps every second point and so on.
Author
SWDG
Date
20/1/14
LSDRaster LSDRaster::hillshade ( )

This function generates a hillshade raster.

It uses the the algorithm outlined in Burrough and McDonnell Principles of GIS (1990) and in the ArcMap web help http://edndoc.esri.com/arcobjects/9.2/net/shared/geoprocessing/ spatial_analyst_tools/how_hillshade_works.htm

Default values are altitude = 45, azimuth = 315, z_factor = 1

Parameters
altitude(float) of the illumination source in degrees.
azimuth(float) of the illumination source in degrees
z_factor(float) Scaling factor between vertical and horizontal.
Returns
Hillshaded LSDRaster object
Author
SWDG
Date
February 2013
LSDRaster LSDRaster::HillslopeLengthFromDrainageDensity ( LSDIndexRaster StreamNetwork,
LSDIndexRaster Basins,
Array2D< int >  FlowDir 
)

Simple method to calculate drainage density for each basin and then convert these values into a hillslope length raster.

The LH value is calculated using LH = 1/2*DD [Tucker et al 2001].

Parameters
StreamNetworkLSDIndexRaster of the stream network.
BasinsLSDIndexRaster of the basins to be analysed.
FlowDirArray2D of flowdirections generated by FlowInfo.get_FlowDirection().
Returns
Raster of basin average hillslope lengths.
Author
SWDG
Date
7/11/13
void LSDRaster::HilltopsToCSV ( LSDRaster CHT,
LSDRaster CHT_gradient,
LSDRaster gradient,
int  UTMZone,
bool  isNorth,
int  eId,
string  filename 
)

Write CHT and hilltop gradient data to a *.csv file, coded by UTM coordinates as well as lat/long.

Pass in a CHT raster, CHT raster that has been filtered by gradient, a slope raster, a filename and some spatial reference information used to generate Lat Long values.

The code outputs a csv to the filename specified with the header structure:

"_ID,Easting,Northing,Lat,Long,CHT,gradient_flag,gradient"

Where the gradient_flag is a binary switch where 0 == above threshold and 1 == below threshold.

Parameters
CHTLSDRaster of the hilltop curvature.
CHT_gradientLSDRaster of the hilltop curvature, filtered by a gradient threshold.
gradientLSDRaster of the topographic gradient.
UTMZoneThe UTM zone the data falls in.
isNorthBoolean set to true if the data are in the northern hemisphere and false if not.
eIdThe ellipsoid ID, see LSDCoordinateConverterLLandUTM for details, WGS84 is 22.
filenameA string containing a path and filename to write the data to.
Author
SWDG
Date
2/11/16
void LSDRaster::impose_georeferencing_UTM ( int  zone,
string  NorS 
)

This method imposes georefereing strings assuming the coordinate system is UTM.

Parameters
zonethe UTM zone
NorSa string containing characters that start either N (for north) or S for south. The letter is not case sensitive
Author
SMM
Date
6/11/14
vector< float > LSDRaster::interpolate_points_bilinear ( vector< float >  UTMEvec,
vector< float >  UTMNvec 
)

This interpolates a vector of points onto the raster. Uses bilinear interpolation.

Parameters
UTMEvecEasting coordinates of points to be interpolatiod.
UTMNvecNorthing coordinates of points to be interpolatiod.
Returns
The vector of interpolated data.
Author
SMM
Date
17/03/2017
LSDIndexRaster LSDRaster::IsolateChannelsGeonet ( float  timesteps,
float  area_threshold,
float  window_radius,
string  q_q_filename 
)

method to locate channel pixels outlined by Passalacqua et al. (2010).

Isolate channelised portions of the landscape using the method proposed by Passalacqua et al. (2010) A geometric framework for channel network extraction from lidar: Nonlinear diffusion and geodesic paths, J. Geophys. Res., 115(F1), F01002, doi:10.1029/2009JF001254.

Parameters
numberof timesteps for non-linear filtering steps - suggest 20 in complex terrain
acatchment area threshold for pruning
awindow radius for surface fitting from which curvature calculation is performed
Returns
LSDIndexRaster A binary raster where the pixel value is 1 where the input raster exceeded the defined threshold
Author
DTM
Date
21/04/2015
LSDIndexRaster LSDRaster::IsolateChannelsLashermesCurvature ( float  sigma,
string  q_q_filename 
)

method to locate channel pixels outlined by Lashermes.

picks departure from gaussian behaviour, then uses this as a threshold to create a binary dataset. Lashermes, B., E. Foufoula-Georgiou, and W. E. Dietrich (2007), Channel network extraction from high resolution topography using wavelets, Geophys. Res. Lett., 34, L23S04, doi:10.1029/2007GL031140.

Parameters
stringq_q_file A text file containing data to produce a q_q_plot.
Returns
LSDIndexRaster A binary raster where the pixel value is 1 where the input raster exceeded the defined threshold
Author
DTM
Date
11/02/2015
LSDIndexRaster LSDRaster::IsolateChannelsQuantileQuantile ( string  q_q_filename)

uses quantile-quantile analysis to pick departure from gaussian behaviour, then uses this as a threshold to create a binary dataset.

Parameters
stringq_q_file A text file containing data to produce a q_q_plot.
Returns
LSDIndexRaster A binary raster where the pixel value is 1 where the input raster exceeded the defined threshold
Author
DTM ///
Returns
LSDIndexRaster A binary raster where the pixel value is 1 where the input raster exceeded the defined threshold
Author
DTM
Date
10/02/2015
LSDRaster LSDRaster::LSDRasterTemplate ( Array2D< float >  InputData)

Make LSDRaster object using a 'template' raster and an Array2D of data.

Parameters
InputData2DArray of floats to be written to LSDRaster.
Returns
LSDRaster containing the data passed in.
Author
SWDG
Date
29/8/13
LSDRaster LSDRaster::M2DFlow ( )

Generate a flow area raster using a multi 2-direction algorithm.

Computes the proportion of all downslope flows for each cell in the input DEM. Finds the cell of the steepest descent and then checks the two neighbouring cells slopes. If either is also downslope proportion flow between the steepest cell and the steepest neighbour. If neither neighbour is downslope 100% of flow follows the steepest path.

Can NOT handle DEMs containing flats or pits - must be filled using the new LSDRaster fill. Function built around original c++ code by Martin Hurst.

Returns
LSDRaster of flow area.
Author
SWDG
Date
02/08/13
void LSDRaster::MakeGaussianKernel ( Array2D< float > &  Kernel,
float  sigma,
int  SimilarityRadius 
)

Generate gaussian weighted kernel.

kernel array must be predeclared of size SimilarityRadius and consist of zeros: Array2D<float> Kernel(SimilarityRadius,SimilarityRadius,0.0);

Kernel generated using: G(x,y) = (1/2*pi*sigma^2) exp ((-x^2+y^2)/(2*sigma^2))

Parameters
Kernel
sigma
SimilarityRadiussimilarity window radius.
Author
Martin Hurst
Date
February 2012
LSDRaster LSDRaster::MapAlgebra_add ( LSDRaster M_raster)

This add two rasters, elementwise Simple elementwise addition.

Parameters
M_rasterThe raster by which to add the current raster
Returns
A raster holding the elementwise sum of the two rasters
Author
SMM
Date
27/10/2016
LSDRaster LSDRaster::MapAlgebra_divide ( LSDRaster M_raster)

This divides two rasters, elementwise Simple elementwise division.

Parameters
M_rasterThe raster by which to divide the current raster
Returns
A raster holding the elementwise quotient of the two rasters
Author
SMM
Date
27/10/2016
LSDRaster LSDRaster::MapAlgebra_multiply ( LSDRaster M_raster)

This multiplies two rasters, elementwise Simple elementwise multiplictation.

Parameters
M_rasterThe raster by which to multiply the current raster
Returns
A raster holding the elementwise product of the two rasters
Author
SMM
Date
27/10/2016
LSDRaster LSDRaster::MapAlgebra_subtract ( LSDRaster M_raster)

This subtracts two rasters, elementwise Simple elementwise subtraction.

Parameters
M_rasterThe raster by which to subtract the current raster
Returns
A raster holding the elementwise difference of the two rasters
Author
SMM
Date
27/10/2016
LSDIndexRaster LSDRaster::mask_to_indexraster_using_threshold ( float  threshold,
bool  belowthresholdisnodata 
)

This function creats an LSDIndexRaster mask (with true == 1 and otherwise nodata) from an LSDRaster. Can mask either above or below a threshold.

Parameters
thresholdThe threshold value
belowthresholdisnodataa boolean that if true means anything below the threshold turns to nodata
Returns
Returns the mask
Author
SMM
Date
9/9/2016
void LSDRaster::mask_to_nodata_below_threshold ( float  threshold)

This function changes any elevation <= threshold to NoDataValue.

Parameters
thresholdThe thresold, silly
Author
SMM
Date
29/10/2014
LSDRaster LSDRaster::mask_to_nodata_using_threshold ( float  threshold,
bool  belowthresholdisnodata 
)

This function changes any data point either above or below threshold to NoDataValue.

Parameters
thresholdThe threshold value
belowthresholdisnodataa boolean that if true means anything below the threshold turns to nodata
Returns
Returns the masked raster
Author
SMM
Date
28/9/2016
LSDRaster LSDRaster::mask_to_nodata_using_threshold_using_other_raster ( float  threshold,
bool  belowthresholdisnodata,
LSDRaster MaskingRaster 
)

This function changes any data point either above or below threshold to NoDataValue The threshold is determined by a second raster.

Parameters
thresholdThe threshold value
belowthresholdisnodataa boolean that if true means anything below the threshold turns to nodata
MaskingRasteran LSDRaster that is used to define the mask
Returns
Returns the masked raster
Author
SMM
Date
28/9/2016
LSDRaster LSDRaster::mask_to_nodata_with_mask_raster ( LSDIndexRaster Mask_raster,
int  mask_value 
)

This function masks a raster to nodata based on a mask value and a mask raster.

Parameters
Mask_rasterthe LSDIndexRaster that contains the mask
mask_valuethe value on the mask that triggers a nodata
Returns
a new LSDRaster that has the masked portions as nodata
Author
SMM
Date
4/11/2014
void LSDRaster::MaskRaster ( LSDIndexRaster  Mask)

Function to update an LSDRaster based on a LSDIndexRaster mask.

Parameters
LSDIndexRasterTheMask
Author
MDH
Date
26/07/2017
float LSDRaster::max_elevation ( void  )

Calculates max elevation of a raster.

Returns
The spatially distributed relief
Author
JAJ (entered into trunk SMM)
Date
01/02/2014
LSDRaster LSDRaster::MDFlow ( vector< string >  BoundaryConditions)

Generate a flow area raster using a multi direction algorithm.

Computes the proportion of all downslope flows for each cell in the input DEM and routes the flow accordingly. Consequently the dem is sorted and indexed using LSDStatsTools. Can handle DEMs containing flats, but pits must be filled using the new LSDRaster fill.

Currently only works with periodic boundaries. Function built around original c++ code by Martin Hurst.

Parameters
BoundaryConditionsVector as in LSDFlowInfo object.
Returns
LSDRaster of flow area.
Author
SWDG
Date
18/4/13 - 24/4/13
float LSDRaster::mean_elevation ( void  )

Calculates mean elevation of a raster.

Returns
The spatially distributed relief
Author
JAJ (entered into trunk SMM)
Date
01/02/2014 modified 09/06/2014 by SMM
float LSDRaster::mean_relief ( float  kernelsize)

Calculates mean relief of a raster, it defaults to a circular kernal.

Returns
The spatially distributed relief
Author
JAJ (entered into trunk SMM)
Date
01/02/2014 modified 09/06/2014 by SMM
LSDRaster LSDRaster::MergeRasters ( LSDRaster RasterToAdd)

Method to merge data from two LSDRasters WITH SAME EXTENT together. /// The data from the raster specified as an argument will be added (will overwrite the original raster if there is a conflict).

Parameters
RasterToAddsecond raster to add to original raster
Author
FJC
Date
30/09/16
LSDRaster LSDRaster::neighbourhood_statistics_fraction_condition ( float  window_radius,
int  neighbourhood_switch,
int  condition_switch,
float  test_value 
)

tests neighbourhood for the fraction of values for which the specified condition is met.

The second argument (neighbourhood_switch) specifies the neighbourhood type: 0 Square neighbourhood 1 Circular window

the third argument (condition_switch) specifies the condition using an integer as follows: 0 == 1 != 2 > 3 >= 4 < 5 <=

Parameters
floatwindow_radius -> radius of neighbourhood
intneighbourhood_switch -> see above
intcondition_switch -> see above
floattest_value -> the value to test against in the conditional statement
Returns
an LSDRaster with the fraction of cells in neightbourhood for which condition statement is true
Author
DTM
Date
20/06/2014
LSDRaster LSDRaster::neighbourhood_statistics_local_relief ( float  window_radius,
int  neighbourhood_switch 
)

gets relief within value specified circular neighbourhood

The second argument (neighbourhood_switch) specifies the neighbourhood type: 0 Square neighbourhood 1 Circular window

Parameters
floatwindow_radius -> radius of neighbourhood
intneighbourhood_switch -> see above
Returns
LSDRasters contianing the relief within a neighbourhood
Author
SMM
Date
16/11/2014
LSDRaster LSDRaster::neighbourhood_statistics_spatial_average ( float  window_radius,
int  neighbourhood_switch 
)

gets mean value for specified circular neighbourhood

The second argument (neighbourhood_switch) specifies the neighbourhood type: 0 Square neighbourhood 1 Circular window

Parameters
floatwindow_radius -> radius of neighbourhood
intneighbourhood_switch -> see above
Returns
an LSDRaster with the mean value of cells in neightbourhood
Author
DTM
Date
20/06/2014
vector< LSDRaster > LSDRaster::neighbourhood_statistics_spatial_average_and_SD ( float  window_radius,
int  neighbourhood_switch 
)

gets mean & standard deviation value specified circular neighbourhood

The second argument (neighbourhood_switch) specifies the neighbourhood type: 0 Square neighbourhood 1 Circular window

Parameters
floatwindow_radius -> radius of neighbourhood
intneighbourhood_switch -> see above
Returns
vector<LSDRaster> with 2 LSDRasters, the first with the mean value of cells in neighbourhood, the second with the standard deviation
Author
DTM
Date
24/09/2014
LSDRaster LSDRaster::NonLocalMeansFilter ( int  WindowRadius = 2,
int  SimilarityRadius = 2,
int  DegreeFiltering = 2,
float  Sigma = 1.25 
)

Perform Non-local means filtering on a DEM following Baude et al [2005].

Smoothes non-gaussian noise. Martin Hurst, February, 2012 Modified by David Milodowski, May 2012- generates grid of recording filtered noise

WindowRadius has to be <= SimilarityRadius ?

Adapted from a matlab script by: Author: Jose Vicente Manjon Herrera & Antoni Buades Date: 09-03-2006

Implementation of the Non local filter proposed for A. Buades, B. Coll and J.M. Morel in "A non-local algorithm for image denoising"

**Added soft threshold optimal correction - David Milodowski, 05/2012

Parameters
WindowRadiussearch window radius (defualt=2).
SimilarityRadiussimilarity window radius (defualt=2).
DegreeFilteringdegree of filtering (defualt=2).
Sigma(default=1.25).
Returns
Filtered LSDRaster object.
Author
MDH, DTM
Date
February 2012
void LSDRaster::OverwriteRaster ( LSDRaster RasterToAdd)

Method to merge data from two LSDRasters WITH SAME EXTENT together. /// The data from the raster specified as an argument will be added (will overwrite the original raster if there is a conflict). Overloaded function to rewrite original raster rather than creating a new one.

Parameters
RasterToAddsecond raster to add to original raster
Author
FJC
Date
07/04/17
void LSDRaster::PadRasterSymmetric ( Array2D< float > &  PaddedRasterData,
int &  SimilarityRadius 
)

Creates a buffer around an array (of size SimilarityRadius) and gives the new border mirror symmetric values of the original array reflected across the boundary.

SimilarityRadius should be the size of the window if filtering. New array has size nrows + 2*SimilarityRadius by ncols + 2*SimilarityRadius.

Parameters
PaddedRasterDataPadded LSDRaster.
SimilarityRadiussimilarity window radius.
Author
Martin Hurst
Date
February 2012
LSDRaster LSDRaster::PeronaMalikFilter ( int  timesteps,
float  percentile_for_lambda,
float  dt 
)

Filters the raster using a Perona-Malik non-linear diffusion filter.

This follows the algorithm descibed in Passalacqua et al. (2010), A geometric framework for channel network extraction from lidar: Nonlinear diffusion and geodesic paths, J. Geophys. Res., 115(F1), F01002, doi:10.1029/2009JF001254. See also Catte et al. (1992), Image Selective Smoothing and Edge Detection by Nonlinear Diffusion, SIAM J. Numer. Anal., 29(1), 182-193, doi:10.1137/0729012.

Parameters
timestepsthe number of diffusion timesteps. Suggest ~50 for 1m LiDAR
lambdapercentile (selects the gradient percentile that is used to define lambda. Suggest 90th percentile)
dtThe timestep for each round of diffusion. Suggest that this is 0.1 to avoid stability issues (same as Passalacqua et al. 2010)
Returns
a filtered raster
Author
David Milodowski
Date
Feb 2015
LSDIndexRaster LSDRaster::PointShapefileToRaster ( string  FileName)

Method to turn a point shapefile into an LSDIndexRaster.

Can be used to turn a shapefile of channel heads into a sources raster. Does not do any bounds checking or shapefile type checking.

Parameters
FileNameThe path and filename of the shapefile to be loaded, must include the file extension.
Returns
An LSDIndexRaster converted from a point shapefile.
Author
SWDG
Date
13/3/14
LSDIndexRaster LSDRaster::PolylineShapefileToRaster ( string  FileName)

Method to turn a polyline shapefile into an LSDIndexRaster.

Can be used to turn a shapefile of a river network into a raster. Does not do any bounds checking or shapefile type checking.

Works by calculating points along each line spaced by less than the data resolution. This has the effect of flaggin every raster cell along a polyline.

Parameters
FileNameThe path and filename of the shapefile to be loaded, must include the file extension.
Returns
An LSDIndexRaster converted from a polyline shapefile.
Author
SWDG
Date
21/3/14
LSDRaster LSDRaster::PoupulateRasterGaussian ( float  minimum,
float  mean 
)

Populate a raster with random noise drawn from a gaussian distribution of given mean and minimum values.

Parameters
minimumMinimum value of the distribution to draw values from.
meanMean value of the distribution to draw values from.
Author
SWDG
Date
9/6/16

Populate a raster with random noise drawn from a gaussian distribution of given mean and minimum values. SWDG 9/6/16

LSDRaster LSDRaster::PoupulateRasterSingleValue ( float  value)

Populate a raster with a single value.

Parameters
valueValue to populate all non nodata cells with.
Author
SWDG
Date
9/6/16

Populate a raster with a given value. SWDG 9/6/16

LSDRaster LSDRaster::QuinnMDFlow ( )

Generate a flow area raster using a multi direction algorithm.

Computes the proportion of all downslope flows for each cell in the input DEM, and weights them using the equation from Quinn et al 1991 and routes the flow accordingly.

Paper link: http://onlinelibrary.wiley.com/doi/10.1002/hyp.3360050106/abstract

Cardinal Weighting = (elevation_drop/total_elevation_drop)*DataResolution/2
Diagonal Weighting = ((elevation_drop/total_elevation_drop)*(1/root(2)))* DataResolution*0.354

Can NOT handle DEMs containing flats or pits - must be filled using the new LSDRaster fill. Function built around original c++ code by Martin Hurst.

Returns
LSDRaster of flow area.
Author
SWDG
Date
18/4/13
void LSDRaster::raster_multiplier ( float  multiplier)

This multiplies the raster data by a multiplier Note that values are replaced.

Author
SMM
Date
06/05/2015
void LSDRaster::raster_statistics_by_index ( LSDIndexRaster IndexRaster,
vector< float > &  mean_vector,
vector< float > &  sd_vector,
vector< float > &  serr_vector,
vector< int > &  Npts_vector 
)

Takes a raster and a corresponding index raster, and calculates the mean, sd and standard error by index. Returns four vectors: mean, st.dev., st.err and Number of points for each category.

Parameters
inputindex raster
outputvector with mean values
outputvector with standard deviation values
outputvector with standard error values
outputvector with number of points
Author
DTM
Date
28/11/2013
LSDRaster LSDRaster::RasterTrimmer ( )

Calculate the minimum bounding rectangle for an LSDRaster Object and crop out all the surrounding NoDataValues to reduce the size and load times of output rasters.

Ideal for use with chi analysis tools which output basin and chi m value rasters which can be predominantly no data. As an example, a 253 Mb file can be reduced to ~5 Mb with no loss or resampling of data.
Modded 6/11/14 to cope with bil files and to catch cases where some or all of the edges cannot be trimmed - SWDG

Returns
A trimmed LSDRaster object.
Author
SWDG
Date
22/08/13
LSDRaster LSDRaster::RasterTrimmerPadded ( int  padded_pixels)

Calculate the minimum bounding rectangle for an LSDRaster Object and crop out all the surrounding NoDataValues to reduce the size and load times of output rasters. Similar to RasterTrimmer but has a pixel buffer. Useful for CRN data since sometimes the channel in the DEM does not correspond exactly with the data point.

Ideal for use with chi analysis tools which output basin and chi m value rasters which can be predominantly no data. As an example, a 253 Mb file can be reduced to ~5 Mb with no loss or resampling of data.

Parameters
padded_pixelsthe number of pixels to pad the DEM with
Returns
A trimmed LSDRaster object.
Author
SMM
Date
18/03/15
LSDRaster LSDRaster::RasterTrimmerSpiral ( )

Takes a raster and trims nodata from around the edges to result in a rectangular LSDRaster.

Returns
A trimmed LSDRaster object.
Author
SMM
Date
5/11/14
void LSDRaster::read_ascii_raster_integers ( string  FILENAME)

Reads a raster of integers and populates LSDRaster integer array member data.

Author
DAV
Todo:
Really, one ought to modify LSDRaster so that it is a class template, and then wouldn't need different TNT Array data members for when we have floats, double, ints etc. Might be tricky though, although if done carefully it should not break peoples code.
void LSDRaster::read_raster ( string  filename,
string  extension 
)

Read a raster into memory from a file.

The supported formats are .asc and .flt which are both exported and imported by arcmap.

The filename is the string of characters before the '.' in the extension and the extension is the characters after the '.'.

If the full filename is my_dem.01.asc then: filename = "my_dem.01" and extension = "asc".

For float files both a data file and a header are read the header file must have the same filename, before extention, of the raster data, and the extension must be .hdr.

Author
SMM
Date
01/01/12
LSDRaster LSDRaster::remove_positive_hilltop_curvature ( LSDRaster hilltop_curvature)

Removes positive hilltop curvature values.

Modifies the hilltop curvature raster to remove pixels with positive curvature caused by noise

Parameters
hilltop_curvaturehilltop curvature input raster
Returns
LSDRaster of hilltop curvature with positive values removed
Author
FJC
Date
24/03/14
void LSDRaster::remove_positive_values ( )

Removes positive values from a raster.

Modifies araster to remove pixels with positive values

Author
MDH
Date
25/07/17
void LSDRaster::remove_seas ( )

This function changes any elevation <= 0 to NoDataValue.

Author
SMM
Date
03/10/2014
LSDRaster LSDRaster::RemoveAbove ( float  Value)

Simple method to remove any values above a user supplied value from an LSDRaster.

Parameters
Valuefloat of the threshold above which values will be removed.
Author
SWDG
Date
25/11/15
LSDRaster LSDRaster::RemoveBelow ( float  Value)

Simple method to remove any values below a user supplied value from an LSDRaster.

Parameters
Valuefloat of the threshold below which values will be removed.
Author
SWDG
Date
22/6/15
LSDRaster LSDRaster::Resample ( float  OutputResolution)

Method to resample an LSDRaster to a lower resolution.

Parameters
OutputResolutionthe resolution in spatial units to be resampled to.
Returns
An LSDRaster resampled to the OutputResolution.
Author
SWDG
Date
17/3/14
void LSDRaster::rewrite_with_random_values ( float  range)

rewrite all the data array values with random numbers (with a uniform distribution).

Parameters
rangeis the range of values.
Author
SMM
Date
18/02/14
LSDRaster LSDRaster::RidgeBuffer ( int  BufferRadius)

Pass a buffer over a ridge LSDRaster object to increase sampling area.

Buffers equally in all directions, so use with care to avoid sampling areas away from the axis of the original ridge line.

Parameters
BufferRadiusoptional integer buffer radius between 1 and 6.
Precondition
Default buffer radius is 2 and will revert to that value if a radius outside the vaid range (1 to 6) is passed.
Returns
LSDRaster object containing buffered ridges.
Author
SWDG
Date
04/2013
LSDRaster LSDRaster::RidgeSample ( Array2D< float > &  Ridges)

Module to sample LSDRaster values running along a ridgetop network.

Ridge network is generated from LSDJunctionNetwork::ExtractRidges.

Parameters
Ridges2D Array of ridge lines.
Returns
Sampled LSDRaster object.
Author
SWDG
Date
04/2013
LSDRaster LSDRaster::RidgeSmoother ( int  WindowRadius)

Pass a smoothing window over a ridge LSDRaster object to calculate an average value running along the ridgetop.

Parameters
WindowRadiusoptional integer smoothing radius between 1 and 6.
Precondition
Default smoothing radius is 2 and will revert to that value if a radius outside the vaid range (1 to 6) is passed.
Returns
Averaged LSDRaster object.
Author
SWDG
Date
04/2013
void LSDRaster::rudimentary_nodata_fill ( )

a very rudimentay filling routine that just fills nodata nodes with the average elevation of its neighbors

Author
SMM
Date
04/11/2014
vector< vector< float > > LSDRaster::Sample_Along_Ridge ( LSDRaster Raster1,
LSDRaster Raster2,
LSDRaster Raster3,
int  a,
int  b,
int  threshold 
)

Sample the values of 3 input rasters that intersect with the point a,b within the area defined by threshold.

Parameters
Raster1First LSDRaster to sample.
Raster2Second LSDRaster to sample.
Raster3Third LSDRaster to sample.
aInteger row index of point to sample.
bInteger col index of point to sample.
thresholdThe number of cells of hilltop to sample.
Returns
A vector of vectors of floats, containing the sampled values for each raster.
Author
SWDG
Date
23/1/17
void LSDRaster::set_data_element ( int  row,
int  column,
float  value 
)
inline

Sets the raster data at a specified location.

Parameters
rowAn integer, the X coordinate of the target cell.
columnAn integer, the Y coordinate of the target cell.
valueThe value of the updated raster element
Author
SMM
Date
19/05/16
void LSDRaster::SetWrapSample ( int  row,
int  col,
float  value 
)

This sets a value in the data array withthe added feature that it wraps beyond NRows and NCols.

Parameters
Therow of data to be reset.
Thecolumn of the data to be reset.
Thevalue of the data to be reset.
Author
SMM
Date
16/02/2014
Array2D< float > LSDRaster::Shadow ( int  theta,
int  phi 
)

This function generates a hillshade derivative raster using the algorithm outlined in Codilean (2006).

It identifies areas in shadow as 1 and all other values as 0. Is interfaced through LSDRaster::TopoShield and should not be called directly, to generate a hillshade use LSDRaster::hillshade instead.

Parameters
thetaThe zenith angle of the illumination source in degrees.
phiThe azimuth angle of the illumination source in degrees.
Returns
2D Array of floats.
Author
SWDG
Date
11/4/13
Array2D< float > LSDRaster::Shadows ( int  Azimuth,
int  ZenithAngle 
)

Function to determine areas of a DEM that are in shadow from a given radiation source defined by an Azimuth and Zenith following Codilean (2006).

Performs a coordinate transformation, rotating the x,y,z coordinates about the Azimuth and Zenith such that the coordinates are aligned with the Azimuth and Zenith. Shaded cells are then found by tracking in the direction of the radiation source and looking for transformed z values greater than that at the cell of interest which would therefore cast a shadow.

Parameters
Azimuthof the illumination source in degrees.
ZenithAngleof the illumination source in degrees
Returns
Hillshaded 2D Array of ints
Author
MDH
Date
Feb 2015
float LSDRaster::SingleBasinAverager ( LSDIndexRaster Basin)

Module calculates an average value to each for a given raster from within a basin.

Parameters
BasinsLSDIndexRaster of a Drainage basin
Returns
Float of the averaged value
Author
SWDG
Date
24/3/2015
void LSDRaster::strip_raster_padding ( )

Strips the edge rows/columns of a LSDRaster on each side of the array.

This removes 1 pixel/grid cell from each side of an LSDRaster Note that it modifies the original raster and reassigns the RasterData_dbl data member to the new 'trimmed' raster. It then reduces the NCols and NRows values by 2, but does not modify the ll-corner values. It was primarily written for a special case in LSDCatchmentModel but will work with any LSDRaster.

Author
DAV
Date
01/04/2016
LSDRaster LSDRaster::TopographicShielding ( int  theta_step,
int  phi_step 
)

This function generates a topographic shielding raster using the algorithm outlined in Codilean (2006).

Creating a raster of values between 0 and 1 of shadowed cells which can be used as a scaling factor in Cosmo analysis.

Goes further than the original algorithm allowing a theoretical theta, phi pair of 1,1 to be supplied and although this will increase the computation time significantly, it is much faster than the original Avenue and VBScript implementations (This is probably no longer true now that we incorporate drop shadows (MDH, Feb 2015)).

Takes 2 ints, representing the theta, phi paring required. Codilean (2006) used 5,5 as the standard values, but in reality values of 10,15 are often preferred to save processing time.

Parameters
theta_stepSpacing of sampled theta values.
phi_stepSpacing of sampled phi values.
Precondition
phi_step must be a factor of 360.
Author
SWDG
Date
11/4/13
map< string, string > LSDRaster::Update_GeoReferencingStrings ( float  NewXmin,
float  NewYmax 
)

Method which takes a new xmin and ymax value and modifys the GeoReferencingStrings map_info line to contain these new values.

Intended for use in the rastertrimmer methods and is called from within these methods. Modifying georeferencing information by hand is messy and should be avoided if at all possible.

Parameters
NewXminfloating point value of the new minimum x value in the raster.
NewYmaxfloating point value of the new maximum y value in the raster.
Returns
An updated GeoReferencingStrings object.
Author
SWDG
Date
6/11/14
void LSDRaster::Update_GeoReferencingStrings ( )

Method which updates the map info element of the georeferencing strings based on information within the datamembers of the raster.

Intended for use when changing raster dimesions

Author
SMM
Date
6/11/14
float LSDRaster::WrapSample ( int  row,
int  col 
)

This returns a value from the array data element but wraps around the array dimensions so that row > NRows (for example) returns a value.

Parameters
Therow of the data point you want. Column of desired data point.
Returns
The value of the data array at the desired row and column.
Author
SMM
Date
16/02/2014
LSDRaster LSDRaster::write_dinf_flowdir_to_LSDRaster ( Array2D< float >  dinflow)

Function to write the D-infinity flow directions to an LSDRaster.

Parameters
dinflowArray of Flowdirections generated by D_inf_FlowDir().
Returns
LSDRaster of D-inf flow directions in degrees.
Author
SWDG
Date
26/07/13
void LSDRaster::write_double_bil_raster ( string  filename,
string  string_filename 
)

Writes out a double array to a ENVI bil file (untested!)

Bug:
Unlikely to work as Georeferencing not set. DAV to fix.
void LSDRaster::write_double_raster ( string  filename,
string  extension 
)

This calls raster write functions, writing from Arrays of type <double> to raster format.

Sorry for duplicating a load of code, but I couldn't think of a good way to overload the function without passing the raster data array or breaking someone elses code.

Parameters
filenamea string of the filename without the extension.
extensiona string of the extension without the leading dot
Author
DAV
Date
07-12-2015
void LSDRaster::write_raster ( string  filename,
string  extension 
)

Read a raster from memory to a file.

The supported formats are .asc and .flt which are both exported and imported by arcmap.

The filename is the string of characters before the '.' in the extension and the extension is the characters after the '.'.

If the full filename is my_dem.01.asc then: filename = "my_dem.01" and extension = "asc".

For float files both a data file and a header are written the header file must have the same filename, before extention, of the raster data, and the extension must be .hdr.

Parameters
filenamea string of the filename without the extension.
extensiona string of the extension without the leading dot
Author
SMM
Date
01/01/12
void LSDRaster::write_RasterData_to_text_file ( string  filename)

This function returns the raster data as text file.

Returns
text file with raster data
Author
FJC
Date
30/09/16

The documentation for this class was generated from the following files: