Closed wiesehahn closed 2 years ago
Compared to raster
, terra
is somehow annoying with that because it never load a raster in memory and does not have a function to do it. The trick is to multiply by 1 to load in memory.
chm = chm*1
Another confusion was that I expected the ITS algorithm to return tree crowns as sf vector data
No, the algorithm is raster based. There is no reason to perform an additional vectorization step on the lidR side. This works that way since the very first version of lidR.
You can also use the set.values()
to load data into memory, but it is in-place without copying the object.
library("terra")
f = system.file("ex/elev.tif", package = "terra")
r = rast(f)
inMemory(r)
#> [1] FALSE
set.values(r)
inMemory(r)
#> [1] TRUE
thanks for your quick answers!
In the news for v4.0.1 it says that
now I guess I just ran into this problem: Trying to segment trees based on a CHM loaded with terra does not work, e.g.
results in
Error: Cannot segment the trees from a raster stored on disk. Use segment_trees() or load the raster in memory
But still I am not sure whats an efficient way to load the raster in memory. Maybe it would be nice to add this to the message.
Another confusion was that I expected the ITS algorithm to return tree crowns as sf vector data as is the case for treetop detection, but a raster was returned.