BERATools 0.2.2__py3-none-any.whl → 0.2.4__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 +8 -3
- beratools/core/{algo_footprint_rel.py → algo_canopy_footprint_exp.py} +176 -139
- beratools/core/algo_centerline.py +61 -77
- beratools/core/algo_common.py +48 -57
- beratools/core/algo_cost.py +18 -25
- beratools/core/algo_dijkstra.py +37 -45
- beratools/core/algo_line_grouping.py +100 -100
- beratools/core/algo_merge_lines.py +40 -8
- beratools/core/algo_split_with_lines.py +289 -304
- beratools/core/algo_vertex_optimization.py +25 -46
- beratools/core/canopy_threshold_relative.py +755 -0
- beratools/core/constants.py +8 -9
- beratools/{tools → core}/line_footprint_functions.py +411 -258
- beratools/core/logger.py +18 -2
- beratools/core/tool_base.py +17 -75
- beratools/gui/assets/BERALogo.ico +0 -0
- beratools/gui/assets/BERA_Splash.gif +0 -0
- beratools/gui/assets/BERA_WizardImage.png +0 -0
- beratools/gui/assets/beratools.json +475 -2171
- beratools/gui/bt_data.py +585 -234
- beratools/gui/bt_gui_main.py +129 -91
- beratools/gui/main.py +4 -7
- beratools/gui/tool_widgets.py +530 -354
- beratools/tools/__init__.py +0 -7
- beratools/tools/{line_footprint_absolute.py → canopy_footprint_absolute.py} +81 -56
- beratools/tools/canopy_footprint_exp.py +113 -0
- beratools/tools/centerline.py +30 -37
- beratools/tools/check_seed_line.py +127 -0
- beratools/tools/common.py +65 -586
- beratools/tools/{line_footprint_fixed.py → ground_footprint.py} +140 -117
- beratools/tools/line_footprint_relative.py +64 -35
- beratools/tools/tool_template.py +48 -40
- beratools/tools/vertex_optimization.py +20 -34
- beratools/utility/env_checks.py +53 -0
- beratools/utility/spatial_common.py +210 -0
- beratools/utility/tool_args.py +138 -0
- beratools-0.2.4.dist-info/METADATA +134 -0
- beratools-0.2.4.dist-info/RECORD +50 -0
- {beratools-0.2.2.dist-info → beratools-0.2.4.dist-info}/WHEEL +1 -1
- beratools-0.2.4.dist-info/entry_points.txt +3 -0
- beratools-0.2.4.dist-info/licenses/LICENSE +674 -0
- beratools/core/algo_tiler.py +0 -428
- beratools/gui/__init__.py +0 -11
- beratools/gui/batch_processing_dlg.py +0 -513
- beratools/gui/map_window.py +0 -162
- beratools/tools/Beratools_r_script.r +0 -1120
- beratools/tools/Ht_metrics.py +0 -116
- beratools/tools/batch_processing.py +0 -136
- beratools/tools/canopy_threshold_relative.py +0 -672
- beratools/tools/canopycostraster.py +0 -222
- beratools/tools/fl_regen_csf.py +0 -428
- beratools/tools/forest_line_attributes.py +0 -408
- beratools/tools/line_grouping.py +0 -45
- beratools/tools/ln_relative_metrics.py +0 -615
- beratools/tools/r_cal_lpi_elai.r +0 -25
- beratools/tools/r_generate_pd_focalraster.r +0 -101
- beratools/tools/r_interface.py +0 -80
- beratools/tools/r_point_density.r +0 -9
- beratools/tools/rpy_chm2trees.py +0 -86
- beratools/tools/rpy_dsm_chm_by.py +0 -81
- beratools/tools/rpy_dtm_by.py +0 -63
- beratools/tools/rpy_find_cellsize.py +0 -43
- beratools/tools/rpy_gnd_csf.py +0 -74
- beratools/tools/rpy_hummock_hollow.py +0 -85
- beratools/tools/rpy_hummock_hollow_raster.py +0 -71
- beratools/tools/rpy_las_info.py +0 -51
- beratools/tools/rpy_laz2las.py +0 -40
- beratools/tools/rpy_lpi_elai_lascat.py +0 -466
- beratools/tools/rpy_normalized_lidar_by.py +0 -56
- beratools/tools/rpy_percent_above_dbh.py +0 -80
- beratools/tools/rpy_points2trees.py +0 -88
- beratools/tools/rpy_vegcoverage.py +0 -94
- beratools/tools/tiler.py +0 -48
- beratools/tools/zonal_threshold.py +0 -144
- beratools-0.2.2.dist-info/METADATA +0 -108
- beratools-0.2.2.dist-info/RECORD +0 -74
- beratools-0.2.2.dist-info/entry_points.txt +0 -2
- beratools-0.2.2.dist-info/licenses/LICENSE +0 -22
|
@@ -27,7 +27,7 @@ import beratools.core.algo_common as algo_common
|
|
|
27
27
|
import beratools.core.algo_cost as algo_cost
|
|
28
28
|
import beratools.core.constants as bt_const
|
|
29
29
|
import beratools.core.tool_base as bt_base
|
|
30
|
-
import beratools.
|
|
30
|
+
import beratools.utility.spatial_common as sp_common
|
|
31
31
|
from beratools.core import algo_dijkstra
|
|
32
32
|
|
|
33
33
|
|
|
@@ -251,36 +251,26 @@ class _Vertex:
|
|
|
251
251
|
if len(self.anchors) == 4:
|
|
252
252
|
seed_line = sh_geom.LineString(self.anchors[0:2])
|
|
253
253
|
|
|
254
|
-
raster_clip, out_meta =
|
|
255
|
-
self.in_raster, seed_line, self.line_radius
|
|
256
|
-
)
|
|
254
|
+
raster_clip, out_meta = sp_common.clip_raster(self.in_raster, seed_line, self.line_radius)
|
|
257
255
|
raster_clip, _ = algo_cost.cost_raster(raster_clip, out_meta)
|
|
258
256
|
centerline_1 = find_lc_path(raster_clip, out_meta, seed_line)
|
|
259
257
|
seed_line = sh_geom.LineString(self.anchors[2:4])
|
|
260
258
|
|
|
261
|
-
raster_clip, out_meta =
|
|
262
|
-
self.in_raster, seed_line, self.line_radius
|
|
263
|
-
)
|
|
259
|
+
raster_clip, out_meta = sp_common.clip_raster(self.in_raster, seed_line, self.line_radius)
|
|
264
260
|
raster_clip, _ = algo_cost.cost_raster(raster_clip, out_meta)
|
|
265
261
|
centerline_2 = find_lc_path(raster_clip, out_meta, seed_line)
|
|
266
262
|
|
|
267
263
|
if centerline_1 and centerline_2:
|
|
268
|
-
intersection = algo_common.intersection_of_lines(
|
|
269
|
-
centerline_1, centerline_2
|
|
270
|
-
)
|
|
264
|
+
intersection = algo_common.intersection_of_lines(centerline_1, centerline_2)
|
|
271
265
|
elif len(self.anchors) == 2:
|
|
272
266
|
seed_line = sh_geom.LineString(self.anchors)
|
|
273
267
|
|
|
274
|
-
raster_clip, out_meta =
|
|
275
|
-
self.in_raster, seed_line, self.line_radius
|
|
276
|
-
)
|
|
268
|
+
raster_clip, out_meta = sp_common.clip_raster(self.in_raster, seed_line, self.line_radius)
|
|
277
269
|
raster_clip, _ = algo_cost.cost_raster(raster_clip, out_meta)
|
|
278
270
|
centerline_1 = find_lc_path(raster_clip, out_meta, seed_line)
|
|
279
271
|
|
|
280
272
|
if centerline_1:
|
|
281
|
-
intersection = algo_common.closest_point_to_line(
|
|
282
|
-
self.get_vertex(), centerline_1
|
|
283
|
-
)
|
|
273
|
+
intersection = algo_common.closest_point_to_line(self.get_vertex(), centerline_1)
|
|
284
274
|
except Exception as e:
|
|
285
275
|
print(e)
|
|
286
276
|
|
|
@@ -308,22 +298,17 @@ class VertexGrouping:
|
|
|
308
298
|
in_raster,
|
|
309
299
|
search_distance,
|
|
310
300
|
line_radius,
|
|
311
|
-
out_line,
|
|
312
301
|
processes,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
out_layer=None,
|
|
302
|
+
call_mode,
|
|
303
|
+
layer=None,
|
|
316
304
|
):
|
|
317
305
|
self.in_line = in_line
|
|
306
|
+
self.in_layer = layer
|
|
318
307
|
self.in_raster = in_raster
|
|
319
308
|
self.line_radius = float(line_radius)
|
|
320
309
|
self.search_distance = float(search_distance)
|
|
321
|
-
self.out_line = out_line
|
|
322
310
|
self.processes = processes
|
|
323
|
-
self.
|
|
324
|
-
self.parallel_mode = bt_const.PARALLEL_MODE
|
|
325
|
-
self.in_layer = in_layer
|
|
326
|
-
self.out_layer = out_layer
|
|
311
|
+
self.call_mode = call_mode
|
|
327
312
|
|
|
328
313
|
self.crs = None
|
|
329
314
|
self.vertex_grp = []
|
|
@@ -333,12 +318,7 @@ class VertexGrouping:
|
|
|
333
318
|
self.line_visited = None
|
|
334
319
|
|
|
335
320
|
# calculate cost raster footprint
|
|
336
|
-
self.cost_footprint = algo_common.generate_raster_footprint(
|
|
337
|
-
self.in_raster, latlon=False
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
def set_parallel_mode(self, parallel_mode):
|
|
341
|
-
self.parallel_mode = parallel_mode
|
|
321
|
+
self.cost_footprint = algo_common.generate_raster_footprint(self.in_raster, latlon=False)
|
|
342
322
|
|
|
343
323
|
def create_vertex_group(self, line_obj):
|
|
344
324
|
"""
|
|
@@ -378,18 +358,17 @@ class VertexGrouping:
|
|
|
378
358
|
self.vertex_grp.append(vertex_obj)
|
|
379
359
|
|
|
380
360
|
def create_all_vertex_groups(self):
|
|
381
|
-
self.
|
|
382
|
-
|
|
383
|
-
)
|
|
361
|
+
print(f"Preparing lines...{self.in_line}", flush=True)
|
|
362
|
+
print("create_all_vertex_groups")
|
|
363
|
+
print(f"in_file: {self.in_line}, in_layer: {self.in_layer}")
|
|
364
|
+
self.line_list = algo_common.prepare_lines_gdf(self.in_line, layer=self.in_layer, proc_segments=True)
|
|
384
365
|
self.sindex = STRtree([item.geometry[0] for item in self.line_list])
|
|
385
366
|
self.line_visited = [{0: False, -1: False} for _ in range(len(self.line_list))]
|
|
386
367
|
|
|
387
368
|
i = 0
|
|
388
369
|
for line_no in range(len(self.line_list)):
|
|
389
370
|
if not self.line_visited[line_no][0]:
|
|
390
|
-
line = _SingleLine(
|
|
391
|
-
self.line_list[line_no], line_no, 0, self.search_distance
|
|
392
|
-
)
|
|
371
|
+
line = _SingleLine(self.line_list[line_no], line_no, 0, self.search_distance)
|
|
393
372
|
|
|
394
373
|
if not line.is_valid:
|
|
395
374
|
print(f"Line {line['line_no']} is invalid")
|
|
@@ -400,9 +379,7 @@ class VertexGrouping:
|
|
|
400
379
|
i += 1
|
|
401
380
|
|
|
402
381
|
if not self.line_visited[line_no][-1]:
|
|
403
|
-
line = _SingleLine(
|
|
404
|
-
self.line_list[line_no], line_no, -1, self.search_distance
|
|
405
|
-
)
|
|
382
|
+
line = _SingleLine(self.line_list[line_no], line_no, -1, self.search_distance)
|
|
406
383
|
|
|
407
384
|
if not line.is_valid:
|
|
408
385
|
print(f"Line {line['line_no']} is invalid")
|
|
@@ -424,9 +401,11 @@ class VertexGrouping:
|
|
|
424
401
|
]
|
|
425
402
|
|
|
426
403
|
def save_all_layers(self, line_file):
|
|
404
|
+
out_file, out_layer = sp_common.decode_file_layer(line_file)
|
|
427
405
|
line_file = Path(line_file)
|
|
428
406
|
lines = pd.concat(self.line_list)
|
|
429
|
-
lines.to_file(
|
|
407
|
+
lines.to_file(out_file, layer=out_layer)
|
|
408
|
+
print(f"Saved output to: {line_file}", flush=True)
|
|
430
409
|
|
|
431
410
|
aux_file = line_file
|
|
432
411
|
if line_file.suffix == ".shp":
|
|
@@ -452,9 +431,10 @@ class VertexGrouping:
|
|
|
452
431
|
anchors = gpd.GeoDataFrame(geometry=anchors, crs=lines.crs)
|
|
453
432
|
vertices = gpd.GeoDataFrame(geometry=vertices, crs=lines.crs)
|
|
454
433
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
434
|
+
if bt_const.BT_DEBUGGING:
|
|
435
|
+
lc_paths.to_file(aux_file, layer="lc_paths")
|
|
436
|
+
anchors.to_file(aux_file, layer="anchors")
|
|
437
|
+
vertices.to_file(aux_file, layer="vertices")
|
|
458
438
|
|
|
459
439
|
def compute(self):
|
|
460
440
|
vertex_grp = bt_base.execute_multiprocessing(
|
|
@@ -462,8 +442,7 @@ class VertexGrouping:
|
|
|
462
442
|
self.vertex_grp,
|
|
463
443
|
"Vertex Optimization",
|
|
464
444
|
self.processes,
|
|
465
|
-
|
|
466
|
-
verbose=self.verbose,
|
|
445
|
+
self.call_mode,
|
|
467
446
|
)
|
|
468
447
|
|
|
469
448
|
self.vertex_grp = vertex_grp
|