Error with raster CHM for locate_trees() #541
-
Hello! I'm using lidR 4.0.0 on Windows. when giving a raster CHM (as a terra
I can't find the The raster has these attributes: class : SpatRaster
dimensions : 2125, 1668, 1 (nrow, ncol, nlyr)
resolution : 0.3, 0.3 (x, y)
extent : 601523.7, 602024.1, 4912952, 4913590 (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / UTM zone 54N (EPSG:32654)
source : jinjayama_chm.tif
name : jinjayama_chm
min value : -0.077
max value : 39.361 Any advice would be appreciated, thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Please report a minimal reproducible example. |
Beta Was this translation helpful? Give feedback.
-
Thank you for responding. library(lidR) # v 4.0.0
library(terra) # v 1.5-17
LASfile <- system.file("extdata", "Topography.laz", package="lidR")
las <- readLAS(LASfile)
dtm_tin <- rasterize_terrain(las, res = 1, algorithm = tin())
ncloud <- las - dtm_tin
chm <- rasterize_canopy(ncloud, res = 1, algorithm = p2r())
trees <- locate_trees(chm,lmf(ws =5)) # works as expected
## The error happens when the raster is loaded from disk.
writeRaster(chm, "testraster.tif")
chm_disk <- rast("testraster.tif")
locate_trees(chm_disk,lmf(ws =5))
# Error: On-disk rasters not supported without a bbox in 'raster_as_las()' |
Beta Was this translation helpful? Give feedback.
-
Thank you. The problem corresponds to the expected behavior but I do agree that the error is not the one that should be thrown to users. Something more informative should be displayed. The idea is that if your raster is not loaded in memory it means that it is too big to be loaded in memory. chm_disk <- rast("testraster.tif")
locate_trees(chm_disk,lmf(ws =5)) Looks perfectly fair but is understood by |
Beta Was this translation helpful? Give feedback.
-
The error is now
|
Beta Was this translation helpful? Give feedback.
-
If the raster is small enough it is loaded on the fly. Your example now works |
Beta Was this translation helpful? Give feedback.
If the raster is small enough it is loaded on the fly. Your example now works