distance function: add distance threshold above which return NA
Hi Robert/others,
For my specific current need I want the to append raster values to points, based on the nearest raster cell to each point. So first I ran terra::distance, which took ~48 hours (raster::gridDistance crashed).
Some thoughts (which I can put into separate issues if you want, LMK):
It would be great to have a parameter called (e.g.) threshold, whereby the user is saying "don't calculate/return values above a certain distance". I understand that conceptually this would require the whole raster worth of cells to be calculated first before the filter was then applied, saving no time, I wonder whether there'd be scope for some clever approaches e.g. batching the raster into blocks then sampling each block of 1000 pixels 10 times and if 0 of the samples were within the threshold, take no more samples. This likely has issues but just by way of an initial idea.
Progress bar: Is a nice addition, but initially confusing because it appears to start with a full bar, and then adds the parallel quarter segments underneath. Because distance is a clever generic function, one can't just punch it into the console with no brackets to see the underlying code and find out what progress function you're using, so it's somewhat a case of waiting hours/days and hoping it eventually works (which it did for me, yay). Possibly some kind of estimated countdown? I know countdowns are sometimes considered more coding trouble than they're worth, but for this usage case it should be somewhat a function of time taken for the first n pixels / total number of pixels?
Edit: and parallel would be lovely, to speed up distance per this note, and the general parallel thread I just added to also.
Thanks!
Simon