Skip to content

Commit 76b50d7

Browse files
authored
Merge pull request #79 from cBLUE-dev-team/out_las_header_fix
Fixed error when copying header file information for output files. Instead of copying in_las data object to an out_las data object, just append Extra Bytes total_thu and total_tvu to the in_las data object. Replaced all instances of out_las with the in_las object in Tpu.py. Updates version number to 3.4
2 parents 8d85857 + 963d633 commit 76b50d7

File tree

4 files changed

+22
-40
lines changed

4 files changed

+22
-40
lines changed
Binary file not shown.

Tpu.py

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -328,18 +328,8 @@ def output_tpu_to_las_extra_bytes(self, las, data_to_output):
328328

329329
# read las file
330330
in_las = laspy.read(las.las)
331-
332-
# print(f"\npoint format: {in_las.header.point_format.id}\n")
333-
out_las = laspy.LasData(laspy.LasHeader(version="1.4", point_format=in_las.header.point_format.id))
334-
out_las.header.scales[0] = in_las.header.scales[0]
335-
out_las.header.scales[1] = in_las.header.scales[1]
336-
out_las.header.scales[2] = in_las.header.scales[2]
337-
338-
out_las.header.offsets[0] = in_las.header.offsets[0]
339-
out_las.header.offsets[1] = in_las.header.offsets[1]
340-
out_las.header.offsets[2] = in_las.header.offsets[2]
341-
# out_las = laspy.LasData(in_las.header)
342331
# print(in_las.header)
332+
# print(in_las.vlrs)
343333

344334
# note '<f4' -> 32 bit floating point
345335
# extra_byte_dimensions = {"total_thu": "<f4", "total_tvu": "<f4"}
@@ -352,7 +342,9 @@ def output_tpu_to_las_extra_bytes(self, las, data_to_output):
352342
# for dimension, dtype in extra_byte_dimensions.items():
353343

354344
logger.tpu("creating extra byte dimension for total_thu and total_tvu")
355-
out_las.add_extra_dims(extra_byte_dimensions)
345+
in_las.add_extra_dims(extra_byte_dimensions)
346+
# print(in_las.header)
347+
# print(in_las.vlrs)
356348

357349
if len(data_to_output) != 0:
358350
tpu_data = np.vstack(data_to_output)
@@ -384,42 +376,32 @@ def output_tpu_to_las_extra_bytes(self, las, data_to_output):
384376
).sort_index()
385377

386378
logger.tpu("populating extra byte data for total_thu...")
387-
out_las.total_thu = extra_byte_df["total_thu"]
388-
# print(f"THU: {out_las.total_thu}")
379+
in_las.total_thu = extra_byte_df["total_thu"]
380+
# print(f"THU: {in_las.total_thu}")
381+
389382

390383
logger.tpu("populating extra byte data for total_tvu...")
391-
out_las.total_tvu = extra_byte_df["total_tvu"]
392-
# print(f"TVU: {out_las.total_tvu}")
393-
# print(f"{out_las.total_tvu[2279775]}")
384+
in_las.total_tvu = extra_byte_df["total_tvu"]
385+
# print(f"TVU: {in_las.total_tvu}")
386+
394387

395388

396389
else:
397390
logger.tpu("populating extra byte data for total_thu...")
398-
out_las.total_thu = np.zeros(las.num_file_points)
399-
391+
in_las.total_thu = np.zeros(las.num_file_points)
400392
logger.tpu("populating extra byte data for total_tvu...")
401-
out_las.total_tvu = np.zeros(las.num_file_points)
402-
403-
# copy data from in_las
404-
for field in in_las.point_format:
405-
logger.tpu("writing {} to {} ...".format(field.name, out_las))
406-
407-
# cannot copy over non-standard (extrabyte) dimensions
408-
dim = in_las.point_format.dimension_by_name(field.name)
409-
if dim.is_standard:
410-
# print({field.name})
411-
las_data = in_las[field.name]
412-
out_las[field.name] = las_data[las.t_argsort]
393+
in_las.total_tvu = np.zeros(las.num_file_points)
413394

414395
# If the user has selected .laz ouput, append .laz
415396
if self.gui_object.laz_option:
416-
out_las.write(out_laz_name)
397+
in_las.write(out_laz_name)
417398
# If the user has selected .las ouput, append .las
418399
if self.gui_object.las_option:
419-
out_las.write(out_las_name)
420-
# print("Wrote out_las")
400+
in_las.write(out_las_name)
401+
402+
# print("Wrote in_las")
421403

422-
# for field in out_las.point_format:
404+
# for field in in_las.point_format:
423405
# print({field.name})
424406

425407
if self.gui_object.csv_option:
@@ -443,13 +425,13 @@ def output_tpu_to_las_extra_bytes(self, las, data_to_output):
443425
# Save relevant data to csv
444426
pd.DataFrame.from_dict(
445427
{
446-
"GPS Time": out_las.gps_time,
428+
"GPS Time": in_las.gps_time,
447429
"X": x,
448430
"Y": y,
449431
"Z": z,
450-
"THU": out_las.total_thu,
451-
"TVU": out_las.total_tvu,
452-
"Classification": out_las.classification,
432+
"THU": in_las.total_thu,
433+
"TVU": in_las.total_tvu,
434+
"Classification": in_las.classification,
453435
}
454436
).to_csv(out_csv_name, index=False)
455437
except ValueError as e:

cblue_configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"multiprocess": "False",
88
"number_cores": 4,
9-
"cBLUE_version": "v3.3",
9+
"cBLUE_version": "v3.4",
1010
"subaqueous_version": "v2.2",
1111
"subaqueous_classes": [
1212
"40",

0 commit comments

Comments
 (0)