Is it possible to return null voxels (those without any points) using voxel_metrics()?

As the description is written, voxels are only returned when they contain at least one point. I am currently attempting to look at ratios of empty and not empty voxels in various height layers such as discussed in Pearse et al. (2019).


Pearse, G. D., Watt, M. S., Dash, J. P., Stone, C., & Caccamo, G. (2019). Comparison of models describing forest inventory attributes using standard and voxel-based lidar predictors across a range of pulse densities. International Journal of Applied Earth Observation and Geoinformation, 78, 341-351.

1 Answer 1


You cannot do that with voxel_metrics() but you can generate the missing voxels yourself

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las = readLAS(LASfile)

# Compute a metric for each real voxel
res = 2
vox = voxel_metrics(las, ~mean(Intensity), res)

# Generate all the possible voxels
x = seq(min(vox$X), max(vox$X), res)
y = seq(min(vox$Y), max(vox$Y), res)
z = seq(min(vox$Z), max(vox$Z), res)
all_vox = expand.grid(X = x, Y = y, Z = z)

# Merge both unsing a join
fullvox = vox[all_vox, on = c("X", "Y", "Z")]

# 3D rendering. It is hard to see anything in fullvox
# because most of the voxels are NA and are displayed gray.
plot(vox, color = "V1", size = 0.5, trim = 50)
plot(fullvox, color = "V1", size = 0.5, trim = 50)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.