r-lidar / lasR

Fast and Pipable Airborne LiDAR Data Tools
https://r-lidar.github.io/lasR/
GNU General Public License v3.0
43 stars 0 forks source link

Problem when using filter in rasterize() #29

Closed wiesehahn closed 1 month ago

wiesehahn commented 1 month ago

When I try to calculate to calculate some rasterized metric with a filter I get strange results, where some areas (small tiles), get no value or wrong values. Its less pronounced with the testdata but it looks weird to me as well.

f <- system.file("extdata", "Topography.las", package="lasR")

imean <- rasterize(2, "imean")
pipeline = imean
ans = exec(pipeline, on = f)

imean <- rasterize(2, "imean", filter = drop_class(2))
pipeline = imean
ans = exec(pipeline, on = f)

without filter: grafik

with filter: grafik

E.g. with the filter I would not expext that the area in the lower left changes, since we are dropping ground points but this area is water.

Jean-Romain commented 1 month ago

Thank you again for reporting. I confirm the bug. The correct result is supposed to be.

library(lasR)
f <- system.file("extdata", "Topography.las", package="lasR")
read = reader_las(filter = drop_class(2))
imean <- rasterize(2, "imean")
pipeline = read + imean
ans = exec(pipeline, on = f)
terra::plot(ans)

Jean-Romain commented 1 month ago

Fixed.

Fun fact: there was a comment on the problematic line of code with something like: //TODO: check if this line is correct. :man_facepalming: