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

Object to perform flow routing. More...

#include <LSDFlowInfo.hpp>

Public Member Functions

 LSDFlowInfo ()
 The create function. This is default and throws an error. More...
 
 LSDFlowInfo (string fname)
 Creates a FlowInfo object from a binary flowinfo data. More...
 
 LSDFlowInfo (LSDRaster &TopoRaster)
 Creates a FlowInfo object from a binary flowinfo data. This assumes no flux boundaries. More...
 
 LSDFlowInfo (vector< string > &BoundaryConditions, LSDRaster &TopoRaster)
 Creates a FlowInfo object from topography. 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_lat_and_long_locations (double X, double Y, double &lat, double &longitude, LSDCoordinateConverterLLandUTM Converter)
 a function to get the lat and long of a location provided as northing and easting Assumes WGS84 ellipsiod 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 retrieve_receiver_information (int current_node, int &reveiver_node, int &receiver_row, int &receiver_col)
 Gives the reciever information for a given node. More...
 
void retrieve_receiver_information (int current_node, int &reveiver_node)
 Gives the reciever information for a given node. More...
 
void retrieve_current_row_and_col (int current_node, int &curr_row, int &curr_col)
 Get the row and column indices of a given node. More...
 
int get_NodeIndex_from_row_col (int row, int col)
 Get the index from row/col. More...
 
void get_x_and_y_from_current_node (int current_node, float &current_X, float &current_Y)
 Get the X and Y coordinates of a given node. More...
 
void get_lat_and_long_from_current_node (int current_node, double &current_lat, double &current_long, LSDCoordinateConverterLLandUTM Converter)
 Get the lat and longitude coordinates of a given node. More...
 
void print_vector_of_nodeindices_to_csv_file (vector< int > &nodeindex_vec, string outfilename)
 This function takes a vector of node indices and prints a csv file that can be read by arcmap. More...
 
void print_vector_of_nodeindices_to_csv_file_with_latlong (vector< int > &nodeindex_vec, string outfilename)
 This function takes a vector of node indices and prints a csv file that can be read by arcmap: similar to above but also prints lat and long. More...
 
void print_vector_of_nodeindices_to_csv_file_Unique (vector< int > &nodeindex_vec, string outfilename)
 This function takes a vector of node indices and prints a csv file that can be read by arcmap, adding in a unique id to each row, independent of the nodeindex. More...
 
int retrieve_contributing_pixels_of_node (int node)
 Get the number of pixels flowing into a node. More...
 
int retrieve_flow_length_code_of_node (int node)
 Get the FlowLengthCode of a given node. More...
 
int get_LocalFlowDirection (int row, int col)
 Get the FlowDirection of a row and column pair. More...
 
int retrieve_ndonors_to_node (int current_node)
 get the number of donors to a given node More...
 
int retrieve_node_from_row_and_column (int row, int column)
 Get the node for a cell at a given row and column. More...
 
vector< int > retrieve_donors_to_node (int current_node)
 gets a vector of all the donors to a given node More...
 
float get_DrainageArea_square_km (int this_node)
 returns the draiange area of a node in square km More...
 
float get_DrainageArea_square_m (int this_node)
 returns the draiange area of a node in square m 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
 
map< string, string > get_GeoReferencingStrings () const
 
int get_NDataNodes () const
 
vector< int > get_BaseLevelNodeList ()
 
vector< int > get_donorStack () const
 
vector< int > get_SVector () const
 
Array2D< int > get_FlowDirection () const
 
void add_to_stack (int lm_index, int &j_index, int bl_node)
 Recursive add_to_stack routine, from Braun and Willett (2012) equations 12 and 13. More...
 
LSDIndexRaster write_NodeIndex_to_LSDIndexRaster ()
 Write NodeIndex to an LSDIndexRaster. More...
 
LSDIndexRaster write_FlowDirection_to_LSDIndexRaster ()
 Write FlowDirection to an LSDIndexRaster. More...
 
LSDIndexRaster write_FlowLengthCode_to_LSDIndexRaster ()
 Write FlowLengthCode to an LSDIndexRaster. More...
 
LSDIndexRaster write_NodeIndexVector_to_LSDIndexRaster (vector< int > &nodeindexvec)
 This function writes and LSDIndexRaster containing the location of nodes in the nodeindexvector. More...
 
LSDIndexRaster write_NodeIndexVector_to_LSDIndexRaster_Unique (vector< int > &nodeindexvec)
 This function writes an LSDIndesxRaster given a list of node indices, and give every pixel its nodeindex value, which is unique. More...
 
LSDIndexRaster write_NContributingNodes_to_LSDIndexRaster ()
 Write NContributingNodes to an LSDIndexRaster. More...
 
LSDIndexRaster write_FlowDirection_to_LSDIndexRaster_Arcformat ()
 Writes flow directions to an LSDIndexRaster. Flow direction in arcmap format is:

32 64 128
16 0 1
8 4 2
. More...
 
LSDRaster write_DrainageArea_to_LSDRaster ()
 
void print_flow_info_vectors (string filename)
 Prints the flow information to file. More...
 
void unpickle (string filename)
 Unpickles flow information data from a binary file. More...
 
void pickle (string filename)
 Pickles flow information data from a binary file. More...
 
map< string, vector< string > > load_csv_data (string filename)
 This loads a csv file, putting the data into a data map. More...
 
vector< string > get_data_column (string column_name, map< string, vector< string > > data_map)
 This gets a data column from the csv file. More...
 
vector< float > data_column_to_float (string column_name, map< string, vector< string > > data_map)
 This gets a data column from the csv file, and converts it to a float vector. More...
 
vector< int > data_column_to_int (string column_name, map< string, vector< string > > data_map)
 This gets a data column from the csv file, and converts it to an int vector. More...
 
vector< int > Ingest_Channel_Heads (string filename, string extension, int input_switch=2)
 Method to ingest the channel heads raster generated using channel_heads_driver.cpp into a vector of source nodes so that an LSDJunctionNetwork can be created easily from them. UPDATE if the extension is a csv file it reads the node indices directly UPDATE, FJC 20/01/16 - changed default input switch to 2 More...
 
vector< int > Ingest_Channel_Heads (string filename, int input_switch=2)
 Method to ingest the channel heads raster generated using channel_heads_driver.cpp into a vector of source nodes so that an LSDJunctionNetwork can be created easily from them. UPDATE if the extension is a csv file it reads the node indices directly UPDATE, FJC 20/01/16 - changed default input switch to 2 ***********UPDATE - overloaded function to read in the column headers using the csv logic rather than assume that the columns have to be in a specific order. ONLY WORKS WITH CSV EXTENSIONS. FJC 23/03/17*************************. More...
 
vector< int > Ingest_Channel_Heads_OS (string csv_filename)
 Method to ingest sources from OS MasterMap Water Network Layer (csv) into a vector of source nodes so that an LSDJunctionNetwork can be easily created from them. More...
 
LSDIndexRaster calculate_n_pixels_contributing_from_upslope ()
 This function calculates the contributing pixels. It can be converted to contributing area by multiplying by the DataResolution^2. In this function a pixel that has no donors has a contributing pixel value of 0. More...
 
void calculate_upslope_reference_indices ()
 This calculates area and makes an index into the s vector for efficient calculation of the basin upslope of a given node. More...
 
int retrieve_largest_base_level ()
 This function returns the base level node with the greatest drainage area. More...
 
int retrieve_base_level_node (int node)
 This gets the base level node for any given node. More...
 
vector< int > get_upslope_nodes (int node_number_outlet)
 This function returns an integer vector containing all the node indexes upslope of of the node with number node_number_outlet. More...
 
LSDRaster get_upslope_node_mask (vector< int > source_nodes)
 This function takes a list of sources and then creates a raster with nodata values where points are not upslope of the sources and 1.0 if they are upslope. More...
 
LSDRaster get_upslope_node_mask (vector< int > source_nodes, vector< float > node_values)
 This function takes a list of sources and then creates a raster with nodata values where points are not upslope of the sources and node_values if they are upslope. More...
 
LSDRaster upslope_variable_accumulator (LSDRaster &accum_raster)
 This function accumulates some variable from an LSDRaster The most probably use is to accumulate precipitation in order to get a discharge raster. More...
 
int is_node_upstream (int current_node, int test_node)
 This function tests whether one node is upstream of another node. More...
 
int is_node_base_level (int node)
 This function tests whether a node is a base level node. More...
 
vector< int > get_donor_nodes (int node)
 this function gets a list of the node indices of the donors to a particular node More...
 
vector< float > get_upslope_chi (int starting_node, float m_over_n, float A_0)
 This function calculates the chi function for all the nodes upslope of a given node. More...
 
vector< float > get_upslope_chi (int starting_node, float m_over_n, float A_0, LSDRaster &Discharge)
 This function calculates the chi function for all the nodes upslope of a given node. this version uses discharge rather than area. More...
 
vector< float > get_upslope_chi (vector< int > &upslope_pixel_list, float m_over_n, float A_0)
 This function calculates the chi function for a list of nodes it isn't really a standalone modules, but is only called from get_upslope_chi above. More...
 
vector< float > get_upslope_chi (vector< int > &upslope_pixel_list, float m_over_n, float A_0, LSDRaster &Discharge)
 This function calculates the chi function for a list of nodes it isn't really a standalone modules, but is only called from get_upslope_chi above this version uses discharge rather than area. More...
 
map< int, float > get_upslope_chi_return_map (vector< int > &upslope_pixel_list, float m_over_n, float A_0, int minimum_pixels)
 This function calculates the chi function for a list of nodes it isn't really a standalone modules, but is only called from get_upslope_chi above. It returns a map, which is used to speed up computation. More...
 
map< int, float > get_upslope_chi_return_map (vector< int > &upslope_pixel_list, float m_over_n, float A_0, int minimum_pixels, LSDRaster &Discharge)
 This function calculates the chi function for a list of nodes it isn't really a standalone modules, but is only called from get_upslope_chi above. It returns a map, which is used to speed up computation this version uses discharge rather than area. More...
 
LSDRaster get_upslope_chi_from_multiple_starting_nodes (vector< int > &starting_nodes, float m_over_n, float A_0, float area_threshold)
 this function takes a vector that contains the node indices of starting nodes, and then calculates chi upslope of these nodes to produce a chi map. A threshold drainage area can be used to only map chi where nodes have greater than the threshold drainage area More...
 
LSDRaster get_upslope_chi_from_multiple_starting_nodes (vector< int > &starting_nodes, float m_over_n, float A_0, float area_threshold, LSDRaster &Discharge)
 this function takes a vector that contains the node indices of starting nodes, and then calculates chi upslope of these nodes to produce a chi map. A threshold drainage area can be used to only map chi where nodes have greater than the threshold drainage area More...
 
map< int, float > get_upslope_chi_from_single_starting_node (int starting_node, float m_over_n, float A_0, int minimum_pixels)
 This funtion gets all the upslope chi of a starting node (assuming chi at starting node is 0) and returns a map. More...
 
map< int, float > get_upslope_chi_from_single_starting_node (int starting_node, float m_over_n, float A_0, int minimum_pixels, LSDRaster &Discharge)
 This funtion gets all the upslope chi of a starting node (assuming chi at starting node is 0) and returns a map. More...
 
LSDRaster get_upslope_chi_from_all_baselevel_nodes (float m_over_n, float A_0, float area_threshold)
 This function gets the chi upslope of every base level node that is, it gets the chi values of the entire DEM, assuming all base level nodes have a chi of 0 because this assumes all base level nodes have a chi of 0, this function is probably only appropriate for numerical models. More...
 
LSDRaster get_upslope_chi_from_all_baselevel_nodes (float m_over_n, float Q_0, float area_threshold, LSDRaster &Discharge)
 This function gets the chi upslope of every base level node that is, it gets the chi values of the entire DEM, assuming all base level nodes have a chi of 0 because this assumes all base level nodes have a chi of 0, this function is probably only appropriate for numerical models. This version of the function allows computation with a discharge raster. More...
 
LSDRaster distance_from_outlet ()
 Calculates the distance from outlet of all the base level nodes. Distance is given in spatial units, not in pixels. More...
 
LSDRaster calculate_d8_slope (LSDRaster &Elevation)
 
int find_farthest_upslope_node (int node, LSDRaster &DistFromOutlet)
 This returns the node index of the pixel farthest upslope from the input node. More...
 
vector< int > sort_node_list_based_on_raster (vector< int > node_vec, LSDRaster &SortingRaster)
 This takes a list of nodes and sorts them according to a sorting raster (it could be anything) fin ascending order nodes are then reordered to reflect the sorting of the raster. More...
 
vector< int > sort_node_list_based_on_raster (vector< int > node_vec, LSDIndexRaster &SortingRaster)
 This takes a list of nodes and sorts them according to a sorting raster (it could be anything) fin ascending order nodes are then reordered to reflect the sorting of the raster. More...
 
int get_node_index_of_coordinate_point (float X_coordinate, float Y_coordinate)
 Function to get the node index for a point using its X and Y coordinates. More...
 
void get_nodeindices_from_csv (string csv_filename, vector< int > &NIs, vector< float > &X_coords, vector< float > &Y_coords)
 Get vector of nodeindices from csv file. More...
 
float snap_RasterData_to_Node (int NodeIndex, LSDRaster &InputRaster, int search_radius)
 Function to return the closest value of a raster to a specified node index. More...
 
vector< int > get_sources_index_threshold (LSDIndexRaster &FlowPixels, int threshold)
 A get sources version that uses the flow accumulation pixels. More...
 
vector< int > get_sources_slope_area (LSDIndexRaster &FlowPixels, LSDRaster &Slope, int threshold)
 A get sources version that uses AS^2 (area and slope). More...
 
vector< int > get_sources_from_mapped_channel_heads (vector< float > &X_coords, vector< float > &Y_coords)
 Gets a vector of source nodes based on the X and Y coordinates of mapped channel heads. Can be used if all the channel heads in a basin were mapped to get the stream network and calculate the drainage density. More...
 
void D8_Trace (int i, int j, LSDIndexRaster StreamNetwork, float &length, int &receiver_row, int &receiver_col, Array2D< int > &Path)
 Perform a downslope trace using D8 from a given point source (i,j). More...
 
void MoveChannelHeadDown (vector< int > Sources, float MoveDist, vector< int > &DownslopeSources, vector< int > &FinalHeads)
 Move the location of the channel head downslope by a user defined distance. More...
 
void MoveChannelHeadUp (vector< int > Sources, float MoveDist, LSDRaster DEM, vector< int > &UpslopeSources, vector< int > &FinalHeads)
 Move the location of the channel head upslope by a user defined distance. More...
 
void HilltopFlowRoutingOriginal (LSDRaster Elevation, LSDRaster Hilltops, LSDRaster Slope, LSDRaster Aspect, LSDIndexRaster StreamNetwork)
 
vector< Array2D< float > > HilltopFlowRouting (LSDRaster Elevation, LSDRaster Hilltop_ID, LSDRaster Slope, LSDRaster Aspect, LSDRaster HilltopCurv, LSDRaster PlanCurvature, LSDIndexRaster StreamNetwork, LSDIndexRaster Basins, string Prefix, bool print_paths_switch, int thinning, string trace_path, bool basin_filter_switch, vector< int > Target_Basin_Vector)
 Hilltop flow routing. More...
 
vector< Array2D< float > > HilltopFlowRouting_RAW (LSDRaster Elevation, LSDRaster Hilltops, LSDRaster Slope, LSDIndexRaster StreamNetwork, LSDRaster D_inf_Flowdir, string Prefix, LSDIndexRaster Basins, LSDRaster PlanCurvature, bool print_paths_switch, int thinning, string trace_path, bool basin_filter_switch, vector< int > Target_Basin_Vector)
 Hilltop flow routing which runs on unsmoothed topography. More...
 
vector< Array2D< float > > HilltopFlowRouting_Profile (LSDRaster Elevation, LSDRaster Hilltops, LSDRaster Slope, LSDIndexRaster StreamNetwork, LSDRaster D_inf_Flowdir, string Prefix, LSDIndexRaster Basins, bool print_paths_switch, int thinning, string trace_path, bool basin_filter_switch, vector< int > Target_Basin_Vector)
 Hilltop flow routing which generates elevation profiles. More...
 
LSDIndexRaster find_cells_influenced_by_nodata (LSDIndexRaster &Bordered_mask, LSDRaster &Topography)
 This function creates a mask depicting all cells that are influenced by a pixel that is either on the edge of the DEM or adjacent to a NoData node. More...
 
bool is_upstream_influenced_by_nodata (int nodeindex, LSDRaster &test_raster)
 This function looks at all uplope nodes and sees if any are bordered by nodata. More...
 
vector< int > basin_edge_extractor (int outlet_node, LSDRaster &Topography)
 This function gets nodes that are possibly on basin edge by removing those that do not border NoData. Intended to be passed to function for finding concave hull of basin. More...
 
vector< float > get_raster_values_for_nodes (LSDRaster &Raster, vector< int > &node_indices)
 This function returns all the values from a raster for a corresponding input vector of node indices. More...
 
void D_Inf_single_trace_to_channel (LSDRaster Elevation, int start_node, LSDIndexRaster StreamNetwork, LSDRaster D_inf_Flowdir, vector< vector< float > > &output_trace_coordinates, vector< float > &output_trace_metrics, int &output_channel_node, bool &skip_trace)
 
vector< Array2D< float > > HilltopFlowRoutingBedrock (LSDRaster Elevation, LSDRaster Hilltops, LSDRaster Slope, LSDIndexRaster StreamNetwork, LSDRaster Aspect, string Prefix, LSDIndexRaster Basins, LSDRaster PlanCurvature, bool print_paths_switch, int thinning, string trace_path, bool basin_filter_switch, vector< int > Target_Basin_Vector, LSDRaster RockExposure)
 
vector< int > ProcessEndPointsToChannelHeads (LSDIndexRaster Ends)
 This method removes end nodes which are not the uppermost extent of the channel network. More...
 
vector< int > RemoveSinglePxChannels (LSDIndexRaster StreamNetwork, vector< int > Sources)
 This method removes single pixel channels from a channel network. More...
 
int get_downslope_node_after_fixed_visited_nodes (int source_node, int outlet_node, int n_nodes_to_visit, LSDIndexRaster &VisitedRaster)
 This function starts from a source and goes downstream until it either accumulates n_nodes_to_visit or hits a base level node. More...
 
float get_flow_length_between_nodes (int UpstreamNode, int DownstreamNode)
 This function gets the flow distance between two nodes. More...
 
float get_slope_between_nodes (int upslope_node, int downslope_node, LSDRaster &Elevation)
 This function gets the slope between two nodes based on flow length. More...
 
float get_Euclidian_distance (int node_A, int node_B)
 This function gets the Euclidian distance between two nodes. More...
 
int snap_to_hilltop (int a, int b, int search_radius, LSDRaster &Hilltops)
 Method to snap a point, given as raster coordinates, to a cell in a raster of hilltops. More...
 
void snap_to_hilltops (vector< float > x_locs, vector< float > y_locs, int search_radius, LSDRaster &Hilltops, vector< int > &SnappedNodes, vector< int > &Valid_node_IDs)
 Wrapper around snap_to_hilltop function to process a collection of utm points. 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.
 
int NDataNodes
 The number of nodes in the raster that have data.
 
Array2D< int > NodeIndex
 An array that says what node number is at a given row and column.
 
Array2D< int > FlowDirection
 A raster of flow direction information. More...
 
Array2D< int > FlowLengthCode
 A code to denote the flow length from the node to its reciever node. Each node has one and only one receiver.

0 == no receiver/self receiver (base level)
1 == cardinal direction, flow length = DataResolution
2 == diagonal, flow length = DataResolution*(1/sqrt(2))
.
 
vector< int > RowIndex
 This stores the row of a node in the vectorized node index. It, combined with ColIndex, is the inverse of NodeIndex.
 
vector< int > ColIndex
 This stores the column of a node in the vectorized node index. It, combined with RowIndex, is the inverse of NodeIndex.
 
vector< int > BaseLevelNodeList
 A list of base level nodes.
 
vector< int > NDonorsVector
 Stores the number of donors to each node.
 
vector< int > ReceiverVector
 Stores the node index of the receiving node.
 
vector< int > DeltaVector
 Stores the delta vector which is used to index into the donor stack and order contributing nodes. See Braun and Willett (2012).
 
vector< int > DonorStackVector
 
vector< int > SVector
 This vector is used to caluculate flow accumulation. For each base level node it progresses from a hilltop to a confluence and then jumps to the next hilltop so that by cascading down through the node indices in this list one can quickly calculate drainage area, discharge, sediment flux, etc.
 
vector< int > BLBasinVector
 This stores the base level node for all of the nodes in the DEM.
 
vector< int > SVectorIndex
 This points to the starting point in the S vector of each node.
 
vector< int > NContributingNodes
 The number of contributing nodes INCULDING SELF to a current pixel. It is used in conjunction with the SVectorIndex to build basins upslope of any and all nodes in the node list.
 
vector< string > BoundaryConditions
 Boundary conditions stored in a vector of four strings. The conditions are North[0] East[1] South[2] West[3]. More...
 

Friends

class LSDJunctionNetwork
 Copy of the LSDJunctionNetwork description here when written.
 

Detailed Description

Object to perform flow routing.

Constructor & Destructor Documentation

LSDFlowInfo::LSDFlowInfo ( )
inline

The create function. This is default and throws an error.

Author
SMM
Date
01/016/12
LSDFlowInfo::LSDFlowInfo ( string  fname)
inline

Creates a FlowInfo object from a binary flowinfo data.

Parameters
fnameString of the binary flowinfo data file to be read.
Author
SMM
Date
01/016/12
LSDFlowInfo::LSDFlowInfo ( LSDRaster TopoRaster)
inline

Creates a FlowInfo object from a binary flowinfo data. This assumes no flux boundaries.

Parameters
TopoRasterLSDRaster object containing the topographic data.
Author
SMM
Date
3/07/2015
LSDFlowInfo::LSDFlowInfo ( vector< string > &  BoundaryConditions,
LSDRaster TopoRaster 
)
inline

Creates a FlowInfo object from topography.

Parameters
BoundaryConditionsVector<string> of the boundary conditions at each edge of the DEM file. Boundary conditions can start with 'P' or 'p' for periodic, 'B' or 'b' for base level, or anything else for no flux. the vector shold have 4 elements, 0 is north, 1 is east, 2 is south and 3 is west
TopoRasterLSDRaster object containing the topographic data.
Author
SMM
Date
01/016/12

Member Function Documentation

void LSDFlowInfo::add_to_stack ( int  lm_index,
int &  j_index,
int  bl_node 
)

Recursive add_to_stack routine, from Braun and Willett (2012) equations 12 and 13.

Parameters
lm_indexInteger
j_indexInteger
bl_nodeInteger
vector< int > LSDFlowInfo::basin_edge_extractor ( int  outlet_node,
LSDRaster Topography 
)

This function gets nodes that are possibly on basin edge by removing those that do not border NoData. Intended to be passed to function for finding concave hull of basin.

Parameters
outletnode The node of the outlet
Topographythis is the LSDRaster containing topographic data
Returns
A vector with the node indices of nodes that are adjacent to nodata within the basin
Author
SMM
Date
25/04/2017
LSDRaster LSDFlowInfo::calculate_d8_slope ( LSDRaster Elevation)

calculates the slope measured in the d8 flow direction base level nodes have slope of 0; slope is measured from node to receiver

Parameters
theelevation raster
Returns
A raster of the d8 slope
Author
SMM
Date
21/09/2014
LSDIndexRaster LSDFlowInfo::calculate_n_pixels_contributing_from_upslope ( )

This function calculates the contributing pixels. It can be converted to contributing area by multiplying by the DataResolution^2. In this function a pixel that has no donors has a contributing pixel value of 0.

Returns
LSDIndexRaster of upslope contributing pixels.
Author
SMM
Date
01/016/12
void LSDFlowInfo::calculate_upslope_reference_indices ( )

This calculates area and makes an index into the s vector for efficient calculation of the basin upslope of a given node.

Author
SMM
Date
01/016/12
bool LSDFlowInfo::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 LSDFlowInfo::D8_Trace ( int  i,
int  j,
LSDIndexRaster  StreamNetwork,
float &  length,
int &  receiver_row,
int &  receiver_col,
Array2D< int > &  Path 
)

Perform a downslope trace using D8 from a given point source (i,j).

Overwrites input parameters to return a raster of the path, the length of the trace and the final pixel coordinates of the trace.

Parameters
iRow index of starting point for trace.
jColumn index of starting point for trace.
StreamNetworkAn LSDIndexRaster of the stream network.
lengthLength of trace in spatial units.
receiver_rowRow index of ending point for trace.
receiver_colColumn index of ending point for trace.
PathEmpty raster to store the final trace path.
Author
SWDG
Date
20/1/14
vector< float > LSDFlowInfo::data_column_to_float ( string  column_name,
map< string, vector< string > >  data_map 
)

This gets a data column from the csv file, and converts it to a float vector.

Parameters
column_namea string that holds the column name
Returns
a vector of floats: this holds the data.
Author
SMM (ported into FlowInfo FJC 23/03/17)
Date
17/02/2017
vector< int > LSDFlowInfo::data_column_to_int ( string  column_name,
map< string, vector< string > >  data_map 
)

This gets a data column from the csv file, and converts it to an int vector.

Parameters
column_namea string that holds the column name
Returns
a vector of ints: this holds the data.
Author
SMM (ported into FlowInfo FJC 23/03/17)
Date
17/02/2017
LSDRaster LSDFlowInfo::distance_from_outlet ( )

Calculates the distance from outlet of all the base level nodes. Distance is given in spatial units, not in pixels.

Returns
LSDRaster of the distance to the outlet for all baselevel nodes.
Author
SMM
Date
01/016/12
LSDIndexRaster LSDFlowInfo::find_cells_influenced_by_nodata ( LSDIndexRaster Bordered_mask,
LSDRaster Topography 
)

This function creates a mask depicting all cells that are influenced by a pixel that is either on the edge of the DEM or adjacent to a NoData node.

Parameters
Bordered_maskand LSDIndexRaster that is created by the function find_cells_bordered_by_nodata() in LSDRaster
Topographythis is the LSDRaster containing topographic data
Returns
Influenced_mask the LSDIndexRaster that has values 1 where pixels are influenced by a pixel on the border or next to nodata. They have 0 otherwise
Author
SMM
Date
31/10/14
int LSDFlowInfo::find_farthest_upslope_node ( int  node,
LSDRaster DistFromOutlet 
)

This returns the node index of the pixel farthest upslope from the input node.

Parameters
nodethe node from which you want to find the farthest upslope pixel.
DistFromOutletan LSDRaster containing the distance from the outlet.
Returns
This returns the node index of the pixel farthest upslope from the input node.
Author
SMM
Date
25/19/13
vector<int> LSDFlowInfo::get_BaseLevelNodeList ( )
inline
Returns
Vector of all base level nodes.
vector< string > LSDFlowInfo::get_data_column ( string  column_name,
map< string, vector< string > >  data_map 
)

This gets a data column from the csv file.

Parameters
column_namea string that holds the column name
Returns
a vector of strings: this holds the data.
Author
SMM (ported into FlowInfo FJC 23/03/17)
Date
17/02/2017
float LSDFlowInfo::get_DataResolution ( ) const
inline
Returns
Data resolution as an integer.
vector< int > LSDFlowInfo::get_donor_nodes ( int  node)

this function gets a list of the node indices of the donors to a particular node

Parameters
nodethis is the nodeindex of the node for which you want to find the donors
Returns
a vector of the donor nodes
Author
SMM
Date
21/10/2013
vector<int> LSDFlowInfo::get_donorStack ( ) const
inline
Returns
donor stack vector (depth first search sequence of nodes)
int LSDFlowInfo::get_downslope_node_after_fixed_visited_nodes ( int  source_node,
int  outlet_node,
int  n_nodes_to_visit,
LSDIndexRaster VisitedRaster 
)

This function starts from a source and goes downstream until it either accumulates n_nodes_to_visit or hits a base level node.

Parameters
source_nodeThe starting node
outlet_nodeA node that serves as an end to the channel before the base level. If this is set to a node not on the channel (e.g., -9999) then the node looks for accuulation or a base level node only
n_nodes_to_visitthe number of visited pixels the flow function will travese before it stops A raster that has pixels indicating if they have been visited or not. A visited pixel is denoted by 1, non visted by 0
Returns
outlet_nde the node at the end of the flow path
Author
SMM
Date
19/05/2016
float LSDFlowInfo::get_DrainageArea_square_km ( int  this_node)

returns the draiange area of a node in square km

Parameters
this_nodenode of interest
Returns
draiange area in square km
Author
FJC
Date
06/02/17
float LSDFlowInfo::get_DrainageArea_square_m ( int  this_node)

returns the draiange area of a node in square m

Parameters
this_nodenode of interest
Returns
draiange area in square km
Author
FJC
Date
01/05/18
float LSDFlowInfo::get_Euclidian_distance ( int  node_A,
int  node_B 
)

This function gets the Euclidian distance between two nodes.

Parameters
node_Athe first node
node_Bthe second node
Returns
distance between the two nodes
Author
FJC
Date
17/02/17
float LSDFlowInfo::get_flow_length_between_nodes ( int  UpstreamNode,
int  DownstreamNode 
)

This function gets the flow distance between two nodes.

Parameters
UpstreamNodethe upstream node
Downstreamnodethe downstream node
Returns
flow length between the nodes
Author
FJC
Date
29/09/2016
Array2D<int> LSDFlowInfo::get_FlowDirection ( ) const
inline
Returns
FlowDirection values as a 2D Array.
map<string,string> LSDFlowInfo::get_GeoReferencingStrings ( ) const
inline
Returns
Georeferencing information
void LSDFlowInfo::get_lat_and_long_from_current_node ( int  current_node,
double &  current_lat,
double &  current_long,
LSDCoordinateConverterLLandUTM  Converter 
)

Get the lat and longitude coordinates of a given node.

Parameters
current_nodeInteger index of a given node.
current_latlatitude. Will be replaced by function
current_longlongitude. Will be replaced by function
ConverterA coordinate converter object
Author
SMM
Date
26/04/2017
void LSDFlowInfo::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
void LSDFlowInfo::get_lat_and_long_locations ( double  X,
double  Y,
double &  lat,
double &  longitude,
LSDCoordinateConverterLLandUTM  Converter 
)

a function to get the lat and long of a location provided as northing and easting Assumes WGS84 ellipsiod

Parameters
Xthe Easting of the location
Ythe Northing of the location
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
MDH
Date
27/7/2017
int LSDFlowInfo::get_LocalFlowDirection ( int  row,
int  col 
)
inline

Get the FlowDirection of a row and column pair.

Parameters
rowInteger of row index.
colInteger of col index.
Returns
Integer of the flow direction.
Author
SWDG
Date
04/02/14
int LSDFlowInfo::get_NCols ( ) const
inline
Returns
Number of columns as an integer.
int LSDFlowInfo::get_NDataNodes ( ) const
inline
Returns
Number of nodes with data as an integer.
int LSDFlowInfo::get_NoDataValue ( ) const
inline
Returns
No Data Value as an integer.
int LSDFlowInfo::get_node_index_of_coordinate_point ( float  X_coordinate,
float  Y_coordinate 
)

Function to get the node index for a point using its X and Y coordinates.

Parameters
X_coordinateX_coord of point
Y_coordinateY_coord of point
Returns
int with node index of point
Author
FJC
Date
11/02/14
int LSDFlowInfo::get_NodeIndex_from_row_col ( int  row,
int  col 
)

Get the index from row/col.

Parameters
introw/col of the nodeindex 2DArray
Author
BG
Date
27/12/2017
void LSDFlowInfo::get_nodeindices_from_csv ( string  csv_filename,
vector< int > &  NIs,
vector< float > &  X_coords,
vector< float > &  Y_coords 
)

Get vector of nodeindices from csv file.

Parameters
csv_filenameinput csv file
Returns
vector<int> with nodeindices. Ignores nodatavalues
Author
FJC
Date
14/02/17
int LSDFlowInfo::get_NRows ( ) const
inline
Returns
Number of rows as an integer.
vector< float > LSDFlowInfo::get_raster_values_for_nodes ( LSDRaster Raster,
vector< int > &  node_indices 
)

This function returns all the values from a raster for a corresponding input vector of node indices.

Parameters
AnLSDRaster - must have same dimensions as the LSDFlowInfo object
vector<float>- the node indices for which you want the values
float LSDFlowInfo::get_slope_between_nodes ( int  upslope_node,
int  downslope_node,
LSDRaster Elevation 
)

This function gets the slope between two nodes based on flow length.

Parameters
upslope_nodethe upstream node
downslope_nodethe downstream node
Elevationelevation raster
Returns
slope between the nodes
Author
FJC
Date
04/05/18
vector< int > LSDFlowInfo::get_sources_from_mapped_channel_heads ( vector< float > &  X_coords,
vector< float > &  Y_coords 
)

Gets a vector of source nodes based on the X and Y coordinates of mapped channel heads. Can be used if all the channel heads in a basin were mapped to get the stream network and calculate the drainage density.

Parameters
X_coordsX coordinates of channel heads
Y_coordsY coordinates of channel heads
Returns
Vector of source nodes
Author
FJC
Date
17/02/14
vector< int > LSDFlowInfo::get_sources_index_threshold ( LSDIndexRaster FlowPixels,
int  threshold 
)

A get sources version that uses the flow accumulation pixels.

Parameters
FlowPixelsLSDIndexRaster of flow accumulation in pixels.
thresholdInteger flow accumulation threshold.
Returns
Vector of source integers: these refer to the node indices of the sources.
Author
SMM
Date
01/016/12
vector< int > LSDFlowInfo::get_sources_slope_area ( LSDIndexRaster FlowPixels,
LSDRaster Slope,
int  threshold 
)

A get sources version that uses AS^2 (area and slope).

Parameters
FlowPixelsLSDIndexRaster of flow accumulation in pixels.
SlopeLSDRaster of slope values
thresholdInteger AS^2 threshold
Returns
Vector of source integers: these refer to the node indices of the sources.
Author
FJC
Date
11/02/14
vector<int> LSDFlowInfo::get_SVector ( ) const
inline
Returns
the S vector, which is a sorted list of nodes (see Braun and Willett 2012)
vector< float > LSDFlowInfo::get_upslope_chi ( int  starting_node,
float  m_over_n,
float  A_0 
)

This function calculates the chi function for all the nodes upslope of a given node.

Parameters
starting_nodeInteger index of node to analyse upslope of.
m_over_n
A_0
Returns
Vector of chi values. The node indices of these values are those that would be retured from get_uplope_nodes
Author
SMM
Date
01/16/2012
vector< float > LSDFlowInfo::get_upslope_chi ( int  starting_node,
float  m_over_n,
float  A_0,
LSDRaster Discharge 
)

This function calculates the chi function for all the nodes upslope of a given node. this version uses discharge rather than area.

Parameters
starting_nodeInteger index of node to analyse upslope of.
m_over_n
A_0the referecen discharge
Dischargea raster of the discharge
Returns
Vector of chi values. The node indices of these values are those that would be retured from get_uplope_nodes
Author
SMM
Date
16/10/2015
vector< float > LSDFlowInfo::get_upslope_chi ( vector< int > &  upslope_pixel_list,
float  m_over_n,
float  A_0 
)

This function calculates the chi function for a list of nodes it isn't really a standalone modules, but is only called from get_upslope_chi above.

Parameters
upslope_pixel_listVector of nodes to analyse.
m_over_n
A_0
Returns
Vector of chi values.
Author
SMM
Date
16/01/12
vector< float > LSDFlowInfo::get_upslope_chi ( vector< int > &  upslope_pixel_list,
float  m_over_n,
float  A_0,
LSDRaster Discharge 
)

This function calculates the chi function for a list of nodes it isn't really a standalone modules, but is only called from get_upslope_chi above this version uses discharge rather than area.

Parameters
upslope_pixel_listVector of nodes to analyse.
m_over_n
A_0
Dischargeand LSDRaster of the discharge
Returns
Vector of chi values.
Author
SMM
Date
16/10/15
LSDRaster LSDFlowInfo::get_upslope_chi_from_all_baselevel_nodes ( float  m_over_n,
float  A_0,
float  area_threshold 
)

This function gets the chi upslope of every base level node that is, it gets the chi values of the entire DEM, assuming all base level nodes have a chi of 0 because this assumes all base level nodes have a chi of 0, this function is probably only appropriate for numerical models.

Parameters
m_over_nthe m/n ratio. Chi is quite sensitive to this
A_0the reference drainage area. This is a but arbitrary. We usually use 1000 m^2. Willet et al(2014, Science) used 1m^2. As of 28 July 2014 we've not done any detailed sensitivity analysis on this parameter
area_thresholdthe threshold area (in m^2) that sets the area above which chi is recorded in the chi raster
Returns
this returns an LSDRaster for the chi values of the entire raster, with base level nodes assumed to have chi = 0
Author
SMM
Date
28/14/2014
LSDRaster LSDFlowInfo::get_upslope_chi_from_all_baselevel_nodes ( float  m_over_n,
float  Q_0,
float  area_threshold,
LSDRaster Discharge 
)

This function gets the chi upslope of every base level node that is, it gets the chi values of the entire DEM, assuming all base level nodes have a chi of 0 because this assumes all base level nodes have a chi of 0, this function is probably only appropriate for numerical models. This version of the function allows computation with a discharge raster.

Parameters
m_over_nthe m/n ratio. Chi is quite sensitive to this
A_0the reference discharge (same units as discharge. As of 28 July 2014 we've not done any detailed sensitivity analysis on this parameter
area_thresholdthe threshold area (in m^2) that sets the area above which chi is recorded in the chi raster
Dischargea raster of the discharge
Returns
this returns an LSDRaster for the chi values of the entire raster, with base level nodes assumed to have chi = 0
Author
SMM
Date
16/10/2015
LSDRaster LSDFlowInfo::get_upslope_chi_from_multiple_starting_nodes ( vector< int > &  starting_nodes,
float  m_over_n,
float  A_0,
float  area_threshold 
)

this function takes a vector that contains the node indices of starting nodes, and then calculates chi upslope of these nodes to produce a chi map. A threshold drainage area can be used to only map chi where nodes have greater than the threshold drainage area

this function is meant to mimic the function of the Willett et al (2014) Science paper. You do need to extract the wanted node indices for your starting nodes from a node index map

Parameters
starting_nodesan integer vector containing all the node indices of the node from which you want to start the chi analysis. All of these nodes will be considered to have a starting chi of 0
m_over_nthe m/n ratio. Chi is quite sensitive to this
A_0the reference drainage area. This is a but arbitrary. We usually use 1000 m^2. Willet et al(2014, Science) used 1m^2. As of 28 July 2014 we've not done any detailed sensitivity analysis on this parameter
area_thresholdthe threshold area (in m^2) that sets the area above which chi is recorded in the chi raster
Returns
this returns an LSDRaster for the chi values upslope of all of the nodes indicated in starting_nodes
Author
SMM
Date
28/14/2014
LSDRaster LSDFlowInfo::get_upslope_chi_from_multiple_starting_nodes ( vector< int > &  starting_nodes,
float  m_over_n,
float  A_0,
float  area_threshold,
LSDRaster Discharge 
)

this function takes a vector that contains the node indices of starting nodes, and then calculates chi upslope of these nodes to produce a chi map. A threshold drainage area can be used to only map chi where nodes have greater than the threshold drainage area

this function is meant to mimic the function of the Willett et al (2014) Science paper. You do need to extract the wanted node indices for your starting nodes from a node index map This version allows computation with discharge

Parameters
starting_nodesan integer vector containing all the node indices of the node from which you want to start the chi analysis. All of these nodes will be considered to have a starting chi of 0
m_over_nthe m/n ratio. Chi is quite sensitive to this
A_0the reference discharge. This is arbitrary. As of 28 July 2014 we've not done any detailed sensitivity analysis on this parameter
area_thresholdthe threshold area (in m^2) that sets the area above which chi is recorded in the chi raster
Returns
this returns an LSDRaster for the chi values upslope of all of the nodes indicated in starting_nodes
Author
SMM
Date
16/10/2015
map< int, float > LSDFlowInfo::get_upslope_chi_from_single_starting_node ( int  starting_node,
float  m_over_n,
float  A_0,
int  minimum_pixels 
)

This funtion gets all the upslope chi of a starting node (assuming chi at starting node is 0) and returns a map.

Parameters
starting_nodesan integer containing the node index of the node from which you want to start the chi analysis.
m_over_nthe m/n ratio. Chi is quite sensitive to this
A_0the reference discharge.
mimum_pixelsThis minimum number of contributing pixels needed before chi is calculated
Returns
Returns a map where the key is the node index and the value is chi
Author
SMM
Date
13/07/2017
map< int, float > LSDFlowInfo::get_upslope_chi_from_single_starting_node ( int  starting_node,
float  m_over_n,
float  A_0,
int  minimum_pixels,
LSDRaster Discharge 
)

This funtion gets all the upslope chi of a starting node (assuming chi at starting node is 0) and returns a map.

This version allows computation with discharge

Parameters
starting_nodesan integer containing the node index of the node from which you want to start the chi analysis.
m_over_nthe m/n ratio. Chi is quite sensitive to this
A_0the reference discharge.
mimum_pixelsThis minimum number of contributing pixels needed before chi is calculated
DischargeThe discharge raster
Returns
Returns a map where the key is the node index and the value is chi
Author
SMM
Date
13/07/2017
map< int, float > LSDFlowInfo::get_upslope_chi_return_map ( vector< int > &  upslope_pixel_list,
float  m_over_n,
float  A_0,
int  minimum_pixels 
)

This function calculates the chi function for a list of nodes it isn't really a standalone modules, but is only called from get_upslope_chi above. It returns a map, which is used to speed up computation.

Parameters
upslope_pixel_listVector of nodes to analyse.
m_over_n
A_0
mimum_pixelsThis minimum number of contributing pixels needed before chi is calculated
Returns
A map where the key is the node index and the value is chi
Author
SMM
Date
13/07/17
map< int, float > LSDFlowInfo::get_upslope_chi_return_map ( vector< int > &  upslope_pixel_list,
float  m_over_n,
float  A_0,
int  minimum_pixels,
LSDRaster Discharge 
)

This function calculates the chi function for a list of nodes it isn't really a standalone modules, but is only called from get_upslope_chi above. It returns a map, which is used to speed up computation this version uses discharge rather than area.

Parameters
upslope_pixel_listVector of nodes to analyse.
m_over_n
A_0
mimum_pixelsThis minimum number of contributing pixels needed before chi is calculated
Dischargeand LSDRaster of the discharge
Returns
A map where the key is the node index and the value is chi
Author
SMM
Date
13/07/17
LSDRaster LSDFlowInfo::get_upslope_node_mask ( vector< int >  source_nodes)

This function takes a list of sources and then creates a raster with nodata values where points are not upslope of the sources and 1.0 if they are upslope.

Parameters
source_nodesa vector of node indicies into the sources
Author
SMM
Date
11/11/2015
LSDRaster LSDFlowInfo::get_upslope_node_mask ( vector< int >  source_nodes,
vector< float >  node_values 
)

This function takes a list of sources and then creates a raster with nodata values where points are not upslope of the sources and node_values if they are upslope.

Parameters
source_nodesa vector of node indicies into the sources
node_valuesa vector of the value of the nodes upslope of the sources this vector needs to be the same size as the source_nodes vector
Author
SMM
Date
12/11/2015
vector< int > LSDFlowInfo::get_upslope_nodes ( int  node_number_outlet)

This function returns an integer vector containing all the node indexes upslope of of the node with number node_number_outlet.

Parameters
node_number_outletInteger of the target node.
Returns
Integer vector of upslope node indexes.
Author
SMM
Date
01/016/12
void LSDFlowInfo::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
void LSDFlowInfo::get_x_and_y_from_current_node ( int  current_node,
float &  current_X,
float &  current_Y 
)

Get the X and Y coordinates of a given node.

Parameters
current_nodeInteger index of a given node.
current_XEmpty integer to be assigned the X coordinate of the given node.
current_YEmpty integer to be assigned the Y coordinate of the given node.
Author
BG
Date
20/02/2017
void LSDFlowInfo::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 LSDFlowInfo::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 LSDFlowInfo::get_XMinimum ( ) const
inline
Returns
Minimum X coordinate as an integer.
float LSDFlowInfo::get_YMinimum ( ) const
inline
Returns
Minimum Y coordinate as an integer.
vector< Array2D< float > > LSDFlowInfo::HilltopFlowRouting ( LSDRaster  Elevation,
LSDRaster  Hilltop_ID,
LSDRaster  Slope,
LSDRaster  Aspect,
LSDRaster  HilltopCurv,
LSDRaster  PlanCurvature,
LSDIndexRaster  StreamNetwork,
LSDIndexRaster  Basins,
string  Prefix,
bool  print_paths_switch,
int  thinning,
string  trace_path,
bool  basin_filter_switch,
vector< int >  Target_Basin_Vector 
)

Hilltop flow routing.

Hilltop flow routing code built around original code from Martin Hurst. Based on Lea (1992), with improvements discussed by Tarboton (1997) and a solution to the problem of looping flow paths implemented.

This code is SLOW but robust, a refactored version may appear, but there may not be enough whisky in Scotland to support that endeavour.

The algorithm now checks for local uphill flows and in the case of identifying one, D8 flow path is used to push the flow into the centre of the steepest downslope cell, at which point the trace is restarted. The same technique is used to cope with self intersections of the flow path. These problems are not solved in the original paper and I think they are caused at least in part by the high resolution topogrpahy we are using.

The code is also now built to take a d infinity flow direction raster instead of an aspect raster. See Tarboton (1997) for discussions on why this is the best solution.

The Basins input raster is used to code each hilltop into a basin to allow basin averaging to take place.

The final 5 parameters are used to set up printing flow paths to files for visualisation, if this is not needed simply pass in false to the two boolean switches and empty variables for the others, and the code will run as normal.

The structure of the returned vector< Array2D<float> > is as follows:

[0] Hilltop Network coded with stream ID
[1] Hillslope Lengths
[2] Slope
[3] Relief

Parameters
ElevationLSDRaster of elevation values.
SlopeLSDRaster of slope values.
HilltopsLSDRaster of hilltops.
StreamNetworkLSDIndexRaster of the stream network.
AspectLSDRaster of Aspect.
PrefixString Prefix for output data filename.
BasinsLSDIndexRaster of basin outlines.
PlanCurvatureLSDRaster of planform curvature.
print_paths_switchIf true paths will be printed.
thinningThinning factor, value used to skip hilltops being printed, use 1 to print every hilltop.
trace_pathThe file path to be used to write the path files to, must end with a slash.
basin_filter_switchIf this switch is true only basins in Target_Basin_Vector will have their paths printed.
Target_Basin_VectorVector of Basin IDs that the user wants to print traces for.
Returns
Vector of Array2D<float> containing hillslope metrics.
Author
SWDG
Date
12/2/14
vector< Array2D< float > > LSDFlowInfo::HilltopFlowRouting_Profile ( LSDRaster  Elevation,
LSDRaster  Hilltops,
LSDRaster  Slope,
LSDIndexRaster  StreamNetwork,
LSDRaster  D_inf_Flowdir,
string  Prefix,
LSDIndexRaster  Basins,
bool  print_paths_switch,
int  thinning,
string  trace_path,
bool  basin_filter_switch,
vector< int >  Target_Basin_Vector 
)

Hilltop flow routing which generates elevation profiles.

Hilltop flow routing code built around original code from Martin Hurst. Based on Lea (1992), with improvements discussed by Tarboton (1997) and a solution to the problem of looping flow paths implemented.

THIS VERSION OF THE CODE RETAINS THE FLOODING METHOD TO ALLOW TRACES TO BE USED ON RAW TOPOGRPAHY TO GET EVENT SCALE HILLSLOPE LENGTHS WITH NO SMOOTHING. IN MOST CASES USE THE MAIN METHOD, TO ANALYSE SEDIMENT TRANSPORT OVER GEOMORPHIC TIME.

This code is SLOW but robust, a refactored version may appear, but there may not be enough whisky in Scotland to support that endeavour.

The algorithm now checks for local uphill flows and in the case of identifying one, D8 flow path is used to push the flow into the centre of the steepest downslope cell, at which point the trace is restarted. The same technique is used to cope with self intersections of the flow path. These problems are not solved in the original paper and I think they are caused at least in part by the high resolution topogrpahy we are using.

The code is also now built to take a d infinity flow direction raster instead of an aspect raster. See Tarboton (1997) for discussions on why this is the best solution.

The Basins input raster is used to code each hilltop into a basin to allow basin averaging to take place.

The final 5 parameters are used to set up printing flow paths to files for visualisation, if this is not needed simply pass in false to the two boolean switches and empty variables for the others, and the code will run as normal.

The structure of the returned vector< Array2D<float> > is as follows:

[0] Hilltop Network coded with stream ID
[1] Hillslope Lengths
[2] Slope
[3] Relief

Parameters
ElevationLSDRaster of elevation values.
SlopeLSDRaster of slope values.
HilltopsLSDRaster of hilltops.
StreamNetworkLSDIndexRaster of the stream network.
D_inf_FlowdirLSDRaster of flow directions.
PrefixString Prefix for output data filename.
BasinsLSDIndexRaster of basin outlines.
print_paths_switchIf true paths will be printed.
thinningThinning factor, value used to skip hilltops being printed, use 1 to print every hilltop.
trace_pathThe file path to be used to write the path files to, must end with a slash.
basin_filter_switchIf this switch is true only basins in Target_Basin_Vector will have their paths printed.
Target_Basin_VectorVector of Basin IDs that the user wants to print traces for.
Returns
Vector of Array2D<float> containing hillslope metrics.
Author
SWDG
Date
25/03/15
vector< Array2D< float > > LSDFlowInfo::HilltopFlowRouting_RAW ( LSDRaster  Elevation,
LSDRaster  Hilltops,
LSDRaster  Slope,
LSDIndexRaster  StreamNetwork,
LSDRaster  D_inf_Flowdir,
string  Prefix,
LSDIndexRaster  Basins,
LSDRaster  PlanCurvature,
bool  print_paths_switch,
int  thinning,
string  trace_path,
bool  basin_filter_switch,
vector< int >  Target_Basin_Vector 
)

Hilltop flow routing which runs on unsmoothed topography.

Hilltop flow routing code built around original code from Martin Hurst. Based on Lea (1992), with improvements discussed by Tarboton (1997) and a solution to the problem of looping flow paths implemented.

THIS VERSION OF THE CODE RETAINS THE FLOODING METHOD TO ALLOW TRACES TO BE USED ON RAW TOPOGRPAHY TO GET EVENT SCALE HILLSLOPE LENGTHS WITH NO SMOOTHING. IN MOST CASES USE THE MAIN METHOD, TO ANALYSE SEDIMENT TRANSPORT OVER GEOMORPHIC TIME.

This code is SLOW but robust, a refactored version may appear, but there may not be enough whisky in Scotland to support that endeavour.

The algorithm now checks for local uphill flows and in the case of identifying one, D8 flow path is used to push the flow into the centre of the steepest downslope cell, at which point the trace is restarted. The same technique is used to cope with self intersections of the flow path. These problems are not solved in the original paper and I think they are caused at least in part by the high resolution topogrpahy we are using.

The code is also now built to take a d infinity flow direction raster instead of an aspect raster. See Tarboton (1997) for discussions on why this is the best solution.

The Basins input raster is used to code each hilltop into a basin to allow basin averaging to take place.

The final 5 parameters are used to set up printing flow paths to files for visualisation, if this is not needed simply pass in false to the two boolean switches and empty variables for the others, and the code will run as normal.

The structure of the returned vector< Array2D<float> > is as follows:

[0] Hilltop Network coded with stream ID
[1] Hillslope Lengths
[2] Slope
[3] Relief

Parameters
ElevationLSDRaster of elevation values.
SlopeLSDRaster of slope values.
HilltopsLSDRaster of hilltops.
StreamNetworkLSDIndexRaster of the stream network.
D_inf_FlowdirLSDRaster of flow directions.
PrefixString Prefix for output data filename.
BasinsLSDIndexRaster of basin outlines.
PlanCurvatureLSDRaster of planform curvature.
print_paths_switchIf true paths will be printed.
thinningThinning factor, value used to skip hilltops being printed, use 1 to print every hilltop.
trace_pathThe file path to be used to write the path files to, must end with a slash.
basin_filter_switchIf this switch is true only basins in Target_Basin_Vector will have their paths printed.
Target_Basin_VectorVector of Basin IDs that the user wants to print traces for.
Returns
Vector of Array2D<float> containing hillslope metrics.
Author
SWDG
Date
12/2/14
vector< int > LSDFlowInfo::Ingest_Channel_Heads ( string  filename,
string  extension,
int  input_switch = 2 
)

Method to ingest the channel heads raster generated using channel_heads_driver.cpp into a vector of source nodes so that an LSDJunctionNetwork can be created easily from them. UPDATE if the extension is a csv file it reads the node indices directly UPDATE, FJC 20/01/16 - changed default input switch to 2

Assumes the FlowInfo object has the same dimensions as the channel heads raster.

Parameters
filenameof the channel heads raster.
extensionof the channel heads raster.
(optional)input_switch, ONLY NEEDED FOR LOADING .csv FILES! An integer to determine whether to use the node index (0 -> default), row and column indices (1), or point coordinates from .csv file (2) to locate the channel heads
Returns
Vector of source nodes.
Author
SWDG updated SMM updated DTM
Date
6/6/14 Happy 3rd birthday Skye!!
vector< int > LSDFlowInfo::Ingest_Channel_Heads ( string  filename,
int  input_switch = 2 
)

Method to ingest the channel heads raster generated using channel_heads_driver.cpp into a vector of source nodes so that an LSDJunctionNetwork can be created easily from them. UPDATE if the extension is a csv file it reads the node indices directly UPDATE, FJC 20/01/16 - changed default input switch to 2 ***********UPDATE - overloaded function to read in the column headers using the csv logic rather than assume that the columns have to be in a specific order. ONLY WORKS WITH CSV EXTENSIONS. FJC 23/03/17*************************.

Assumes the FlowInfo object has the same dimensions as the channel heads raster.

Parameters
filenameof the channel heads raster.
extensionof the channel heads raster.
(optional)input_switch, ONLY NEEDED FOR LOADING .csv FILES! An integer to determine whether to use the node index (0 -> default), row and column indices (1), or point coordinates from .csv file (2) to locate the channel heads
Returns
Vector of source nodes.
Author
SWDG updated SMM updated DTM
Date
6/6/14 Happy 3rd birthday Skye!!
vector< int > LSDFlowInfo::Ingest_Channel_Heads_OS ( string  csv_filename)

Method to ingest sources from OS MasterMap Water Network Layer (csv) into a vector of source nodes so that an LSDJunctionNetwork can be easily created from them.

Parameters
csv_filenameCSV file name
Returns
vector of source nodes
Author
FJC
Date
28/11/16
int LSDFlowInfo::is_node_base_level ( int  node)

This function tests whether a node is a base level node.

Parameters
node
Returns
int which is 1 if node is base level, 0 if not
Author
FJC
Date
26/08/15
int LSDFlowInfo::is_node_upstream ( int  current_node,
int  test_node 
)

This function tests whether one node is upstream of another node.

Parameters
current_node
test_node
Returns
Boolean indicating whether node is upstream or not
Author
FC
Date
08/10/13
bool LSDFlowInfo::is_upstream_influenced_by_nodata ( int  nodeindex,
LSDRaster test_raster 
)

This function looks at all uplope nodes and sees if any are bordered by nodata.

Parameters
nodeindexThe node index of the node in question
test_rasterand LSDRaster that is to be tested
Returns
true if the node is influenced by nodata
Author
SMM
Date
29/05/2017
map< string, vector< string > > LSDFlowInfo::load_csv_data ( string  filename)

This loads a csv file, putting the data into a data map.

Parameters
filenameThe name of the csv file including path and extension
Author
SMM (ported into FlowInfo FJC 23/03/17)
Date
16/02/2017
void LSDFlowInfo::MoveChannelHeadDown ( vector< int >  Sources,
float  MoveDist,
vector< int > &  DownslopeSources,
vector< int > &  FinalHeads 
)

Move the location of the channel head downslope by a user defined distance.

Parameters
Sourcesa vector of node indexes of the channel heads to be moved.
MoveDistThe distance in spatial units the head is to be moved.
DownslopeSourcesA vector used to contain the node indexes of the moved channel heads.
FinalHeadsA vector containing a subset of the original channel heads which corresponds to the moved heads.
Author
SWDG
Date
27/11/15
void LSDFlowInfo::MoveChannelHeadUp ( vector< int >  Sources,
float  MoveDist,
LSDRaster  DEM,
vector< int > &  UpslopeSources,
vector< int > &  FinalHeads 
)

Move the location of the channel head upslope by a user defined distance.

Parameters
Sourcesa vector of node indexes of the channel heads to be moved.
MoveDistThe distance in spatial units the head is to be moved.
DEMthe elevation data.
UpslopeSourcesA vector used to contain the node indexes of the moved channel heads.
FinalHeadsA vector containing a subset of the original channel heads which corresponds to the moved heads.
Author
SWDG
Date
27/11/15
void LSDFlowInfo::pickle ( string  filename)

Pickles flow information data from a binary file.

WARNING!!! This creates HUGE files (sometimes 10x bigger than original file). Testing indicates reading this file takes almost as long as recalculating the flowinfo object so is probably not worth doing

Parameters
filenameString of the binary file to be written.
Author
SMM
Date
01/016/12
void LSDFlowInfo::print_flow_info_vectors ( string  filename)

Prints the flow information to file.

Parameters
filenameString of the output file to be written.
Author
SMM
Date
01/016/12
void LSDFlowInfo::print_vector_of_nodeindices_to_csv_file ( vector< int > &  nodeindex_vec,
string  outfilename 
)

This function takes a vector of node indices and prints a csv file that can be read by arcmap.

Parameters
nodeindexvec is a vector of nodeindices (which are ints)
outfilenameis a string of the filename
Author
SMM
Date
03/06/14
void LSDFlowInfo::print_vector_of_nodeindices_to_csv_file_Unique ( vector< int > &  nodeindex_vec,
string  outfilename 
)

This function takes a vector of node indices and prints a csv file that can be read by arcmap, adding in a unique id to each row, independent of the nodeindex.

The unique ID is used to tie triplets of channel heads together for hollow analysis.

Parameters
nodeindexvec is a vector of nodeindices (which are ints)
outfilenameis a string of the filename
Author
SWDG after SMM
Date
2/2/16
void LSDFlowInfo::print_vector_of_nodeindices_to_csv_file_with_latlong ( vector< int > &  nodeindex_vec,
string  outfilename 
)

This function takes a vector of node indices and prints a csv file that can be read by arcmap: similar to above but also prints lat and long.

Parameters
nodeindexvec is a vector of nodeindices (which are ints)
outfilenameis a string of the filename
Author
SMM
Date
20/05/16
vector< int > LSDFlowInfo::ProcessEndPointsToChannelHeads ( LSDIndexRaster  Ends)

This method removes end nodes which are not the uppermost extent of the channel network.

Parameters
Endsan LSDIndexRaster of the end points to be processed.
Returns
A vector of source nodes
Author
SWDG
Date
23/7/15
vector< int > LSDFlowInfo::RemoveSinglePxChannels ( LSDIndexRaster  StreamNetwork,
vector< int >  Sources 
)

This method removes single pixel channels from a channel network.

Parameters
StreamNetworkan LSDIndexRaster of the channel network generated from Sources.
Sourcesa vetcor of integer node indices which need cleaned
Returns
A vector of source nodes
Author
SWDG
Date
23/7/15
int LSDFlowInfo::retrieve_base_level_node ( int  node)

This gets the base level node for any given node.

Parameters
nodethe starting node
Returns
the base level node
Author
SMM
Date
18/12/2016
int LSDFlowInfo::retrieve_contributing_pixels_of_node ( int  node)
inline

Get the number of pixels flowing into a node.

Parameters
nodeInteger of node index value.
Returns
Integer of the number of contributing pixels.
Author
SMM
Date
01/016/12
void LSDFlowInfo::retrieve_current_row_and_col ( int  current_node,
int &  curr_row,
int &  curr_col 
)

Get the row and column indices of a given node.

Parameters
current_nodeInteger index of a given node.
curr_rowEmpty integer to be assigned the row index of the given node.
curr_colEmpty integer to be assigned the column index of the given node.
Author
SMM
Date
01/016/12
vector< int > LSDFlowInfo::retrieve_donors_to_node ( int  current_node)

gets a vector of all the donors to a given node

Parameters
current_nodethe node index from which to get n donors
Returns
a vector containing all the donors to this node
Author
SMM
Date
19/9/2014
int LSDFlowInfo::retrieve_flow_length_code_of_node ( int  node)
inline

Get the FlowLengthCode of a given node.

Parameters
nodeInteger of node index value.
Returns
Integer of the FlowLengthCode.
Author
SMM
Date
01/016/12
int LSDFlowInfo::retrieve_largest_base_level ( )

This function returns the base level node with the greatest drainage area.

Returns
Integer node index.
int LSDFlowInfo::retrieve_ndonors_to_node ( int  current_node)
inline

get the number of donors to a given node

Parameters
current_nodethe node index from which to get n donors
Returns
the number of donors to this cell
Author
SMM
Date
19/9/2014
int LSDFlowInfo::retrieve_node_from_row_and_column ( int  row,
int  column 
)

Get the node for a cell at a given row and column.

Parameters
rowindex
columnindex
Returns
node index
Author
DTM
Date
08/11/2013
void LSDFlowInfo::retrieve_receiver_information ( int  current_node,
int &  reveiver_node,
int &  receiver_row,
int &  receiver_col 
)

Gives the reciever information for a given node.

Parameters
current_nodeInteger
reveiver_nodeEmpty integer to be assigned the index of the reciever node.
receiver_rowEmpty integer to be assigned the row index of the reciever node.
receiver_colEmpty integer to be assigned the column index of the reciever node.
Author
SMM
Date
01/016/12
void LSDFlowInfo::retrieve_receiver_information ( int  current_node,
int &  reveiver_node 
)

Gives the reciever information for a given node.

Parameters
current_nodeInteger
reveiver_nodeEmpty integer to be assigned the index of the reciever node.
Author
BG
Date
06/01/2018
float LSDFlowInfo::snap_RasterData_to_Node ( int  NodeIndex,
LSDRaster InputRaster,
int  search_radius 
)

Function to return the closest value of a raster to a specified node index.

Parameters
NodeIndexof interest
InputRasterraster to return value of
search_radiusrectangular window to search for, in n_pixels
Returns
float value of raster closest to the node index
Author
FJC
Date
08/02/17
int LSDFlowInfo::snap_to_hilltop ( int  a,
int  b,
int  search_radius,
LSDRaster Hilltops 
)

Method to snap a point, given as raster coordinates, to a cell in a raster of hilltops.

Parameters
aInteger row index.
bInteger row index.
search_radiusThe radius of the search window in pixels.
HilltopsLSDRaster of the hilltops to be snapped to. @ return The nodeindex of the snapped point.
Author
SWDG
Date
23/1/17
void LSDFlowInfo::snap_to_hilltops ( vector< float >  x_locs,
vector< float >  y_locs,
int  search_radius,
LSDRaster Hilltops,
vector< int > &  SnappedNodes,
vector< int > &  Valid_node_IDs 
)

Wrapper around snap_to_hilltop function to process a collection of utm points.

Writes the the nodeindex of each snapped point to SnappedNodes and the coordinate count (first coordinate pair is 0, second is 1 and so on) is written to Valid_node_IDs.

Parameters
x_locsUTM x coordinates.
y_locsUTM y coordinates.
search_radiusThe radius of the search window in pixels.
HilltopsLSDRaster of the hilltops to be snapped to.
SnappedNodesEmpty vector where the snapped nodeindexes are written.
Valid_node_IDsEmpty vector where the coordinate count is written.
Author
SWDG
Date
23/1/17
vector< int > LSDFlowInfo::sort_node_list_based_on_raster ( vector< int >  node_vec,
LSDRaster SortingRaster 
)

This takes a list of nodes and sorts them according to a sorting raster (it could be anything) fin ascending order nodes are then reordered to reflect the sorting of the raster.

Parameters
node_vecA vector of nodes
SortingRastera raster that contains some values that will be used to sort the nodes.
Returns
sorted_nodes a vector containing the sorted nodes
Author
SMM
Date
20/05/2016
vector< int > LSDFlowInfo::sort_node_list_based_on_raster ( vector< int >  node_vec,
LSDIndexRaster SortingRaster 
)

This takes a list of nodes and sorts them according to a sorting raster (it could be anything) fin ascending order nodes are then reordered to reflect the sorting of the raster.

Parameters
node_vecA vector of nodes
SortingRastera raster that contains some values that will be used to sort the nodes.
Returns
sorted_nodes a vector containing the sorted nodes
Author
SMM
Date
20/05/2016
void LSDFlowInfo::unpickle ( string  filename)

Unpickles flow information data from a binary file.

Parameters
filenameString of the binary file to be read.
Author
SMM
Date
01/016/12
LSDRaster LSDFlowInfo::upslope_variable_accumulator ( LSDRaster accum_raster)

This function accumulates some variable from an LSDRaster The most probably use is to accumulate precipitation in order to get a discharge raster.

Parameters
Araster that contains the variable to be accumulated (e.g., precipitation)
Returns
A raster containing the accumulated variable: NOTE the accumulation does not include the node itself
Author
SMM
Date
09/06/2014
LSDRaster LSDFlowInfo::write_DrainageArea_to_LSDRaster ( )
Returns
Author
Fiona Clubb
Date
15/11/12
LSDIndexRaster LSDFlowInfo::write_FlowDirection_to_LSDIndexRaster ( )

Write FlowDirection to an LSDIndexRaster.

Returns
LSDIndexRaster of flow directions.
Author
SMM
Date
01/016/12
LSDIndexRaster LSDFlowInfo::write_FlowDirection_to_LSDIndexRaster_Arcformat ( )

Writes flow directions to an LSDIndexRaster. Flow direction in arcmap format is:

32 64 128
16 0 1
8 4 2
.

Returns
LSDIndexRaster of flow directions in arcgis format.
Author
SMM
Date
01/016/12
LSDIndexRaster LSDFlowInfo::write_FlowLengthCode_to_LSDIndexRaster ( )

Write FlowLengthCode to an LSDIndexRaster.

Returns
LSDIndexRaster of flow lengths.
Author
SMM
Date
01/016/12
LSDIndexRaster LSDFlowInfo::write_NContributingNodes_to_LSDIndexRaster ( )

Write NContributingNodes to an LSDIndexRaster.

Returns
LSDIndexRaster of number of contributing nodes for each cell.
Author
SMM
Date
01/016/12
LSDIndexRaster LSDFlowInfo::write_NodeIndex_to_LSDIndexRaster ( )

Write NodeIndex to an LSDIndexRaster.

Returns
LSDIndexRaster of node index data.
Author
SMM
Date
01/016/12
LSDIndexRaster LSDFlowInfo::write_NodeIndexVector_to_LSDIndexRaster ( vector< int > &  nodeindexvec)

This function writes and LSDIndexRaster containing the location of nodes in the nodeindexvector.

Parameters
nodeindexveca vector containing node indices one use is to export the LSDIndexRaster of pixels that are in the node index vector.
Returns
LSDIndexRaster of pixels that are in the node index vector.
Author
SMM
Date
01/016/12
LSDIndexRaster LSDFlowInfo::write_NodeIndexVector_to_LSDIndexRaster_Unique ( vector< int > &  nodeindexvec)

This function writes an LSDIndesxRaster given a list of node indices, and give every pixel its nodeindex value, which is unique.

Parameters
nodeindexveca vector containing node indices one use is to export the LSDIndexRaster of pixels that are in the node index vector.
Returns
LSDIndexRaster of pixels that are in the node index vector.
Author
SWDG after SMM
Date
2/2/16

Member Data Documentation

vector<string> LSDFlowInfo::BoundaryConditions
protected

Boundary conditions stored in a vector of four strings. The conditions are North[0] East[1] South[2] West[3].

There are 3 kinds of edge boundaries: no flux, base level and periodic.

The strings can be any length, as long as the first letter corresponds to the first letter of the boundary condition. It is not case sensitive.

vector<int> LSDFlowInfo::DonorStackVector
protected

This is a vector that stores the donor nodes of of the nodes and is indexed by the DeltaVector.

Array2D<int> LSDFlowInfo::FlowDirection
protected

A raster of flow direction information.

In the format:

7 0 1
6 -1 2
5 4 3
Nodes with flow direction of -1 drain to themselvs and are base level/sink nodes.


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