@@ -328,18 +328,8 @@ def output_tpu_to_las_extra_bytes(self, las, data_to_output):
328
328
329
329
# read las file
330
330
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)
342
331
# print(in_las.header)
332
+ # print(in_las.vlrs)
343
333
344
334
# note '<f4' -> 32 bit floating point
345
335
# 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):
352
342
# for dimension, dtype in extra_byte_dimensions.items():
353
343
354
344
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)
356
348
357
349
if len (data_to_output ) != 0 :
358
350
tpu_data = np .vstack (data_to_output )
@@ -384,42 +376,32 @@ def output_tpu_to_las_extra_bytes(self, las, data_to_output):
384
376
).sort_index ()
385
377
386
378
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
+
389
382
390
383
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
+
394
387
395
388
396
389
else :
397
390
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 )
400
392
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 )
413
394
414
395
# If the user has selected .laz ouput, append .laz
415
396
if self .gui_object .laz_option :
416
- out_las .write (out_laz_name )
397
+ in_las .write (out_laz_name )
417
398
# If the user has selected .las ouput, append .las
418
399
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")
421
403
422
- # for field in out_las .point_format:
404
+ # for field in in_las .point_format:
423
405
# print({field.name})
424
406
425
407
if self .gui_object .csv_option :
@@ -443,13 +425,13 @@ def output_tpu_to_las_extra_bytes(self, las, data_to_output):
443
425
# Save relevant data to csv
444
426
pd .DataFrame .from_dict (
445
427
{
446
- "GPS Time" : out_las .gps_time ,
428
+ "GPS Time" : in_las .gps_time ,
447
429
"X" : x ,
448
430
"Y" : y ,
449
431
"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 ,
453
435
}
454
436
).to_csv (out_csv_name , index = False )
455
437
except ValueError as e :
0 commit comments