-
Notifications
You must be signed in to change notification settings - Fork 0
/
roughness.py
78 lines (64 loc) · 1.94 KB
/
roughness.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import numpy as np
import laspy as lp
import os
import pcClass
from tkinter import Tk
from tkinter.filedialog import askopenfilename, asksaveasfilename
from tkinter import simpledialog
def open_folder():
"""
This function opens a window that lets the user select the file that is going
to be analysed.
Returns:
string: The address of the file that is being analysed. Will be a las or
laz file.
"""
Tk().withdraw();
file_name = askopenfilename(
filetypes=[
("Lidar files", "*.las"),
("Compressed Lidar files", "*.laz"),
("All files", "*")
],
initialdir="inputs/"
);
print("You have chosen to open the file:\n%s" % (file_name));
return file_name;
def input_radius():
string = simpledialog.askfloat(
title="Roughness plane raidus search",
prompt="What is the radius for constructing the least square plane?");
print("The radius chosen was:", string);
return string;
def open_folder2():
"""
This function opens a window that lets the user select the file that is going
to be analysed.
Returns:
string: The address of the file that is being analysed. Will be a las or
laz file.
"""
Tk().withdraw();
file_name = asksaveasfilename(
filetypes=[
("Lidar files", "*.las"), ("All files", "*")
],
title="Save to las",
initialdir="outputs/"
);
if file_name.endswith('.las'):
pass;
else:
file_name = file_name + '.las';
print("You have chosen to save to:\n%s" % (file_name));
return file_name;
def main():
file_name = open_folder(); # Getting the LAS input point cloud
lstsqrplanradius = input_radius(); # Getting radius for input size
pcCST = pcClass.PointCloudCST(file_name, lstsqrplanradius); # make pc obj
pcCST.roughness2(); # Running roughness calculations
save_name = open_folder2(); # Choosing save location
pcCST.print2las(save_name); # Saving the program
return;
if __name__ == "__main__":
main();