From b51121f5b1b63de8030948c9f19cb50dca74e4f9 Mon Sep 17 00:00:00 2001 From: Tompalski Date: Tue, 19 Mar 2024 14:18:32 -0700 Subject: [PATCH] fix #21 --- R/metrics_rumple.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/R/metrics_rumple.R b/R/metrics_rumple.R index e4bdc20..6868795 100644 --- a/R/metrics_rumple.R +++ b/R/metrics_rumple.R @@ -29,13 +29,20 @@ 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)) { + filt<- z>zmin + x <- x[filt] + y <- y[filt] + z <- z[filt] + } + r <- NA_real_ if (length(z) > 2) { D <- data.table::data.table(X=x, Y=y, Z=z) - if (!is.na(zmin)) D <- D[Z > zmin] + # if (!is.na(zmin)) D <- D[Z > zmin]#z <- z[z>zmin] if(nrow(D)>0) { @@ -44,11 +51,13 @@ metrics_rumple <- function(x, y, z, pixel_size, zmin=NA) { 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)) + } - return(list(rumple=r)) - }