Skip to content

Commit 3b0a861

Browse files
committed
Option to crop interest zone and filter min dbh trees
1 parent 9f696d0 commit 3b0a861

File tree

5 files changed

+422
-128
lines changed

5 files changed

+422
-128
lines changed

raycloudtools/rayextract/rayextract.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ void usage(int exit_code = 1)
5555
std::cout << " --crop_length 1.0 - (-p) crops small branches to this distance from end" << std::endl;
5656
std::cout << " --distance_limit 1 - (-d) maximum distance between neighbour points in a tree" << std::endl;
5757
std::cout << " --height_min 2 - (-h) minimum height counted as a tree" << std::endl;
58+
std::cout << " --min_radius 0.01 - (-r) minimum tree radius to consider" << std::endl;
5859
std::cout << " --girth_height_ratio 0.12 - (-i) the amount up tree's height to estimate trunk girth" << std::endl;
5960
std::cout << " --global_taper 0.024 - (-a) force a taper value (diameter per length) for trees under global_taper_factor of max tree height. Use 0 to estimate global taper from the data" << std::endl;
6061
std::cout << " --global_taper_factor 0.3- (-o) 1 estimates same taper for whole scan, 0 is per-tree tapering. Like a soft cutoff at this amount of max tree height" << std::endl;
6162
std::cout << " --gravity_factor 0.3 - (-f) larger values preference vertical trees" << std::endl;
6263
std::cout << " --branch_segmentation- (-b) _segmented.ply is per branch segment" << std::endl;
6364
std::cout << " --grid_width 10 - (-w) crops results assuming cloud has been gridded with given width" << std::endl;
65+
std::cout << " --grid_origin 0,0,0 - location of origin within grid cell that overlaps it. Defaults to a cell-centre origin (at grid_width/2 in each axis) matching raysplit grid. 0,0,0 is for a vertex origin." << std::endl;
6466
std::cout << " --use_rays - (-u) use rays to reduce trunk radius overestimation in noisy cloud data" << std::endl;
6567
std::cout << " (for internal constants -c -g -s see source file rayextract)" << std::endl;
6668
// These are the internal parameters that I don't expose as they are 'advanced' only, you shouldn't need to adjust them
@@ -92,6 +94,9 @@ int rayExtract(int argc, char *argv[])
9294
}
9395
ray::FileArgument cloud_file, mesh_file, trunks_file, trees_file, leaf_file;
9496
ray::TextArgument forest("forest"), trees("trees"), trunks("trunks"), terrain("terrain"), leaves("leaves");
97+
98+
ray::Vector3dArgument grid_origin;
99+
ray::OptionalKeyValueArgument grid_origin_option("grid_origin", &grid_origin);
95100
ray::OptionalKeyValueArgument groundmesh_option("ground", 'g', &mesh_file);
96101
ray::OptionalKeyValueArgument trunks_option("trunks", 't', &trunks_file);
97102
ray::DoubleArgument gradient(0.001, 1000.0, 1.0), global_taper(0.0, 1.0), global_taper_factor(0.0, 1.0);
@@ -102,7 +107,7 @@ int rayExtract(int argc, char *argv[])
102107
ray::DoubleArgument max_diameter(0.01, 100.0), distance_limit(0.01, 10.0), height_min(0.01, 1000.0),
103108
min_diameter(0.01, 100.0), leaf_area(0.00001, 1.0, 0.002), leaf_droop(0.0, 10.0, 0.1), crop_length(0.01, 100.0);;
104109
ray::DoubleArgument girth_height_ratio(0.001, 0.5), length_to_radius(0.01, 10000.0), cylinder_length_to_width(0.1, 20.0), gap_ratio(0.01, 10.0),
105-
span_ratio(0.01, 10.0);
110+
span_ratio(0.01, 10.0), min_radius(0.01, 100.0);
106111
ray::DoubleArgument gravity_factor(0.0, 100.0), grid_width(1.0, 100000.0),
107112
grid_overlap(0.0, 0.9);
108113
ray::OptionalKeyValueArgument max_diameter_option("max_diameter", 'm', &max_diameter);
@@ -112,6 +117,8 @@ int rayExtract(int argc, char *argv[])
112117
ray::OptionalKeyValueArgument girth_height_ratio_option("girth_height_ratio", 'i', &girth_height_ratio);
113118
ray::OptionalKeyValueArgument cylinder_length_to_width_option("cylinder_length_to_width", 'c',
114119
&cylinder_length_to_width);
120+
121+
ray::OptionalKeyValueArgument min_radius_option("min_radius", 'r', &min_radius);
115122
ray::OptionalKeyValueArgument gap_ratio_option("gap_ratio", 'g', &gap_ratio);
116123
ray::OptionalKeyValueArgument span_ratio_option("span_ratio", 's', &span_ratio);
117124
ray::OptionalKeyValueArgument gravity_factor_option("gravity_factor", 'f', &gravity_factor);
@@ -137,7 +144,8 @@ int rayExtract(int argc, char *argv[])
137144
argc, argv, { &trees, &cloud_file, &mesh_file },
138145
{ &max_diameter_option, &distance_limit_option, &height_min_option, &crop_length_option, &girth_height_ratio_option,
139146
&cylinder_length_to_width_option, &gap_ratio_option, &span_ratio_option, &gravity_factor_option,
140-
&segment_branches, &grid_width_option, &global_taper_option, &global_taper_factor_option, &use_rays, &verbose });
147+
&segment_branches, &grid_width_option, &global_taper_option, &global_taper_factor_option, &use_rays, &verbose,
148+
&grid_origin_option, &min_radius_option });
141149
bool extract_leaves = ray::parseCommandLine(argc, argv, { &leaves, &cloud_file, &trees_file }, { &leaf_option, &leaf_area_option, &leaf_droop_option, &stalks });
142150

143151

@@ -226,8 +234,16 @@ int rayExtract(int argc, char *argv[])
226234
if (global_taper_factor_option.isSet())
227235
{
228236
params.global_taper_factor = global_taper_factor.value();
229-
}
230-
params.use_rays = use_rays.isSet();
237+
}
238+
if (grid_origin_option.isSet())
239+
{
240+
params.grid_origin = grid_origin.value();
241+
}
242+
if (min_radius_option.isSet())
243+
{
244+
params.min_radius = min_radius.value();
245+
}
246+
params.use_rays = use_rays.isSet();
231247
params.segment_branches = segment_branches.isSet();
232248

233249
ray::Trees trees(cloud, offset, mesh, params, verbose.isSet());

0 commit comments

Comments
 (0)