>
> >From the base::sample analogy, I would have expected a random
> permutation, so IMO it would make sense to document this is not the case
> (the function is not called sample, anyway -- question are: what would
> the random permutation be good for? and would it still perform well when
> the image is huge?)

That's the point of using sampleRandom : It still perform well with large
rasters. Especially if you want to na.rm = TRUE.
With Robert precision added:

> (i.e. random cells in random order), except when the sample size 's' is >
> 0.5 * ncells(raster)
>
One (I) can easily add sample(sampleRandom()) for cases where  random order
is needed and keep reasonable speed.
Using sample directly is just too slow for large rasters...
sample_raster <- function(r, size, ...){
x <- cbind(1:ncell(r), getValues(r))
x <- na.omit(x)
sample(x[, -1], size, ...)
}

Etienne

	[[alternative HTML version deleted]]

