JoshOBrien / rasterDT

https://joshobrien.github.io/rasterDT/
27 stars 4 forks source link

Masking in subs dt #2

Closed mikoontz closed 4 years ago

mikoontz commented 4 years ago

Here is the patch I suggested in the Issue (https://github.com/JoshOBrien/rasterDT/issues/1). It doesn't appear to make the function less efficient, and it still works for multi-row dict objects when one of the rows specifies to replace a value to NA and another row specifies a replacement of a different original value for a non-NA.

One consideration I couldn't quite figure out is whether this patch requires more memory, which might mean that Line 61 where the raster::canProcessInMemory() function is run would need a different value for the n= argument (for instance, bumping its current value from 3 to 4 to reflect that another copy of the raster values is required to be held in RAM in order to process in memory.)

JoshOBrien commented 4 years ago

Closing with de8539319cdf1a4ee12d0dd5551fb2ec448e7a48 . To avoid the apparent speed hit of additional calls to [.data.table() and (when subsWithNA=TRUE) to is.na(), I applied a slightly different patch to fix the issue you raised.

Still, I'm intrigued that your approach was so much faster on your enormous raster. If you learn more about whether that was a real speedup, I'd be very interested to hear about it. Thanks again for your help.