nearest distance in matrix
Dear Barry,
The code used by Adrian Baddeley's spatstat routine uses a very neat method for working out the distances, which involves sweeping along rows and columns or something. He did explain it to me when I was in Perth but I can't recall it now!
I knew there should be way to do it without estimating the full distance redistribution matrix O((nrow(mat)*ncol(mat))^2) because the equivalent AV Spatial analyst can do rather big raster (3000 x 3000 pixels) in a few seconds.
Anyway, its super-quick and uses next-to-no memory. Here's how long my function that calls the spatstat routine takes:
It is super quick indeed, I tested it on a 1600 x 250 matrix, ang got the output 1600x250 distance matrix in less than 5 seconds on a PIV 1700 Mhz, so fairly efficient indeed, Many thanks, there's no I could have found this myself, Cheers, Marius