-
Notifications
You must be signed in to change notification settings - Fork 0
/
csf.R
70 lines (35 loc) · 1.61 KB
/
csf.R
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
#If choose 1, the program will perform default calculation
#If choose 2, custom val = 1, 1, 1, 1
#===============================================================================================
library(lidR)
library(RCSF)
#Read LAS file
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las <- readLAS(LASfile, select = "xyzrn")
#Default or Custom Val Param (choose one)
option = readline(prompt = "Enter [1] for default val param or [2] for custom val param: ")
sloopSmooth <- F
if (option == 1){
#Implement CSF algorithm with default val param
las <- classify_ground(las, algorithm = csf())
}else if (option ==2){
sloopSmoothOpt = readline(prompt = "Enter [1] to enable sloop smooth or [2] to disable: ")
if (sloopSmoothOpt == 1){
sloopSmooth <- T
}else if (sloopSmoothOpt == 2){
sloopSmooth <- F
}
classThreshold = readline(prompt = "Enter the class threshold: ")
classThreshold = as.integer(classThreshold)
clothResolution = readline(prompt = "Enter the cloth resolution: ")
clothResolution = as.integer(clothResolution)
timeStep = readline(prompt = "Enter the time step: ")
timeStep = as.integer(timeStep)
#Rebuild CSF algorithm with custom val param
cusCSF <- csf(sloop_smooth = sloopSmooth, class_threshold = classThreshold, cloth_resolution = clothResolution, time_step = timeStep)
las <- classify_ground(las, cusCSF)
}else{
print("Err")
}
#Plot Result (3D view)
plot(las, color = "Classification", size = 2, bg = "white")