Skip to content

Commit

Permalink
Fix #437
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Jun 5, 2021
1 parent 1c66b43 commit 5927ee8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ If you are viewing this file on CRAN, please check [the latest news on GitHub](h

- Doc: fix some code block rendering in `catalog_apply` man page
- Fix: fix catalog processing engine edge case when the last chunks fail. See ([#435](https://github.com/Jean-Romain/lidR/issues/435)).
- Fix: `voxel_metrics()` with `all_voxels = TRUE` did not work as expected. The insertion of empty voxels corrupted some of the real voxels leading to invalid inputs ([#437](https://github.com/Jean-Romain/lidR/issues/437)).

## lidR v3.1.3 (Release date: 2021-05-20)

Expand Down
15 changes: 6 additions & 9 deletions R/voxel_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,17 @@ voxel_metrics = function(las, func, res = 1, ..., all_voxels = FALSE)

if (all_voxels)
{
xrange <- range(las$X)
yrange <- range(las$Y)
zrange <- range(las$Z)
xrange <- f_grid(xrange, res[1], 0)
yrange <- f_grid(yrange, res[1], 0)
zrange <- f_grid(zrange, res[2], 0.5*res[2])
xrange <- range(stat$X)
yrange <- range(stat$Y)
zrange <- range(stat$Z)
X <- seq(xrange[1], xrange[2], by = res[1])
Y <- seq(yrange[1], yrange[2], by = res[1])
Z <- seq(zrange[1], zrange[2], by = res[2])
all <- expand.grid(X = X,Y = Y, Z = Z)
data.table::setDT(all)
data.table::setkey(all, X,Y, Z)
data.table::setkey(stat, X,Y, Z)
stat <- stat[all]
data.table::setkey(all, X,Y,Z)
data.table::setkey(stat, X,Y,Z)
stat <- merge(stat, all, all = TRUE)
}

data.table::setattr(stat, "class", c("lasmetrics3d", attr(stat, "class")))
Expand Down

0 comments on commit 5927ee8

Please sign in to comment.