r-lidar / lidR

Airborne LiDAR data manipulation and visualisation for forestry application
https://CRAN.R-project.org/package=lidR
GNU General Public License v3.0
607 stars 132 forks source link

gap_fraction_profile not increasing upwards #316

Closed LMurphy186232 closed 4 years ago

LMurphy186232 commented 4 years ago

Thank you for a massively useful package. grid_metrics, in particular, is saving my life.

Bouvier et al defined gap fraction as "the ratio of the number of first returns below a specified height threshold to the total number of first returns". I would thus expect the values to monotonically increase as I went up in the canopy, from near 0 to near 1. However, that is not what happens in my gap_fraction_profile results. I might get, in ascending height, gf values of 0.97, 0.92, 0.9, 0.94.

In digging into this, I suspect the reason is line 564 in utils_metrics.r which says i = data.table::shift(cs)/cs. Why the division by cs? (It is entirely possible I have missed some sort of correction factor that needs to be applied.)

Jean-Romain commented 4 years ago

No, look at figure 1 in the paper. LAD is not monotonic. The equation 5 is incorrect. It does not match with the text. It is defined as the # of return in layer [0,z] divided by # of returns in layer [0,z+dz] which is what data.table::shift(cs)/cs does in a vectorized way.

It is easy to understand with 4 layers with 10, 5, 5 and 10 returns. GF is the gap fraction:

  1. GF = 10/30 = 0.33
  2. GF = 5/20 = 0.25
  3. GF = 5/15 = 0.33
  4. GF = 10/10 = 1 (ground is always 1)

[0.33,0.25,0.33] is not monotonic. You can find the correct equation + some pictures in this paper [1].

[1] A mathematical framework to describe the effect of beam incidence angle on metrics derived from airborne LiDAR: The case of forest canopies approaching turbid medium behaviour JR Roussel, M Béland, J Caspersen, A Achim - Remote sensing of environment, 2018

LMurphy186232 commented 4 years ago

Thank you for your reply! Would it be possible for you to write out the reference of the paper you are linking to in your reply? The link appears to go behind a password-secured area.

Jean-Romain commented 4 years ago

Link edited + reference added.

LMurphy186232 commented 4 years ago

Perfect! Thank you for your time. I appreciate it.

Jean-Romain commented 4 years ago

Edit LAD != gap fraction. In my answer you should read GF instead of LAD. The LAD is the log of GF divided by an coefficient of extinction.