diff --git a/NEWS.md b/NEWS.md index 8145c756..837ef77f 100755 --- a/NEWS.md +++ b/NEWS.md @@ -3,7 +3,7 @@ If you are viewing this file on CRAN, please check [the latest news on GitHub](h ## lidR v4.1.2 (Release date: ) - Fix: strongly improved arithmetic accuracy in `point_in_triangle` to improve the quality of delaunay triangulation interpolations and avoid local NAs - +- Enhance: `decimate_points()` with `random()` now preserves the point ordering. ## lidR v4.1.1 (Release date: 2024-02-03) diff --git a/R/algorithm-dec.R b/R/algorithm-dec.R index f36304a4..bf834057 100644 --- a/R/algorithm-dec.R +++ b/R/algorithm-dec.R @@ -48,7 +48,11 @@ random = function(density, use_pulse = FALSE) else { if (nrow(las@data) > n) - return(sample(1:nrow(las@data), n)) + { + idx = sample(1:nrow(las@data), n) + idx = sort(idx) + return(idx) + } else return(1:nrow(las@data)) } @@ -237,6 +241,7 @@ random_per_voxel = function(res = 1, n = 1) selectedPulses <- sample(p, n) selectedPulses <- pulseID %in% selectedPulses + selectedPulses <- sort(selectedPulses) return(selectedPulses) }