# How to generate random points with minimum distances between points in multiple polygons

I am looking to create random points for a random stratified survey. There are three different categories being surveyed; for each, I have a single shapefile, each containing a number of polygons.

I would like to generate a number (undetermined) of random points in each shapefile, with a minimum distance of 250m between points (regardless of what category/shapefile they are in). In other words, I would like there to be an equal number of random points in shapefile1, shapefile2, and shapefile3, with no point within 250m of another (i.e., a point in shapefile1 should not be within 250m of another point in shapefile1 or a point in shapefiles2 or 3). If possible, I would like to create the maximum number of random points possible given my minimum distance of 250m limitation.

So far, I have been able to generate random points (using ArcMap and qgis), however the minimum distance between points seems to apply only to points within each polygon, rather than all polygons in three different shapefiles.

• Perhaps union all the boundaries, dissolve all and create the random points using this as a constraint then select from those points whether they belong to 1, 2 or 3. Mod() operator will help here to split the points into the 3 classes. This is assuming you want the same density for all 3 feature classes. To get more control over the output then you will need to do some scripting. Jan 5, 2015 at 5:32

In ArcGIS, this can be done with Create random point if you have spatial analyst or 3D analyst or Advanced(ArcInfo) licence

select each shapefile as "constraining_feature_class" and set the "minimum_allowed_distance"to 250 m.

In QGIS, from what I know, you can use "Vector ‣ Research Tools ‣ Random points" with a constraining feature class, but not for distance. Again, you can use this tool in a loop to add points one by one until you reach the required number.

On the other hand, a solution for simple random sampling with distance contraint is to recursively add your random point and erase the buffer around your random point from the feature class until all your features are completely erased. As mentioned by @Whuber, this will not optimize the number of sample points, but you can control the number of points per strata.

Finally, the optimal number of points with a distance constraint can be achieved by systematic sampling : create a grid (with fishnet) with evenly spaced points (in your case 250 m) and randomly select a rotation angle and shift value betwen 0 and 250 in X and Y direction. This will optimize the number of point samples (and you could randomly subselect some points to reach a given number inside each startum). However, note that systematic sample could be biased because of the spatial autocorrelation.

• This solution will usually not create anywhere near the maximum possible number of points: it leaves lots of empty space that cannot be filled with any possible additional point. There is a fundamental difficulty with the question itself, too: it turns that that if one optimizes the number of points that can be created in this way, the configuration is far from random--and sometimes is completely determinate. Jan 11, 2016 at 0:01
• my recursive solution will finally cover all polygons. As I said, there is no such thing as the maximum value of this random process, but on average I don't see any random method that will put more points. Jan 11, 2016 at 8:18
• There is always an optimum, even though in practice it's hard to find. I estimate that it would typically include about twice as many points as your method. This problem might become easier to appreciate if you were to execute (manually) your algorithm in one dimension (for an interval). It would leave substantial gaps that could not be filled. Jan 11, 2016 at 13:26
• I don't understand what you mean by gaps. The process stops when all features are completely erased, which means that there are no gaps left if I work on one dimension. Jan 11, 2016 at 13:40
• Maybe I should have mentioned that new points can be anywhere on the remaining features (which can be smaller than the buffers, of course). At the end of the process, the distances between 2 points will range in [250,500], no more and no less. Jan 11, 2016 at 14:04