Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in grid_canopy when points extent (las argument) is larger than target extent (res argument) #483

Closed
jmmonnet opened this issue Oct 1, 2021 · 3 comments
Assignees
Labels
Enhancement Not actually a bug but a possible improvement

Comments

@jmmonnet
Copy link

jmmonnet commented Oct 1, 2021

Hi,

grid_canopy returns an error when the point extent (las argument) is larger than the target extent (res argument supplied as rasterLayer).

Erreur dans C_rasterize(las, layout, subcircle, 1L) :
C++ unexpected internal error in 'rasterize': point out of raster.

If the point cloud is cropped beforeward then the output is ok. The function grid_terrain runs without problem in any case.

Here is some code to reproduce this error:

# load data
data(las_chablais3, package = "lidaRtRee")
# output layout (smaller extent than point cloud)
output <- raster::raster(xmn = 974330, xmx = 974340, ymn = 6581630, ymx = 6581640, resolution = 1)
# grid_terrain is ok 
lidR::grid_terrain(las_chablais3, output, lidR::tin())
# grid_canopy is ok if point cloud is first cropped
lidR::grid_canopy(lidR::clip_roi(las_chablais3, raster::extent(output)), output, lidR::p2r())
# error in this case
lidR::grid_canopy(las_chablais3, output, lidR::p2r())
@Jean-Romain Jean-Romain self-assigned this Oct 1, 2021
@Jean-Romain
Copy link
Collaborator

To tell the truth I put this limit to be very sure to do no segfault. But I can remove the limitation that sometime annoy me too.

Jean-Romain added a commit that referenced this issue Oct 1, 2021
@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Oct 1, 2021

There we go. I removed this limitation. Let me now if it works as expected.

By the way I did not tag you in this discussion because your package is on the irstea's gitlab and did not know your name here. Please take note of what I wrote there. In practice it should not affect you but who knows... If you are using code like las@proj4string or lasctg@polygons[[1]]@area or writeRDS(las) please stop now and use dedicated functions

@Jean-Romain Jean-Romain added the Enhancement Not actually a bug but a possible improvement label Oct 3, 2021
@jmmonnet
Copy link
Author

jmmonnet commented Oct 11, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Not actually a bug but a possible improvement
Projects
None yet
Development

No branches or pull requests

2 participants