Closed ouroukhai closed 9 months ago
I suggest that your function funlas
get a serialized SpatRaster
as input and unserialize it on the fly. Look at terra::serialize()
and terra::unserialize()
. You can also use raster
. RasterLayer
are serializable
UPDATE: I read that SpatRaster objects can not be used in parallel. In my pipeline, I used parallel programming, so some of the problems might occur there. Nevertheless, a suggestion on how to handle a similar situation would be really helpful.
Hello lidR team, And thank you for the excellent package!
I am currently working on a problem for which I want to use raster data (specifically a DTM) in a user-specified function in a
pixel_metric()
operation. Ideally, I want to be able to write something like this (given thatctg
anddtm
are defined):where
When I tried the naive approach of using the DTM immediately, I get error: "external pointer is not valid". I tried also to use
merge_spatial()
viacatalog_map()
, but got errors, probably data-specific ones. Is there a suggested method to do such a calculation? My current approach is to write a cropped version (to thelas
coordinates) of the raster file into a temporary folder and then read it each time, withrast()
in thefun()
, but it feels too artificial and slow.