2

How to generate random circles with certain radius size that do not overlap, inside a polygon?

4
  • Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works. Thanks.
    – PolyGeo
    Commented Oct 10, 2021 at 23:52
  • 1
    Create random points in polygon and set a minimum distance.
    – Babel
    Commented Oct 11, 2021 at 6:23
  • 1
    @Babel: then do a buffer and select the circles that are entirely within the polygon. Commented Oct 11, 2021 at 7:33
  • Please, do not forget about "What should I do when someone answers my question?"
    – Taras
    Commented Dec 2, 2022 at 19:47

2 Answers 2

2

enter image description here

  1. Create an image with a cell size equal to the circle radius.
  2. Create an empty point vector file with the required CRS (the same as the CRS of the image).
  3. Use the r.random tool located in the GRASS toolbox.
  4. Use the buffer tool with the distance value equal to the image cell size.
  5. Use select by location tool to select all circles that lays within your polygon.
  6. Inverse selection and delete all circles that lays outside of the polygon.
2

In this solution : circles won't overlap but they can touch

Let's assume there is a polygon layer called 'poly_test' with several features in it, see image below.

input

Step 1. Firstly make use of the "Create grid" geoalgorithm

Please, keep in mind: Horizontal spacing = Vertical spacing = 2 * of the certain radius. So the radius of a circle in this example will be 10000/2 = 5000, that be later proved with this expression :

distance(centroid($geometry), point_on_surface(boundary($geometry)))

window1

step1

Step 2. Use the "Extract by location" geoalgorithm with 'are within' geometrical predicate

window2

step2

Step 3. Proceed with the "Geometry by expression" geoalgorithm

make_circle(centroid($geometry), distance(centroid($geometry), point_on_surface(boundary($geometry)))/sqrt(2), 36)

window3

step3

Step 4. On the last stage apply the "Random extract" geoalgorithm

window4

and get the output like this :

step4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.