1

I want to calculate the mean height of shrubs layer using the mean height of points between 0.2-4 m above ground but the raster output mean max values never is higher than 1 m which is not make sense since we have areas with mean shrubs higher than 2 m at 15 x 15 m pixel resolution.

The code I used to generate the metric

mean_shrub_height = function(z) {
  SH=mean(z >= 0.2 & z <= 4)
  return(list(SH =SH))
}

mean_shrub_height = grid_metrics(las, ~mean_shrub_height(Z), res = 15)

1 Answer 1

0

You are computing the mean of a boolean vector which is indeed between 0 and 1.

One solution

msh = function(z) {
  z = z[z >= 0.2 & z <= 4]
  SH=mean(z)
  return(list(SH =SH))
}

Another option

msh = pixel_metrics(las, ~list(SH = mean(Z)), res = 15, filter = ~Z >= 0.2 & Z <= 4)
1
  • Many Thanks for the help Commented Mar 9, 2023 at 22:02

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.