Open ianmseddy opened 3 months ago
Notice the filenames are the same.
> testOutput1 <- test(sa1, rtm1) #rerun it
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
this will not persist across R sessions.
Object to retrieve (fn: prepInputs, 7cd6911c99db678e.tif) ...
Loaded! Cached result from previous prepInputs call
> testOutput2 <- test(sa2, rtm2)
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
this will not persist across R sessions.
Object to retrieve (fn: prepInputs, 3b735d25a8d34c2d.tif) ...
Loaded! Cached result from previous prepInputs call
> terra::sources(testOutput2)
[1] "C:/Users/ieddy/AppData/Local/Temp/Rtmp0EIuZb/rawBiomassMap_foo.tif"
> terra::sources(testOutput1)
[1] "C:/Users/ieddy/AppData/Local/Temp/Rtmp0EIuZb/rawBiomassMap_foo.tif"
It's unclear to me what is the source of this error, and I can't reliably reproduce it. But I have done so in two different R sessions. Essentially, the LandR::prepRawBiomassMap function is retrieving the incorrect SpatRaster under conditions where the studyArea and rasterToMatch have the same CRS but different extent. I do not think it is related to the
if
statements, as I tried removing them to no avail. Below is a reprex (note you must run the function at least three times)