BERATools 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- beratools/__init__.py +1 -7
- beratools/core/algo_centerline.py +491 -351
- beratools/core/algo_common.py +497 -0
- beratools/core/algo_cost.py +192 -0
- beratools/core/{dijkstra_algorithm.py → algo_dijkstra.py} +503 -460
- beratools/core/algo_footprint_rel.py +577 -0
- beratools/core/algo_line_grouping.py +944 -0
- beratools/core/algo_merge_lines.py +214 -0
- beratools/core/algo_split_with_lines.py +304 -0
- beratools/core/algo_tiler.py +428 -0
- beratools/core/algo_vertex_optimization.py +469 -0
- beratools/core/constants.py +52 -86
- beratools/core/logger.py +76 -85
- beratools/core/tool_base.py +196 -133
- beratools/gui/__init__.py +11 -15
- beratools/gui/{beratools.json → assets/beratools.json} +2185 -2300
- beratools/gui/batch_processing_dlg.py +513 -463
- beratools/gui/bt_data.py +481 -487
- beratools/gui/bt_gui_main.py +710 -691
- beratools/gui/main.py +26 -0
- beratools/gui/map_window.py +162 -146
- beratools/gui/tool_widgets.py +725 -493
- beratools/tools/Beratools_r_script.r +1120 -1120
- beratools/tools/Ht_metrics.py +116 -116
- beratools/tools/__init__.py +7 -7
- beratools/tools/batch_processing.py +136 -132
- beratools/tools/canopy_threshold_relative.py +672 -670
- beratools/tools/canopycostraster.py +222 -222
- beratools/tools/centerline.py +136 -176
- beratools/tools/common.py +857 -885
- beratools/tools/fl_regen_csf.py +428 -428
- beratools/tools/forest_line_attributes.py +408 -408
- beratools/tools/line_footprint_absolute.py +213 -363
- beratools/tools/line_footprint_fixed.py +436 -282
- beratools/tools/line_footprint_functions.py +733 -720
- beratools/tools/line_footprint_relative.py +73 -64
- beratools/tools/line_grouping.py +45 -0
- beratools/tools/ln_relative_metrics.py +615 -615
- beratools/tools/r_cal_lpi_elai.r +24 -24
- beratools/tools/r_generate_pd_focalraster.r +100 -100
- beratools/tools/r_interface.py +79 -79
- beratools/tools/r_point_density.r +8 -8
- beratools/tools/rpy_chm2trees.py +86 -86
- beratools/tools/rpy_dsm_chm_by.py +81 -81
- beratools/tools/rpy_dtm_by.py +63 -63
- beratools/tools/rpy_find_cellsize.py +43 -43
- beratools/tools/rpy_gnd_csf.py +74 -74
- beratools/tools/rpy_hummock_hollow.py +85 -85
- beratools/tools/rpy_hummock_hollow_raster.py +71 -71
- beratools/tools/rpy_las_info.py +51 -51
- beratools/tools/rpy_laz2las.py +40 -40
- beratools/tools/rpy_lpi_elai_lascat.py +466 -466
- beratools/tools/rpy_normalized_lidar_by.py +56 -56
- beratools/tools/rpy_percent_above_dbh.py +80 -80
- beratools/tools/rpy_points2trees.py +88 -88
- beratools/tools/rpy_vegcoverage.py +94 -94
- beratools/tools/tiler.py +48 -206
- beratools/tools/tool_template.py +69 -54
- beratools/tools/vertex_optimization.py +61 -620
- beratools/tools/zonal_threshold.py +144 -144
- beratools-0.2.2.dist-info/METADATA +108 -0
- beratools-0.2.2.dist-info/RECORD +74 -0
- {beratools-0.2.0.dist-info → beratools-0.2.2.dist-info}/WHEEL +1 -1
- {beratools-0.2.0.dist-info → beratools-0.2.2.dist-info}/licenses/LICENSE +22 -22
- beratools/gui/cli.py +0 -18
- beratools/gui/gui.json +0 -8
- beratools/gui_tk/ASCII Banners.txt +0 -248
- beratools/gui_tk/__init__.py +0 -20
- beratools/gui_tk/beratools_main.py +0 -515
- beratools/gui_tk/bt_widgets.py +0 -442
- beratools/gui_tk/cli.py +0 -18
- beratools/gui_tk/img/BERALogo.png +0 -0
- beratools/gui_tk/img/closed.gif +0 -0
- beratools/gui_tk/img/closed.png +0 -0
- beratools/gui_tk/img/open.gif +0 -0
- beratools/gui_tk/img/open.png +0 -0
- beratools/gui_tk/img/tool.gif +0 -0
- beratools/gui_tk/img/tool.png +0 -0
- beratools/gui_tk/main.py +0 -14
- beratools/gui_tk/map_window.py +0 -144
- beratools/gui_tk/runner.py +0 -1481
- beratools/gui_tk/tooltip.py +0 -55
- beratools/third_party/pyqtlet2/__init__.py +0 -9
- beratools/third_party/pyqtlet2/leaflet/__init__.py +0 -26
- beratools/third_party/pyqtlet2/leaflet/control/__init__.py +0 -6
- beratools/third_party/pyqtlet2/leaflet/control/control.py +0 -59
- beratools/third_party/pyqtlet2/leaflet/control/draw.py +0 -52
- beratools/third_party/pyqtlet2/leaflet/control/layers.py +0 -20
- beratools/third_party/pyqtlet2/leaflet/core/Parser.py +0 -24
- beratools/third_party/pyqtlet2/leaflet/core/__init__.py +0 -2
- beratools/third_party/pyqtlet2/leaflet/core/evented.py +0 -180
- beratools/third_party/pyqtlet2/leaflet/layer/__init__.py +0 -5
- beratools/third_party/pyqtlet2/leaflet/layer/featuregroup.py +0 -34
- beratools/third_party/pyqtlet2/leaflet/layer/icon/__init__.py +0 -1
- beratools/third_party/pyqtlet2/leaflet/layer/icon/icon.py +0 -30
- beratools/third_party/pyqtlet2/leaflet/layer/imageoverlay.py +0 -18
- beratools/third_party/pyqtlet2/leaflet/layer/layer.py +0 -105
- beratools/third_party/pyqtlet2/leaflet/layer/layergroup.py +0 -45
- beratools/third_party/pyqtlet2/leaflet/layer/marker/__init__.py +0 -1
- beratools/third_party/pyqtlet2/leaflet/layer/marker/marker.py +0 -91
- beratools/third_party/pyqtlet2/leaflet/layer/tile/__init__.py +0 -2
- beratools/third_party/pyqtlet2/leaflet/layer/tile/gridlayer.py +0 -4
- beratools/third_party/pyqtlet2/leaflet/layer/tile/tilelayer.py +0 -16
- beratools/third_party/pyqtlet2/leaflet/layer/vector/__init__.py +0 -5
- beratools/third_party/pyqtlet2/leaflet/layer/vector/circle.py +0 -15
- beratools/third_party/pyqtlet2/leaflet/layer/vector/circlemarker.py +0 -18
- beratools/third_party/pyqtlet2/leaflet/layer/vector/path.py +0 -5
- beratools/third_party/pyqtlet2/leaflet/layer/vector/polygon.py +0 -14
- beratools/third_party/pyqtlet2/leaflet/layer/vector/polyline.py +0 -18
- beratools/third_party/pyqtlet2/leaflet/layer/vector/rectangle.py +0 -14
- beratools/third_party/pyqtlet2/leaflet/map/__init__.py +0 -1
- beratools/third_party/pyqtlet2/leaflet/map/map.py +0 -220
- beratools/third_party/pyqtlet2/mapwidget.py +0 -45
- beratools/third_party/pyqtlet2/web/custom.js +0 -43
- beratools/third_party/pyqtlet2/web/map.html +0 -23
- beratools/third_party/pyqtlet2/web/modules/leaflet_193/images/layers-2x.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_193/images/layers.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_193/images/marker-icon-2x.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_193/images/marker-icon.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_193/images/marker-shadow.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_193/leaflet.css +0 -656
- beratools/third_party/pyqtlet2/web/modules/leaflet_193/leaflet.js +0 -6
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/.codeclimate.yml +0 -14
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/.editorconfig +0 -4
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/.gitattributes +0 -22
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/.travis.yml +0 -43
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/LICENSE +0 -20
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/images/layers-2x.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/images/layers.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/images/marker-icon-2x.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/images/marker-icon.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/images/marker-shadow.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/images/spritesheet-2x.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/images/spritesheet.png +0 -0
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/images/spritesheet.svg +0 -156
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/leaflet.draw.css +0 -10
- beratools/third_party/pyqtlet2/web/modules/leaflet_draw_414/leaflet.draw.js +0 -10
- beratools/third_party/pyqtlet2/web/modules/leaflet_rotatedMarker_020/LICENSE +0 -22
- beratools/third_party/pyqtlet2/web/modules/leaflet_rotatedMarker_020/leaflet.rotatedMarker.js +0 -57
- beratools/tools/forest_line_ecosite.py +0 -216
- beratools/tools/lapis_all.py +0 -103
- beratools/tools/least_cost_path_from_chm.py +0 -152
- beratools-0.2.0.dist-info/METADATA +0 -63
- beratools-0.2.0.dist-info/RECORD +0 -142
- /beratools/gui/{img → assets}/BERALogo.png +0 -0
- /beratools/gui/{img → assets}/closed.gif +0 -0
- /beratools/gui/{img → assets}/closed.png +0 -0
- /beratools/{gui_tk → gui/assets}/gui.json +0 -0
- /beratools/gui/{img → assets}/open.gif +0 -0
- /beratools/gui/{img → assets}/open.png +0 -0
- /beratools/gui/{img → assets}/tool.gif +0 -0
- /beratools/gui/{img → assets}/tool.png +0 -0
- {beratools-0.2.0.dist-info → beratools-0.2.2.dist-info}/entry_points.txt +0 -0
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
from beratools.tools.common import *
|
|
5
|
-
from beratools.tools.r_interface import *
|
|
6
|
-
|
|
7
|
-
def normalized_lidar(callback, in_las_folder, out_folder, style, processes, verbose):
|
|
8
|
-
rprocesses = r_processes(processes)
|
|
9
|
-
|
|
10
|
-
# assign R script file to local variable
|
|
11
|
-
Beratools_R_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Beratools_r_script.r')
|
|
12
|
-
# Defining the R script and loading the instance in Python
|
|
13
|
-
r['source'](Beratools_R_script)
|
|
14
|
-
# Loading the function defined in R script.
|
|
15
|
-
if style == 'tin':
|
|
16
|
-
r_normalized_lidar = robjects.globalenv['normalized_lidar_knnidw']
|
|
17
|
-
elif style == 'knnidw':
|
|
18
|
-
r_normalized_lidar = robjects.globalenv['normalized_lidar_tin']
|
|
19
|
-
else:
|
|
20
|
-
r_normalized_lidar = robjects.globalenv['normalized_lidar_kriging']
|
|
21
|
-
|
|
22
|
-
# Invoking the R function
|
|
23
|
-
r_normalized_lidar(in_las_folder, out_folder, rprocesses)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if __name__ == '__main__':
|
|
27
|
-
start_time = time.time()
|
|
28
|
-
print('Normalize Lidar data processing\n @ {}'
|
|
29
|
-
.format(time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())))
|
|
30
|
-
|
|
31
|
-
packages = ['lidR', 'rgrass', 'rlas', 'future', 'terra', 'sp']
|
|
32
|
-
check_r_packages_installation(packages)
|
|
33
|
-
|
|
34
|
-
print("Checking input parameters....")
|
|
35
|
-
in_args, in_verbose = check_arguments()
|
|
36
|
-
|
|
37
|
-
if in_args.input["style"] in ["tin", "knnidw", "kriging"]:
|
|
38
|
-
style = in_args.input["style"]
|
|
39
|
-
else:
|
|
40
|
-
print("Warning! invalid alogrithm, default algorthim will be used.")
|
|
41
|
-
in_args.input["style"] = "tin"
|
|
42
|
-
|
|
43
|
-
in_las_folder = in_args.input["in_las_folder"]
|
|
44
|
-
out_folder = in_args.input["out_folder"]
|
|
45
|
-
check_las_files_existence(in_las_folder)
|
|
46
|
-
|
|
47
|
-
if not os.path.exists(out_folder):
|
|
48
|
-
print("Warning! Cannot locate output folder, It will be created.")
|
|
49
|
-
os.makedirs(out_folder)
|
|
50
|
-
|
|
51
|
-
print("Checking input parameters....Done")
|
|
52
|
-
|
|
53
|
-
normalized_lidar(print, **in_args.input, processes=int(in_args.processes), verbose=in_verbose)
|
|
54
|
-
|
|
55
|
-
print('Normalize Lidar data processing is done in {} seconds)'
|
|
56
|
-
.format(round(time.time() - start_time, 5)))
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
from beratools.tools.common import *
|
|
5
|
+
from beratools.tools.r_interface import *
|
|
6
|
+
|
|
7
|
+
def normalized_lidar(callback, in_las_folder, out_folder, style, processes, verbose):
|
|
8
|
+
rprocesses = r_processes(processes)
|
|
9
|
+
|
|
10
|
+
# assign R script file to local variable
|
|
11
|
+
Beratools_R_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Beratools_r_script.r')
|
|
12
|
+
# Defining the R script and loading the instance in Python
|
|
13
|
+
r['source'](Beratools_R_script)
|
|
14
|
+
# Loading the function defined in R script.
|
|
15
|
+
if style == 'tin':
|
|
16
|
+
r_normalized_lidar = robjects.globalenv['normalized_lidar_knnidw']
|
|
17
|
+
elif style == 'knnidw':
|
|
18
|
+
r_normalized_lidar = robjects.globalenv['normalized_lidar_tin']
|
|
19
|
+
else:
|
|
20
|
+
r_normalized_lidar = robjects.globalenv['normalized_lidar_kriging']
|
|
21
|
+
|
|
22
|
+
# Invoking the R function
|
|
23
|
+
r_normalized_lidar(in_las_folder, out_folder, rprocesses)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if __name__ == '__main__':
|
|
27
|
+
start_time = time.time()
|
|
28
|
+
print('Normalize Lidar data processing\n @ {}'
|
|
29
|
+
.format(time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())))
|
|
30
|
+
|
|
31
|
+
packages = ['lidR', 'rgrass', 'rlas', 'future', 'terra', 'sp']
|
|
32
|
+
check_r_packages_installation(packages)
|
|
33
|
+
|
|
34
|
+
print("Checking input parameters....")
|
|
35
|
+
in_args, in_verbose = check_arguments()
|
|
36
|
+
|
|
37
|
+
if in_args.input["style"] in ["tin", "knnidw", "kriging"]:
|
|
38
|
+
style = in_args.input["style"]
|
|
39
|
+
else:
|
|
40
|
+
print("Warning! invalid alogrithm, default algorthim will be used.")
|
|
41
|
+
in_args.input["style"] = "tin"
|
|
42
|
+
|
|
43
|
+
in_las_folder = in_args.input["in_las_folder"]
|
|
44
|
+
out_folder = in_args.input["out_folder"]
|
|
45
|
+
check_las_files_existence(in_las_folder)
|
|
46
|
+
|
|
47
|
+
if not os.path.exists(out_folder):
|
|
48
|
+
print("Warning! Cannot locate output folder, It will be created.")
|
|
49
|
+
os.makedirs(out_folder)
|
|
50
|
+
|
|
51
|
+
print("Checking input parameters....Done")
|
|
52
|
+
|
|
53
|
+
normalized_lidar(print, **in_args.input, processes=int(in_args.processes), verbose=in_verbose)
|
|
54
|
+
|
|
55
|
+
print('Normalize Lidar data processing is done in {} seconds)'
|
|
56
|
+
.format(round(time.time() - start_time, 5)))
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
from beratools.tools.common import *
|
|
5
|
-
from beratools.tools.r_interface import *
|
|
6
|
-
|
|
7
|
-
def percentage_aboveDBH(callback, in_las_folder, is_normalized, out_folder, DBH, cell_size, processes, verbose):
|
|
8
|
-
rprocesses = r_processes(processes)
|
|
9
|
-
|
|
10
|
-
# assign R script file to local variable
|
|
11
|
-
Beratools_R_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Beratools_r_script.r')
|
|
12
|
-
# Defining the R script and loading the instance in Python
|
|
13
|
-
r['source'](Beratools_R_script)
|
|
14
|
-
# Loading the function defined in R script.
|
|
15
|
-
r_percentage_aboveDBH = robjects.globalenv['percentage_aboveDBH']
|
|
16
|
-
# Invoking the R function
|
|
17
|
-
r_percentage_aboveDBH(in_las_folder, is_normalized, out_folder, DBH, cell_size, rprocesses)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if __name__ == '__main__':
|
|
21
|
-
start_time = time.time()
|
|
22
|
-
print('Finding percentage returns above DBH height process\n @ {}'
|
|
23
|
-
.format(time.strftime("%d %b %Y %H:%M:%S", time.localtime())))
|
|
24
|
-
|
|
25
|
-
packages = ['lidR', 'future', 'terra']
|
|
26
|
-
check_r_packages_installation(packages)
|
|
27
|
-
|
|
28
|
-
print("Checking input parameters ...")
|
|
29
|
-
in_args, in_verbose = check_arguments()
|
|
30
|
-
in_las_folder = in_args.input["in_las_folder"]
|
|
31
|
-
|
|
32
|
-
try:
|
|
33
|
-
DBH = float(in_args.input["DBH"])
|
|
34
|
-
if DBH < 0:
|
|
35
|
-
raise ValueError
|
|
36
|
-
else:
|
|
37
|
-
in_args.input["DBH"] = DBH
|
|
38
|
-
except ValueError:
|
|
39
|
-
print("Invalid input of DBH, default value is used")
|
|
40
|
-
in_args.input["DBH"] = 1.3
|
|
41
|
-
|
|
42
|
-
try:
|
|
43
|
-
is_normalized = bool(in_args.input["is_normalized"])
|
|
44
|
-
|
|
45
|
-
except ValueError:
|
|
46
|
-
print("Invalid input of checking normalized data box, normalize data will be carried")
|
|
47
|
-
in_args.input["is_normalized"] = False
|
|
48
|
-
|
|
49
|
-
try:
|
|
50
|
-
cell_size = float(in_args.input["cell_size"])
|
|
51
|
-
in_args.input["cell_size"] = cell_size
|
|
52
|
-
except ValueError:
|
|
53
|
-
print("Invalid input of cell size, default value is used")
|
|
54
|
-
in_args.input["cell_size"] = 5.0
|
|
55
|
-
|
|
56
|
-
out_folder = in_args.input["out_folder"]
|
|
57
|
-
|
|
58
|
-
if not os.path.exists(in_las_folder):
|
|
59
|
-
print("Error! Cannot locate Las folder, please check.")
|
|
60
|
-
exit()
|
|
61
|
-
else:
|
|
62
|
-
found = False
|
|
63
|
-
for files in os.listdir(in_las_folder):
|
|
64
|
-
if files.endswith(".las") or files.endswith(".laz"):
|
|
65
|
-
found = True
|
|
66
|
-
break
|
|
67
|
-
if not found:
|
|
68
|
-
print("Error! Cannot locate input LAS file(s), please check!")
|
|
69
|
-
exit()
|
|
70
|
-
|
|
71
|
-
if not os.path.exists(out_folder):
|
|
72
|
-
print("Warning! Cannot locate output folder, It will be created.")
|
|
73
|
-
os.makedirs(out_folder)
|
|
74
|
-
|
|
75
|
-
print("Checking input parameters ... Done")
|
|
76
|
-
|
|
77
|
-
percentage_aboveDBH(print, **in_args.input, processes=int(in_args.processes), verbose=in_verbose)
|
|
78
|
-
|
|
79
|
-
print('Finding percentage returns above DBH height process is done in {} seconds)'
|
|
80
|
-
.format(round(time.time() - start_time, 5)))
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
from beratools.tools.common import *
|
|
5
|
+
from beratools.tools.r_interface import *
|
|
6
|
+
|
|
7
|
+
def percentage_aboveDBH(callback, in_las_folder, is_normalized, out_folder, DBH, cell_size, processes, verbose):
|
|
8
|
+
rprocesses = r_processes(processes)
|
|
9
|
+
|
|
10
|
+
# assign R script file to local variable
|
|
11
|
+
Beratools_R_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Beratools_r_script.r')
|
|
12
|
+
# Defining the R script and loading the instance in Python
|
|
13
|
+
r['source'](Beratools_R_script)
|
|
14
|
+
# Loading the function defined in R script.
|
|
15
|
+
r_percentage_aboveDBH = robjects.globalenv['percentage_aboveDBH']
|
|
16
|
+
# Invoking the R function
|
|
17
|
+
r_percentage_aboveDBH(in_las_folder, is_normalized, out_folder, DBH, cell_size, rprocesses)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if __name__ == '__main__':
|
|
21
|
+
start_time = time.time()
|
|
22
|
+
print('Finding percentage returns above DBH height process\n @ {}'
|
|
23
|
+
.format(time.strftime("%d %b %Y %H:%M:%S", time.localtime())))
|
|
24
|
+
|
|
25
|
+
packages = ['lidR', 'future', 'terra']
|
|
26
|
+
check_r_packages_installation(packages)
|
|
27
|
+
|
|
28
|
+
print("Checking input parameters ...")
|
|
29
|
+
in_args, in_verbose = check_arguments()
|
|
30
|
+
in_las_folder = in_args.input["in_las_folder"]
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
DBH = float(in_args.input["DBH"])
|
|
34
|
+
if DBH < 0:
|
|
35
|
+
raise ValueError
|
|
36
|
+
else:
|
|
37
|
+
in_args.input["DBH"] = DBH
|
|
38
|
+
except ValueError:
|
|
39
|
+
print("Invalid input of DBH, default value is used")
|
|
40
|
+
in_args.input["DBH"] = 1.3
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
is_normalized = bool(in_args.input["is_normalized"])
|
|
44
|
+
|
|
45
|
+
except ValueError:
|
|
46
|
+
print("Invalid input of checking normalized data box, normalize data will be carried")
|
|
47
|
+
in_args.input["is_normalized"] = False
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
cell_size = float(in_args.input["cell_size"])
|
|
51
|
+
in_args.input["cell_size"] = cell_size
|
|
52
|
+
except ValueError:
|
|
53
|
+
print("Invalid input of cell size, default value is used")
|
|
54
|
+
in_args.input["cell_size"] = 5.0
|
|
55
|
+
|
|
56
|
+
out_folder = in_args.input["out_folder"]
|
|
57
|
+
|
|
58
|
+
if not os.path.exists(in_las_folder):
|
|
59
|
+
print("Error! Cannot locate Las folder, please check.")
|
|
60
|
+
exit()
|
|
61
|
+
else:
|
|
62
|
+
found = False
|
|
63
|
+
for files in os.listdir(in_las_folder):
|
|
64
|
+
if files.endswith(".las") or files.endswith(".laz"):
|
|
65
|
+
found = True
|
|
66
|
+
break
|
|
67
|
+
if not found:
|
|
68
|
+
print("Error! Cannot locate input LAS file(s), please check!")
|
|
69
|
+
exit()
|
|
70
|
+
|
|
71
|
+
if not os.path.exists(out_folder):
|
|
72
|
+
print("Warning! Cannot locate output folder, It will be created.")
|
|
73
|
+
os.makedirs(out_folder)
|
|
74
|
+
|
|
75
|
+
print("Checking input parameters ... Done")
|
|
76
|
+
|
|
77
|
+
percentage_aboveDBH(print, **in_args.input, processes=int(in_args.processes), verbose=in_verbose)
|
|
78
|
+
|
|
79
|
+
print('Finding percentage returns above DBH height process is done in {} seconds)'
|
|
80
|
+
.format(round(time.time() - start_time, 5)))
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
from beratools.tools.common import *
|
|
5
|
-
from beratools.tools.r_interface import *
|
|
6
|
-
|
|
7
|
-
def points2trees(callback, in_las_folder, is_normalized, hmin, cell_size, do_nCHM, out_folder, processes, verbose):
|
|
8
|
-
rprocesses = r_processes(processes)
|
|
9
|
-
|
|
10
|
-
# assign R script file to local variable
|
|
11
|
-
Beratools_R_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Beratools_r_script.r')
|
|
12
|
-
# Defining the R script and loading the instance in Python
|
|
13
|
-
r['source'](Beratools_R_script)
|
|
14
|
-
# Loading the function defined in R script.
|
|
15
|
-
r_points2trees = robjects.globalenv['points2trees']
|
|
16
|
-
r_pd2cellsize = robjects.globalenv['pd2cellsize']
|
|
17
|
-
# Invoking the R function
|
|
18
|
-
if do_nCHM:
|
|
19
|
-
CHMcell_size = r_pd2cellsize(in_las_folder, rprocesses)
|
|
20
|
-
print("CHM raster output cell size is: {}m".format(CHMcell_size))
|
|
21
|
-
r_points2trees(in_las_folder, is_normalized, hmin, out_folder, rprocesses, CHMcell_size, cell_size)
|
|
22
|
-
else:
|
|
23
|
-
CHMcell_size = -999
|
|
24
|
-
r_points2trees(in_las_folder, is_normalized, hmin, out_folder, rprocesses, CHMcell_size, cell_size)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if __name__ == '__main__':
|
|
28
|
-
start_time = time.time()
|
|
29
|
-
print('Starting tree detection from LAS processing\n @ {}'
|
|
30
|
-
.format(time.strftime("%d %b %Y %H:%M:%S", time.localtime())))
|
|
31
|
-
|
|
32
|
-
packages = ['lidR', 'rgrass', 'rlas', 'future', 'terra', 'sp']
|
|
33
|
-
check_r_packages_installation(packages)
|
|
34
|
-
|
|
35
|
-
print("Checking input parameters ...")
|
|
36
|
-
in_args, in_verbose = check_arguments()
|
|
37
|
-
in_las_folder = in_args.input["in_las_folder"]
|
|
38
|
-
|
|
39
|
-
try:
|
|
40
|
-
hmin = float(in_args.input["hmin"])
|
|
41
|
-
if hmin >= 20:
|
|
42
|
-
print("Invalid input of minimum height (<=20) of a tree, maximum is used")
|
|
43
|
-
in_args.input["hmin"] = 20.0
|
|
44
|
-
else:
|
|
45
|
-
in_args.input["hmin"] = hmin
|
|
46
|
-
except ValueError:
|
|
47
|
-
print("Invalid input of minimum height (<=20) of a tree, default is used")
|
|
48
|
-
in_args.input["hmin"] = 3.0
|
|
49
|
-
|
|
50
|
-
try:
|
|
51
|
-
is_normalized = bool(in_args.input["is_normalized"])
|
|
52
|
-
|
|
53
|
-
except ValueError:
|
|
54
|
-
print("Invalid input of checking normalized data box, normalize data will be carried")
|
|
55
|
-
in_args.input["is_normalized"] = False
|
|
56
|
-
|
|
57
|
-
try:
|
|
58
|
-
cell_size = float(in_args.input["cell_size"])
|
|
59
|
-
in_args.input["cell_size"] = cell_size
|
|
60
|
-
except ValueError:
|
|
61
|
-
print("Invalid input of minimum height of a tree, default is used")
|
|
62
|
-
in_args.input["cell_size"] = 5.0
|
|
63
|
-
|
|
64
|
-
out_folder = in_args.input["out_folder"]
|
|
65
|
-
|
|
66
|
-
if not os.path.exists(in_las_folder):
|
|
67
|
-
print("Error! Cannot locate Las folder, please check.")
|
|
68
|
-
exit()
|
|
69
|
-
else:
|
|
70
|
-
found = False
|
|
71
|
-
for files in os.listdir(in_las_folder):
|
|
72
|
-
if files.endswith(".las") or files.endswith(".laz"):
|
|
73
|
-
found = True
|
|
74
|
-
break
|
|
75
|
-
if not found:
|
|
76
|
-
print("Error! Cannot locate input LAS file(s), please check!")
|
|
77
|
-
exit()
|
|
78
|
-
|
|
79
|
-
if not os.path.exists(out_folder):
|
|
80
|
-
print("Warning! Cannot locate output folder, It will be created.")
|
|
81
|
-
os.makedirs(out_folder)
|
|
82
|
-
|
|
83
|
-
print("Checking input parameters ... Done")
|
|
84
|
-
|
|
85
|
-
points2trees(print, **in_args.input, processes=int(in_args.processes), verbose=in_verbose)
|
|
86
|
-
|
|
87
|
-
print('Tree detection from Lidar data processing is done in {} seconds)'
|
|
88
|
-
.format(round(time.time() - start_time, 5)))
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
from beratools.tools.common import *
|
|
5
|
+
from beratools.tools.r_interface import *
|
|
6
|
+
|
|
7
|
+
def points2trees(callback, in_las_folder, is_normalized, hmin, cell_size, do_nCHM, out_folder, processes, verbose):
|
|
8
|
+
rprocesses = r_processes(processes)
|
|
9
|
+
|
|
10
|
+
# assign R script file to local variable
|
|
11
|
+
Beratools_R_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Beratools_r_script.r')
|
|
12
|
+
# Defining the R script and loading the instance in Python
|
|
13
|
+
r['source'](Beratools_R_script)
|
|
14
|
+
# Loading the function defined in R script.
|
|
15
|
+
r_points2trees = robjects.globalenv['points2trees']
|
|
16
|
+
r_pd2cellsize = robjects.globalenv['pd2cellsize']
|
|
17
|
+
# Invoking the R function
|
|
18
|
+
if do_nCHM:
|
|
19
|
+
CHMcell_size = r_pd2cellsize(in_las_folder, rprocesses)
|
|
20
|
+
print("CHM raster output cell size is: {}m".format(CHMcell_size))
|
|
21
|
+
r_points2trees(in_las_folder, is_normalized, hmin, out_folder, rprocesses, CHMcell_size, cell_size)
|
|
22
|
+
else:
|
|
23
|
+
CHMcell_size = -999
|
|
24
|
+
r_points2trees(in_las_folder, is_normalized, hmin, out_folder, rprocesses, CHMcell_size, cell_size)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == '__main__':
|
|
28
|
+
start_time = time.time()
|
|
29
|
+
print('Starting tree detection from LAS processing\n @ {}'
|
|
30
|
+
.format(time.strftime("%d %b %Y %H:%M:%S", time.localtime())))
|
|
31
|
+
|
|
32
|
+
packages = ['lidR', 'rgrass', 'rlas', 'future', 'terra', 'sp']
|
|
33
|
+
check_r_packages_installation(packages)
|
|
34
|
+
|
|
35
|
+
print("Checking input parameters ...")
|
|
36
|
+
in_args, in_verbose = check_arguments()
|
|
37
|
+
in_las_folder = in_args.input["in_las_folder"]
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
hmin = float(in_args.input["hmin"])
|
|
41
|
+
if hmin >= 20:
|
|
42
|
+
print("Invalid input of minimum height (<=20) of a tree, maximum is used")
|
|
43
|
+
in_args.input["hmin"] = 20.0
|
|
44
|
+
else:
|
|
45
|
+
in_args.input["hmin"] = hmin
|
|
46
|
+
except ValueError:
|
|
47
|
+
print("Invalid input of minimum height (<=20) of a tree, default is used")
|
|
48
|
+
in_args.input["hmin"] = 3.0
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
is_normalized = bool(in_args.input["is_normalized"])
|
|
52
|
+
|
|
53
|
+
except ValueError:
|
|
54
|
+
print("Invalid input of checking normalized data box, normalize data will be carried")
|
|
55
|
+
in_args.input["is_normalized"] = False
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
cell_size = float(in_args.input["cell_size"])
|
|
59
|
+
in_args.input["cell_size"] = cell_size
|
|
60
|
+
except ValueError:
|
|
61
|
+
print("Invalid input of minimum height of a tree, default is used")
|
|
62
|
+
in_args.input["cell_size"] = 5.0
|
|
63
|
+
|
|
64
|
+
out_folder = in_args.input["out_folder"]
|
|
65
|
+
|
|
66
|
+
if not os.path.exists(in_las_folder):
|
|
67
|
+
print("Error! Cannot locate Las folder, please check.")
|
|
68
|
+
exit()
|
|
69
|
+
else:
|
|
70
|
+
found = False
|
|
71
|
+
for files in os.listdir(in_las_folder):
|
|
72
|
+
if files.endswith(".las") or files.endswith(".laz"):
|
|
73
|
+
found = True
|
|
74
|
+
break
|
|
75
|
+
if not found:
|
|
76
|
+
print("Error! Cannot locate input LAS file(s), please check!")
|
|
77
|
+
exit()
|
|
78
|
+
|
|
79
|
+
if not os.path.exists(out_folder):
|
|
80
|
+
print("Warning! Cannot locate output folder, It will be created.")
|
|
81
|
+
os.makedirs(out_folder)
|
|
82
|
+
|
|
83
|
+
print("Checking input parameters ... Done")
|
|
84
|
+
|
|
85
|
+
points2trees(print, **in_args.input, processes=int(in_args.processes), verbose=in_verbose)
|
|
86
|
+
|
|
87
|
+
print('Tree detection from Lidar data processing is done in {} seconds)'
|
|
88
|
+
.format(round(time.time() - start_time, 5)))
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
from beratools.tools.common import *
|
|
5
|
-
from beratools.tools.r_interface import *
|
|
6
|
-
|
|
7
|
-
def veg_cover_percentage(callback, in_las_folder, is_normalized, out_folder, hmin, hmax, cell_size, processes, verbose):
|
|
8
|
-
rprocesses = r_processes(processes)
|
|
9
|
-
|
|
10
|
-
# assign R script file to local variable
|
|
11
|
-
Beratools_R_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Beratools_r_script.r')
|
|
12
|
-
# Defining the R script and loading the instance in Python
|
|
13
|
-
r['source'](Beratools_R_script)
|
|
14
|
-
# Loading the function defined in R script.
|
|
15
|
-
r_veg_metrics = robjects.globalenv['veg_cover_percentage']
|
|
16
|
-
# Invoking the R function
|
|
17
|
-
r_veg_metrics(in_las_folder, is_normalized, out_folder, hmin, hmax, cell_size, rprocesses)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if __name__ == '__main__':
|
|
21
|
-
start_time = time.time()
|
|
22
|
-
print('Finding Vegetation Coverage from Lidar data process\n @ {}'
|
|
23
|
-
.format(time.strftime("%d %b %Y %H:%M:%S", time.localtime())))
|
|
24
|
-
|
|
25
|
-
packages = ['lidR', 'future', 'terra']
|
|
26
|
-
check_r_packages_installation(packages)
|
|
27
|
-
|
|
28
|
-
print("Checking input parameters ...")
|
|
29
|
-
in_args, in_verbose = check_arguments()
|
|
30
|
-
in_las_folder = in_args.input["in_las_folder"]
|
|
31
|
-
|
|
32
|
-
try:
|
|
33
|
-
hmin = float(in_args.input["hmin"])
|
|
34
|
-
if hmin < 0:
|
|
35
|
-
raise ValueError
|
|
36
|
-
else:
|
|
37
|
-
in_args.input["hmin"] = hmin
|
|
38
|
-
except ValueError:
|
|
39
|
-
print("Invalid input of minimum height of a tree, default value is used")
|
|
40
|
-
in_args.input["hmin"] = 3.0
|
|
41
|
-
|
|
42
|
-
try:
|
|
43
|
-
hmax = float(in_args.input["hmax"])
|
|
44
|
-
if hmax <= hmin:
|
|
45
|
-
raise ValueError
|
|
46
|
-
else:
|
|
47
|
-
in_args.input["hmax"] = hmax
|
|
48
|
-
except ValueError:
|
|
49
|
-
print("Invalid input of maximum height of a tree, default value is used")
|
|
50
|
-
if hmin < 10:
|
|
51
|
-
in_args.input["hmax"] = 10.0
|
|
52
|
-
else:
|
|
53
|
-
in_args.input["hmin"] = 3.0
|
|
54
|
-
in_args.input["hmax"] = 10.0
|
|
55
|
-
|
|
56
|
-
try:
|
|
57
|
-
is_normalized = bool(in_args.input["is_normalized"])
|
|
58
|
-
|
|
59
|
-
except ValueError:
|
|
60
|
-
print("Invalid input of checking normalized data box, normalize data will be carried")
|
|
61
|
-
in_args.input["is_normalized"] = False
|
|
62
|
-
|
|
63
|
-
try:
|
|
64
|
-
cell_size = float(in_args.input["cell_size"])
|
|
65
|
-
in_args.input["cell_size"] = cell_size
|
|
66
|
-
except ValueError:
|
|
67
|
-
print("Invalid input of cell size, default value is used")
|
|
68
|
-
in_args.input["cell_size"] = 5.0
|
|
69
|
-
|
|
70
|
-
out_folder = in_args.input["out_folder"]
|
|
71
|
-
|
|
72
|
-
if not os.path.exists(in_las_folder):
|
|
73
|
-
print("Error! Cannot locate Las folder, please check.")
|
|
74
|
-
exit()
|
|
75
|
-
else:
|
|
76
|
-
found = False
|
|
77
|
-
for files in os.listdir(in_las_folder):
|
|
78
|
-
if files.endswith(".las") or files.endswith(".laz"):
|
|
79
|
-
found = True
|
|
80
|
-
break
|
|
81
|
-
if not found:
|
|
82
|
-
print("Error! Cannot locate input LAS file(s), please check!")
|
|
83
|
-
exit()
|
|
84
|
-
|
|
85
|
-
if not os.path.exists(out_folder):
|
|
86
|
-
print("Warning! Cannot locate output folder, It will be created.")
|
|
87
|
-
os.makedirs(out_folder)
|
|
88
|
-
|
|
89
|
-
print("Checking input parameters ... Done")
|
|
90
|
-
|
|
91
|
-
veg_cover_percentage(print, **in_args.input, processes=int(in_args.processes), verbose=in_verbose)
|
|
92
|
-
|
|
93
|
-
print('Finding Vegetation Coverage from Lidar data process is done in {} seconds)'
|
|
94
|
-
.format(round(time.time() - start_time, 5)))
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
from beratools.tools.common import *
|
|
5
|
+
from beratools.tools.r_interface import *
|
|
6
|
+
|
|
7
|
+
def veg_cover_percentage(callback, in_las_folder, is_normalized, out_folder, hmin, hmax, cell_size, processes, verbose):
|
|
8
|
+
rprocesses = r_processes(processes)
|
|
9
|
+
|
|
10
|
+
# assign R script file to local variable
|
|
11
|
+
Beratools_R_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Beratools_r_script.r')
|
|
12
|
+
# Defining the R script and loading the instance in Python
|
|
13
|
+
r['source'](Beratools_R_script)
|
|
14
|
+
# Loading the function defined in R script.
|
|
15
|
+
r_veg_metrics = robjects.globalenv['veg_cover_percentage']
|
|
16
|
+
# Invoking the R function
|
|
17
|
+
r_veg_metrics(in_las_folder, is_normalized, out_folder, hmin, hmax, cell_size, rprocesses)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if __name__ == '__main__':
|
|
21
|
+
start_time = time.time()
|
|
22
|
+
print('Finding Vegetation Coverage from Lidar data process\n @ {}'
|
|
23
|
+
.format(time.strftime("%d %b %Y %H:%M:%S", time.localtime())))
|
|
24
|
+
|
|
25
|
+
packages = ['lidR', 'future', 'terra']
|
|
26
|
+
check_r_packages_installation(packages)
|
|
27
|
+
|
|
28
|
+
print("Checking input parameters ...")
|
|
29
|
+
in_args, in_verbose = check_arguments()
|
|
30
|
+
in_las_folder = in_args.input["in_las_folder"]
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
hmin = float(in_args.input["hmin"])
|
|
34
|
+
if hmin < 0:
|
|
35
|
+
raise ValueError
|
|
36
|
+
else:
|
|
37
|
+
in_args.input["hmin"] = hmin
|
|
38
|
+
except ValueError:
|
|
39
|
+
print("Invalid input of minimum height of a tree, default value is used")
|
|
40
|
+
in_args.input["hmin"] = 3.0
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
hmax = float(in_args.input["hmax"])
|
|
44
|
+
if hmax <= hmin:
|
|
45
|
+
raise ValueError
|
|
46
|
+
else:
|
|
47
|
+
in_args.input["hmax"] = hmax
|
|
48
|
+
except ValueError:
|
|
49
|
+
print("Invalid input of maximum height of a tree, default value is used")
|
|
50
|
+
if hmin < 10:
|
|
51
|
+
in_args.input["hmax"] = 10.0
|
|
52
|
+
else:
|
|
53
|
+
in_args.input["hmin"] = 3.0
|
|
54
|
+
in_args.input["hmax"] = 10.0
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
is_normalized = bool(in_args.input["is_normalized"])
|
|
58
|
+
|
|
59
|
+
except ValueError:
|
|
60
|
+
print("Invalid input of checking normalized data box, normalize data will be carried")
|
|
61
|
+
in_args.input["is_normalized"] = False
|
|
62
|
+
|
|
63
|
+
try:
|
|
64
|
+
cell_size = float(in_args.input["cell_size"])
|
|
65
|
+
in_args.input["cell_size"] = cell_size
|
|
66
|
+
except ValueError:
|
|
67
|
+
print("Invalid input of cell size, default value is used")
|
|
68
|
+
in_args.input["cell_size"] = 5.0
|
|
69
|
+
|
|
70
|
+
out_folder = in_args.input["out_folder"]
|
|
71
|
+
|
|
72
|
+
if not os.path.exists(in_las_folder):
|
|
73
|
+
print("Error! Cannot locate Las folder, please check.")
|
|
74
|
+
exit()
|
|
75
|
+
else:
|
|
76
|
+
found = False
|
|
77
|
+
for files in os.listdir(in_las_folder):
|
|
78
|
+
if files.endswith(".las") or files.endswith(".laz"):
|
|
79
|
+
found = True
|
|
80
|
+
break
|
|
81
|
+
if not found:
|
|
82
|
+
print("Error! Cannot locate input LAS file(s), please check!")
|
|
83
|
+
exit()
|
|
84
|
+
|
|
85
|
+
if not os.path.exists(out_folder):
|
|
86
|
+
print("Warning! Cannot locate output folder, It will be created.")
|
|
87
|
+
os.makedirs(out_folder)
|
|
88
|
+
|
|
89
|
+
print("Checking input parameters ... Done")
|
|
90
|
+
|
|
91
|
+
veg_cover_percentage(print, **in_args.input, processes=int(in_args.processes), verbose=in_verbose)
|
|
92
|
+
|
|
93
|
+
print('Finding Vegetation Coverage from Lidar data process is done in {} seconds)'
|
|
94
|
+
.format(round(time.time() - start_time, 5)))
|