-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge_output.py
55 lines (46 loc) · 2.07 KB
/
merge_output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""Merges output as generated by test_data_generator.py
Script must be run from 'helios_dir/output/Survey Playback' folder
param lasmerge: path to lasmerge executable
param outdir: path to which merged files will be written and metadata files will be copied
"""
import os
lasmerge = r"E:\LAStools\bin\lasmerge.exe"
outdir = r"E:/ws_21_22/bachelor_arbeit/data/generated_data/test_data3/"
files = [f for f in os.listdir('.')]
# Run in 'Survey Playback' folder
for i, f in enumerate(sorted(files)):
files2 = [os.path.join(os.getcwd(), f, f2) for f2 in os.listdir(os.path.join(os.getcwd(), f))]
for f2 in files2:
old_dir = os.getcwd()
os.chdir(f2)
num = f2.split('data_gen_')[1].split('\\')[0]
call0 = r'{} -i *.xyz -iparse xyzssrnssst -o {}merged_{}.laz'.format(lasmerge, outdir, num)
call = r'{} -i *.laz -o {}merged_data_{}.laz'.format(lasmerge, outdir, num)
print(os.getcwd())
print(call0)
os.system(call0)
call1 = r'copy metadata.txt "{}metadata_{}.txt"'.format(outdir, num)
print(call1)
os.popen(call1)
os.chdir(old_dir)
# old implementation:
'''outdir = r'G:/ws_21_22/bachelor_arbeit/data/test_data2/'
old_dir = os.getcwd()
files = [f for f in os.listdir('.') if os.path.isdir(f)]
# Run in 'Survey Playback' folder
for i, f in enumerate(sorted(files)):
files2 = [os.path.join(os.getcwd(), f, f2) for f2 in os.listdir(os.path.join(os.getcwd(), f))]
for f2 in files2:
files3 = [os.path.join(os.getcwd(), f2, f3) for f3 in os.listdir(f2)]
for f3 in files3:
os.chdir(f3)
num = f3.split('data_gen_')[1].split('\\')[0]
print(num)
print('Merging las files in {}...'.format(f3))
call = r'G:\LAStools\bin\lasmerge -i *.las -o {}merged_data_{}.las'.format(outdir, num)
os.system(call)
print(call)
call1 = r'copy metadata.txt "{}metadata_{}.txt"'.format(outdir, num)
os.popen(call1)
print(call1)
os.chdir(old_dir)'''