I'm trying to randomly select a number of points within my data frame (example data below) with a constraint that the minimum distance between the selected point must be greater than a certain distance. I managed to do the randomly selection bit using the sample
function in R, but I can't figure out how to add the constraint bit into my code. I suppose this must involve using some spatial analysis package in R but I haven't got a clue where to start.
I know ArcGIS has a tool called Create Random Points which can specify the minimum distance between points. But my situation requires a larger number of repeated sampling, thus making me feel doing this in R would be much easier because it can be incorporated with a loop.
Any suggestions are welcome.
Example data:
grid_index x y
grid_168 323012.5 674187.5
grid_169 323012.5 674212.5
grid_292 323037.5 672287.5
grid_293 323037.5 672312.5
grid_368 323037.5 674187.5
grid_369 323037.5 674212.5