本文整理汇总了C++中LSDRaster::D_inf_FlowDir方法的典型用法代码示例。如果您正苦于以下问题:C++ LSDRaster::D_inf_FlowDir方法的具体用法?C++ LSDRaster::D_inf_FlowDir怎么用?C++ LSDRaster::D_inf_FlowDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LSDRaster
的用法示例。
在下文中一共展示了LSDRaster::D_inf_FlowDir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int nNumberofArgs,char *argv[])
{
//Test for correct input arguments
if (nNumberofArgs!=7)
{
cout << "FATAL ERROR: wrong number of inputs. The program needs the path (with trailing slash), the filename prefix, window radius, ";
cout << "basin order, a switch to use or exclude floodplains and a switch to write rasters if desired." << endl;
exit(EXIT_SUCCESS);
}
//load input arguments
string path = argv[1];
string filename = argv[2];
float window_radius = atof(argv[3]); //6
int BasinOrder = atoi(argv[4]); //2
int FloodplainSwitch = atoi(argv[5]);
int WriteRasters = atoi(argv[6]); //0 (do not write rasters) or 1 (write rasters)
//set boundary conditions
vector<string> BoundaryConditions(4, "No Flux");
//load dem
LSDRaster DEM((path+filename+"_dem"), "flt");
//Fill
float MinSlope = 0.0001;
LSDRaster FilledDEM = DEM.fill(MinSlope);
//surface fitting
vector<int> raster_selection;
raster_selection.push_back(0);
raster_selection.push_back(1); //slope
raster_selection.push_back(1); //aspect
raster_selection.push_back(1); //curvature
raster_selection.push_back(1); //plan curvature
raster_selection.push_back(0);
raster_selection.push_back(0);
raster_selection.push_back(0);
vector<LSDRaster> Surfaces = FilledDEM.calculate_polyfit_surface_metrics(window_radius, raster_selection);
LSDRaster slope = Surfaces[1];
LSDRaster aspect = Surfaces[2];
cout << "\nGetting drainage network and basins\n" << endl;
// get a flow info object
LSDFlowInfo FlowInfo(BoundaryConditions,FilledDEM);
//get stream net from channel heads
vector<int> sources = FlowInfo.Ingest_Channel_Heads((path+filename+"_dem_CH"), "flt"); //swap to csv?
LSDJunctionNetwork ChanNetwork(sources, FlowInfo);
LSDIndexRaster StreamNetwork = ChanNetwork.StreamOrderArray_to_LSDIndexRaster();
//load floodplain and merge with the channel network if required, otherwise the
//floodplain mask will only contain the channel data
LSDIndexRaster ChannelAndFloodplain;
if (FloodplainSwitch == 1){
LSDIndexRaster Floodplains((path+filename+"_FloodPlain"), "flt");
ChannelAndFloodplain = StreamNetwork.MergeChannelWithFloodplain(Floodplains);
}
else{
ChannelAndFloodplain = StreamNetwork;
}
//Extract basins based on input stream order
vector< int > basin_junctions = ChanNetwork.ExtractBasinJunctionOrder(BasinOrder, FlowInfo);
LSDIndexRaster Basin_Raster = ChanNetwork.extract_basins_from_junction_vector(basin_junctions, FlowInfo);
cout << "\nExtracting hilltops and hilltop curvature" << endl;
// extract hilltops - no critical slope filtering is performed here
LSDRaster hilltops = ChanNetwork.ExtractRidges(FlowInfo);
//get hilltop curvature using filter to remove positive curvatures
LSDRaster cht_raster = FilledDEM.get_hilltop_curvature(Surfaces[3], hilltops);
LSDRaster CHT = FilledDEM.remove_positive_hilltop_curvature(cht_raster);
//get d infinity flowdirection and flow area
Array2D<float> dinf = FilledDEM.D_inf_FlowDir();
LSDRaster dinf_rast = FilledDEM.LSDRasterTemplate(dinf);
LSDRaster DinfArea = FilledDEM.D_inf_units();
cout << "Starting hilltop flow routing\n" << endl;
//start of Hilltop flow routing
string prefix = (path+filename+"_dreich_"); //set a path to write the hillslope length data to, based on the input path and filename given by the user
// these params do not need changed during normal use of the HFR algorithm
bool print_paths_switch = false;
int thinning = 1;
string trace_path = "";
bool basin_filter_switch = false;
vector<int> Target_Basin_Vector;
//run HFR
vector< Array2D<float> > HFR_Arrays = FlowInfo.HilltopFlowRouting(FilledDEM, hilltops, slope, ChannelAndFloodplain, aspect, prefix, Basin_Raster, Surfaces[4], print_paths_switch, thinning, trace_path, basin_filter_switch, Target_Basin_Vector);
//.........这里部分代码省略.........