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 ¤t_X, float ¤t_Y) |
Get the X and Y coordinates of a given node. More... | |
void | get_lat_and_long_from_current_node (int current_node, double ¤t_lat, double ¤t_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. | |
Object to perform flow routing.
|
inline |
The create function. This is default and throws an error.
|
inline |
Creates a FlowInfo object from a binary flowinfo data.
fname | String of the binary flowinfo data file to be read. |
|
inline |
Creates a FlowInfo object from a binary flowinfo data. This assumes no flux boundaries.
TopoRaster | LSDRaster object containing the topographic data. |
|
inline |
Creates a FlowInfo object from topography.
BoundaryConditions | Vector<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 |
TopoRaster | LSDRaster object containing the topographic data. |
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.
lm_index | Integer |
j_index | Integer |
bl_node | Integer |
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.
outlet | node The node of the outlet |
Topography | this is the LSDRaster containing topographic data |
calculates the slope measured in the d8 flow direction base level nodes have slope of 0; slope is measured from node to receiver
the | elevation raster |
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.
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.
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
X_coordinate | the x location of the point |
Y_coordinate | the y location of the point |
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.
i | Row index of starting point for trace. |
j | Column index of starting point for trace. |
StreamNetwork | An LSDIndexRaster of the stream network. |
length | Length of trace in spatial units. |
receiver_row | Row index of ending point for trace. |
receiver_col | Column index of ending point for trace. |
Path | Empty raster to store the final trace path. |
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.
column_name | a string that holds the column name |
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.
column_name | a string that holds the column name |
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.
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.
Bordered_mask | and LSDIndexRaster that is created by the function find_cells_bordered_by_nodata() in LSDRaster |
Topography | this is the LSDRaster containing topographic data |
int LSDFlowInfo::find_farthest_upslope_node | ( | int | node, |
LSDRaster & | DistFromOutlet | ||
) |
This returns the node index of the pixel farthest upslope from the input node.
node | the node from which you want to find the farthest upslope pixel. |
DistFromOutlet | an LSDRaster containing the distance from the outlet. |
|
inline |
vector< string > LSDFlowInfo::get_data_column | ( | string | column_name, |
map< string, vector< string > > | data_map | ||
) |
This gets a data column from the csv file.
column_name | a string that holds the column name |
|
inline |
vector< int > LSDFlowInfo::get_donor_nodes | ( | int | node | ) |
this function gets a list of the node indices of the donors to a particular node
node | this is the nodeindex of the node for which you want to find the donors |
|
inline |
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.
source_node | The starting node |
outlet_node | A 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_visit | the 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 |
float LSDFlowInfo::get_DrainageArea_square_km | ( | int | this_node | ) |
returns the draiange area of a node in square km
this_node | node of interest |
float LSDFlowInfo::get_DrainageArea_square_m | ( | int | this_node | ) |
returns the draiange area of a node in square m
this_node | node of interest |
float LSDFlowInfo::get_Euclidian_distance | ( | int | node_A, |
int | node_B | ||
) |
This function gets the Euclidian distance between two nodes.
node_A | the first node |
node_B | the second node |
float LSDFlowInfo::get_flow_length_between_nodes | ( | int | UpstreamNode, |
int | DownstreamNode | ||
) |
This function gets the flow distance between two nodes.
UpstreamNode | the upstream node |
Downstreamnode | the downstream node |
|
inline |
|
inline |
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.
current_node | Integer index of a given node. |
current_lat | latitude. Will be replaced by function |
current_long | longitude. Will be replaced by function |
Converter | A coordinate converter object |
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
row | the row of the node |
col | the col of the node |
lat | the 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) |
long | the 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) |
Converter | a converter object (from LSDShapeTools) |
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
X | the Easting of the location |
Y | the Northing of the location |
lat | the 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) |
long | the 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) |
Converter | a converter object (from LSDShapeTools) |
|
inline |
Get the FlowDirection of a row and column pair.
row | Integer of row index. |
col | Integer of col index. |
|
inline |
|
inline |
|
inline |
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.
X_coordinate | X_coord of point |
Y_coordinate | Y_coord of point |
int LSDFlowInfo::get_NodeIndex_from_row_col | ( | int | row, |
int | col | ||
) |
Get the index from row/col.
int | row/col of the nodeindex 2DArray |
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.
csv_filename | input csv file |
|
inline |
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.
An | LSDRaster - 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.
upslope_node | the upstream node |
downslope_node | the downstream node |
Elevation | elevation raster |
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.
X_coords | X coordinates of channel heads |
Y_coords | Y coordinates of channel heads |
vector< int > LSDFlowInfo::get_sources_index_threshold | ( | LSDIndexRaster & | FlowPixels, |
int | threshold | ||
) |
A get sources version that uses the flow accumulation pixels.
FlowPixels | LSDIndexRaster of flow accumulation in pixels. |
threshold | Integer flow accumulation threshold. |
vector< int > LSDFlowInfo::get_sources_slope_area | ( | LSDIndexRaster & | FlowPixels, |
LSDRaster & | Slope, | ||
int | threshold | ||
) |
A get sources version that uses AS^2 (area and slope).
FlowPixels | LSDIndexRaster of flow accumulation in pixels. |
Slope | LSDRaster of slope values |
threshold | Integer AS^2 threshold |
|
inline |
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.
starting_node | Integer index of node to analyse upslope of. |
m_over_n | |
A_0 |
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.
starting_node | Integer index of node to analyse upslope of. |
m_over_n | |
A_0 | the referecen discharge |
Discharge | a raster of the discharge |
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.
upslope_pixel_list | Vector of nodes to analyse. |
m_over_n | |
A_0 |
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.
upslope_pixel_list | Vector of nodes to analyse. |
m_over_n | |
A_0 | |
Discharge | and LSDRaster of the discharge |
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.
m_over_n | the m/n ratio. Chi is quite sensitive to this |
A_0 | the 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_threshold | the threshold area (in m^2) that sets the area above which chi is recorded in the chi raster |
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.
m_over_n | the m/n ratio. Chi is quite sensitive to this |
A_0 | the reference discharge (same units as discharge. As of 28 July 2014 we've not done any detailed sensitivity analysis on this parameter |
area_threshold | the threshold area (in m^2) that sets the area above which chi is recorded in the chi raster |
Discharge | a raster of the discharge |
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
starting_nodes | an 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_n | the m/n ratio. Chi is quite sensitive to this |
A_0 | the 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_threshold | the threshold area (in m^2) that sets the area above which chi is recorded in the chi raster |
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
starting_nodes | an 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_n | the m/n ratio. Chi is quite sensitive to this |
A_0 | the reference discharge. This is arbitrary. As of 28 July 2014 we've not done any detailed sensitivity analysis on this parameter |
area_threshold | the threshold area (in m^2) that sets the area above which chi is recorded in the chi raster |
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.
starting_nodes | an integer containing the node index of the node from which you want to start the chi analysis. |
m_over_n | the m/n ratio. Chi is quite sensitive to this |
A_0 | the reference discharge. |
mimum_pixels | This minimum number of contributing pixels needed before chi is calculated |
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
starting_nodes | an integer containing the node index of the node from which you want to start the chi analysis. |
m_over_n | the m/n ratio. Chi is quite sensitive to this |
A_0 | the reference discharge. |
mimum_pixels | This minimum number of contributing pixels needed before chi is calculated |
Discharge | The discharge raster |
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.
upslope_pixel_list | Vector of nodes to analyse. |
m_over_n | |
A_0 | |
mimum_pixels | This minimum number of contributing pixels needed before chi is calculated |
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.
upslope_pixel_list | Vector of nodes to analyse. |
m_over_n | |
A_0 | |
mimum_pixels | This minimum number of contributing pixels needed before chi is calculated |
Discharge | and LSDRaster of the discharge |
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.
source_nodes | a vector of node indicies into the sources |
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.
source_nodes | a vector of node indicies into the sources |
node_values | a vector of the value of the nodes upslope of the sources this vector needs to be the same size as the source_nodes vector |
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.
node_number_outlet | Integer of the target node. |
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
UTM_zone | the UTM zone. Replaced in function. |
is_North | a boolean that is true if the DEM is in the northern hemisphere. replaced in function |
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.
current_node | Integer index of a given node. |
current_X | Empty integer to be assigned the X coordinate of the given node. |
current_Y | Empty integer to be assigned the Y coordinate of the given node. |
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
row | the row of the node |
col | the column of the node |
x_loc | the x location (Northing) of the node |
y_loc | the y location (Easting) of the node |
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
row | the row of the node |
col | the column of the node |
x_loc | the x location (Northing) of the node |
y_loc | the y location (Easting) of the node |
|
inline |
|
inline |
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
Elevation | LSDRaster of elevation values. |
Slope | LSDRaster of slope values. |
Hilltops | LSDRaster of hilltops. |
StreamNetwork | LSDIndexRaster of the stream network. |
Aspect | LSDRaster of Aspect. |
Prefix | String Prefix for output data filename. |
Basins | LSDIndexRaster of basin outlines. |
PlanCurvature | LSDRaster of planform curvature. |
print_paths_switch | If true paths will be printed. |
thinning | Thinning factor, value used to skip hilltops being printed, use 1 to print every hilltop. |
trace_path | The file path to be used to write the path files to, must end with a slash. |
basin_filter_switch | If this switch is true only basins in Target_Basin_Vector will have their paths printed. |
Target_Basin_Vector | Vector of Basin IDs that the user wants to print traces for. |
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
Elevation | LSDRaster of elevation values. |
Slope | LSDRaster of slope values. |
Hilltops | LSDRaster of hilltops. |
StreamNetwork | LSDIndexRaster of the stream network. |
D_inf_Flowdir | LSDRaster of flow directions. |
Prefix | String Prefix for output data filename. |
Basins | LSDIndexRaster of basin outlines. |
print_paths_switch | If true paths will be printed. |
thinning | Thinning factor, value used to skip hilltops being printed, use 1 to print every hilltop. |
trace_path | The file path to be used to write the path files to, must end with a slash. |
basin_filter_switch | If this switch is true only basins in Target_Basin_Vector will have their paths printed. |
Target_Basin_Vector | Vector of Basin IDs that the user wants to print traces for. |
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
Elevation | LSDRaster of elevation values. |
Slope | LSDRaster of slope values. |
Hilltops | LSDRaster of hilltops. |
StreamNetwork | LSDIndexRaster of the stream network. |
D_inf_Flowdir | LSDRaster of flow directions. |
Prefix | String Prefix for output data filename. |
Basins | LSDIndexRaster of basin outlines. |
PlanCurvature | LSDRaster of planform curvature. |
print_paths_switch | If true paths will be printed. |
thinning | Thinning factor, value used to skip hilltops being printed, use 1 to print every hilltop. |
trace_path | The file path to be used to write the path files to, must end with a slash. |
basin_filter_switch | If this switch is true only basins in Target_Basin_Vector will have their paths printed. |
Target_Basin_Vector | Vector of Basin IDs that the user wants to print traces for. |
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.
filename | of the channel heads raster. |
extension | of 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 |
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.
filename | of the channel heads raster. |
extension | of 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 |
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.
csv_filename | CSV file name |
int LSDFlowInfo::is_node_base_level | ( | int | node | ) |
This function tests whether a node is a base level node.
node |
int LSDFlowInfo::is_node_upstream | ( | int | current_node, |
int | test_node | ||
) |
This function tests whether one node is upstream of another node.
current_node | |
test_node |
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.
nodeindex | The node index of the node in question |
test_raster | and LSDRaster that is to be tested |
map< string, vector< string > > LSDFlowInfo::load_csv_data | ( | string | filename | ) |
This loads a csv file, putting the data into a data map.
filename | The name of the csv file including path and extension |
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.
Sources | a vector of node indexes of the channel heads to be moved. |
MoveDist | The distance in spatial units the head is to be moved. |
DownslopeSources | A vector used to contain the node indexes of the moved channel heads. |
FinalHeads | A vector containing a subset of the original channel heads which corresponds to the moved heads. |
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.
Sources | a vector of node indexes of the channel heads to be moved. |
MoveDist | The distance in spatial units the head is to be moved. |
DEM | the elevation data. |
UpslopeSources | A vector used to contain the node indexes of the moved channel heads. |
FinalHeads | A vector containing a subset of the original channel heads which corresponds to the moved heads. |
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
filename | String of the binary file to be written. |
void LSDFlowInfo::print_flow_info_vectors | ( | string | filename | ) |
Prints the flow information to file.
filename | String of the output file to be written. |
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.
nodeindex | vec is a vector of nodeindices (which are ints) |
outfilename | is a string of the filename |
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.
nodeindex | vec is a vector of nodeindices (which are ints) |
outfilename | is a string of the filename |
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.
nodeindex | vec is a vector of nodeindices (which are ints) |
outfilename | is a string of the filename |
vector< int > LSDFlowInfo::ProcessEndPointsToChannelHeads | ( | LSDIndexRaster | Ends | ) |
This method removes end nodes which are not the uppermost extent of the channel network.
Ends | an LSDIndexRaster of the end points to be processed. |
vector< int > LSDFlowInfo::RemoveSinglePxChannels | ( | LSDIndexRaster | StreamNetwork, |
vector< int > | Sources | ||
) |
This method removes single pixel channels from a channel network.
StreamNetwork | an LSDIndexRaster of the channel network generated from Sources. |
Sources | a vetcor of integer node indices which need cleaned |
int LSDFlowInfo::retrieve_base_level_node | ( | int | node | ) |
This gets the base level node for any given node.
node | the starting node |
|
inline |
Get the number of pixels flowing into a node.
node | Integer of node index value. |
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.
current_node | Integer index of a given node. |
curr_row | Empty integer to be assigned the row index of the given node. |
curr_col | Empty integer to be assigned the column index of the given node. |
vector< int > LSDFlowInfo::retrieve_donors_to_node | ( | int | current_node | ) |
gets a vector of all the donors to a given node
current_node | the node index from which to get n donors |
|
inline |
Get the FlowLengthCode of a given node.
node | Integer of node index value. |
int LSDFlowInfo::retrieve_largest_base_level | ( | ) |
This function returns the base level node with the greatest drainage area.
|
inline |
get the number of donors to a given node
current_node | the node index from which to get n donors |
int LSDFlowInfo::retrieve_node_from_row_and_column | ( | int | row, |
int | column | ||
) |
Get the node for a cell at a given row and column.
row | index |
column | index |
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.
current_node | Integer |
reveiver_node | Empty integer to be assigned the index of the reciever node. |
receiver_row | Empty integer to be assigned the row index of the reciever node. |
receiver_col | Empty integer to be assigned the column index of the reciever node. |
void LSDFlowInfo::retrieve_receiver_information | ( | int | current_node, |
int & | reveiver_node | ||
) |
Gives the reciever information for a given node.
current_node | Integer |
reveiver_node | Empty integer to be assigned the index of the reciever node. |
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.
NodeIndex | of interest |
InputRaster | raster to return value of |
search_radius | rectangular window to search for, in n_pixels |
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.
a | Integer row index. |
b | Integer row index. |
search_radius | The radius of the search window in pixels. |
Hilltops | LSDRaster of the hilltops to be snapped to. @ return The nodeindex of the snapped point. |
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.
x_locs | UTM x coordinates. |
y_locs | UTM y coordinates. |
search_radius | The radius of the search window in pixels. |
Hilltops | LSDRaster of the hilltops to be snapped to. |
SnappedNodes | Empty vector where the snapped nodeindexes are written. |
Valid_node_IDs | Empty vector where the coordinate count is written. |
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.
node_vec | A vector of nodes |
SortingRaster | a raster that contains some values that will be used to sort the nodes. |
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.
node_vec | A vector of nodes |
SortingRaster | a raster that contains some values that will be used to sort the nodes. |
void LSDFlowInfo::unpickle | ( | string | filename | ) |
Unpickles flow information data from a binary file.
filename | String of the binary file to be read. |
This function accumulates some variable from an LSDRaster The most probably use is to accumulate precipitation in order to get a discharge raster.
A | raster that contains the variable to be accumulated (e.g., precipitation) |
LSDRaster LSDFlowInfo::write_DrainageArea_to_LSDRaster | ( | ) |
LSDIndexRaster LSDFlowInfo::write_FlowDirection_to_LSDIndexRaster | ( | ) |
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
.
LSDIndexRaster LSDFlowInfo::write_FlowLengthCode_to_LSDIndexRaster | ( | ) |
LSDIndexRaster LSDFlowInfo::write_NContributingNodes_to_LSDIndexRaster | ( | ) |
Write NContributingNodes to an LSDIndexRaster.
LSDIndexRaster LSDFlowInfo::write_NodeIndex_to_LSDIndexRaster | ( | ) |
LSDIndexRaster LSDFlowInfo::write_NodeIndexVector_to_LSDIndexRaster | ( | vector< int > & | nodeindexvec | ) |
This function writes and LSDIndexRaster containing the location of nodes in the nodeindexvector.
nodeindexvec | a vector containing node indices one use is to export the LSDIndexRaster of pixels that are in the node index vector. |
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.
nodeindexvec | a vector containing node indices one use is to export the LSDIndexRaster of pixels that are in the node index vector. |
|
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.
|
protected |
This is a vector that stores the donor nodes of of the nodes and is indexed by the DeltaVector.
|
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.