Closed Hannes-Ole closed 2 years ago
C++ unexpected internal error in 'rasterize': point out of raster.
This problem has been fixed in https://github.com/r-lidar/lidR/issues/483 and released in 3.2.2. Which version are you using?
t can be argued that it makes sense, that the user gets as chm the full extent of the "extended" point cloud - although having a larger output extent than input extent may still be surprising to some.
I do agree and this is something I was thinking about for a while. I removed this in v4. The extent of the point cloud is now fixed and is not affected by the subcircle tweak
grid_metrics(~max(Z)) basically equivalent to grid_canopy(p2r())
Yes, but ten times slower approximately.
I suggest having a p2r optional parameter cropToInputExtent = TRUE
I think that do not extending the raster is simpler, more consistent and more logic.
You are right, I was working on a server where still lidR 3.2.1 was installed, so this is obsolete then. I also agree that not extending the raster is consistent and the optional extension isn't really necessary. Thank you!
When using grid_canopy(), the output is dependend on the subcircle tweak used in
p2r()
. This makes sense, since after "expanding" each point to a disk, the extent of the point cloud is larger - it can be argued that it makes sense, that the user gets as chm the full extent of the "extended" point cloud - although having a larger output extent than input extent may still be surprising to some.However the algorithm breaks when using a reference raster to determine alignment/resolution, and I think that shouldn't happen (I'd rather get the "cropped" chm). Here is a code example, if it isn't reproducible on your data I can send you some:
Calling the following causes the error:
Here we see, what the algorithm would like to output, without being restricted by an extent:
When using
grid_metrics
or settingp2r(subcircle = 0)
, which is the default, it works without complaints. A side question: Is grid_metrics(~max(Z)) basically equivalent togrid_canopy(p2r())
?Also the pitfree algorithm apparently has a crop back to the original extent implemented, as
grid_canopy(pitfree(subcircle > 0))
also works fine:I suggest having a p2r optional parameter
cropToInputExtent = TRUE
(you may have a more concise name for it ;] ), that allows for extension by the subcircle tweak, but defaults toextent(input) = extent(output)
[as generally may be expected and allows for usage of a reference rastergrid_canopy(las, res=raster(extent(las), res=1), p2r(0.5))
].