-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add random sampling functionality (like R's terra::spatSample()
)
#771
Comments
No need for anything that complicated ;) StatsBase gives us the using StatsBase
sample(collect(skipmissing(raster)), 100) To keep the missing values, its just using StatsBase
sample(raster, 100) But you might want to use The key message here is unlike in R, a |
Thanks a lot for the quick response & detailed explanation! That is really helpful. That is a very nice solution for sampling values--but I was really hoping to sample both coordinates and values for non-NA cells, hence the use of |
It's probably no problem to convert, it's just
Then probably |
Fantastic - thank you! |
I've been thinking about adding some sample function that mirrors syntax and outputs generated by |
This is now possible by calling |
Thanks for a great package! This is a feature request for a function like R’s
terra::spatSample()
that enables random sampling of locations on a raster, optionally excluding NaN/missing values. Below is some quick-and-dirty example code which demonstrates the functionality, but is inefficient when NaNs should be ignored. Maybe this is already quick & easy to do in Julia? (I am coming from R.)The text was updated successfully, but these errors were encountered: