Skip to content

Commit

Permalink
fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Tompalski committed Mar 19, 2024
1 parent 06feec4 commit 46353fe
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions R/metrics_rumple.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@ metrics_rumple <- function(x, y, z, pixel_size, zmin=NA) {
if(!is.na(zmin)) assert_is_a_number(zmin)
assert_all_are_positive(pixel_size)

if (!is.na(zmin)) z <- z[z>zmin]

r <- NA_real_

if (length(z) > 2) {

D <- data.table::data.table(X=x, Y=y, Z=z)

D <- LAS(D, header = rlas::header_create(D), check=F)

D <- lidR::decimate_points(D, lidR::highest(pixel_size))
if (!is.na(zmin)) D <- D[Z > zmin]

r <- lidR::rumple_index(x = D$X, y = D$Y, z = D$Z)
if(nrow(D)>0) {

D <- LAS(D, header = rlas::header_create(D), check=F)

D <- lidR::decimate_points(D, lidR::highest(pixel_size))

r <- lidR::rumple_index(x = D$X, y = D$Y, z = D$Z)
}
}

return(list(rumple=r))
Expand Down

0 comments on commit 46353fe

Please sign in to comment.