I have a complicated shapefile of overlapping polygons. I need to generate random points inside each polygon, which is easily accomplished using Vector -> Research Tools -> Random Points Inside Polygons, but this obliterates the attribute table of the generated point shapefile which is not okay. Under more simple conditions, I could use NNJoin to rejoin the attributes, but because of the multiple overlapping polygons this is not acceptable as I cannot be sure the nearest polygon is actually the correct source of data. Can anyone suggest a method to generate a single random point in each polygon that has a 1:1 (ie., perfect) transfer of the attributes from the polygon to the random point, for each polygon?


I've made a PR to support your requirement at https://github.com/qgis/QGIS/pull/36479

You can take the file RandomPointsPolygons.py from the PR and replace the one on your machine with the same name (make a copy before, to be safe). Then, restart QGIS and it should do what you want.

  • Wow! Thanks so much for this! Does this mean it might eventually make its way into QGIS' native feature set? – Meander Photography May 16 '20 at 17:32
  • It should if PR is accepted: waiting for QGIS devs feedback – ThomasG77 May 16 '20 at 17:37
  • Amazing. Thanks so much, Thomas. Open source GIS forever! – Meander Photography May 16 '20 at 17:38
  • @MeanderPhotography Please accept this answer if it solves your problem. – underdark Jul 29 '20 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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