-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetLAD.R
37 lines (30 loc) · 799 Bytes
/
getLAD.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
library(lidR)
gridLAS <- function(las, grid_size){
xmin <- min(las$X)
xmax <- max(las$X)
ymin <- min(las$Y)
ymax <- max(las$Y)
grid <- list()
for(x in seq(xmin, xmax, grid_size)){
for(y in seq(ymin, ymax, grid_size)){
grid[x][y] <- lasClip(las, x, y, x+grid_size, y+grid_size)
}
}
return(unlist(grid))
}
#TODO: Test and finish
getLAD <- function(file, grid_size, height){
las <- readLAS(file)
#z above 100 is outliers
grid <- lasfilter(las, Z <= 100)
len <- length(grid)
lad <- vector(length=len)
X <- vector(length=len)
Y <- vector(length=len)
for(i in 1:len){
seg <- grid[i]
lad[i] <- LAD(seg@data$Z)[height]
X[i] <- (min(seg@data$X)+max(seg@data$X))/2
Y[i] <- (min(seg@data$Y)+max(seg@data$Y))/2
}
}