I have a shapefile with a lot of polygons, representing events occuring for a given year. Every area can be covered several times, for every year it occured on the same coverage. Each polygon is characterized by a certain quantity (ie. number of hosues builded).

I generate random points within thoses polygons to show the amount of this quantity (with the toolbox). By doing this, I'm loosing all the fields of the polygon, and am not able to categorize the points according to the year they're referring to. It's not possible to perform a spatial join because of the overlapping polygons.

The answer to this question (How to create random points in overlapping polygons?) won't work because I'm not using fixed points generation.

So how can I generate random points within polygons and keep all the fields of the polygons the points are referring to?

  • 1
    How many different years are there? Is it feasible to split your polygon layer by that attribute and create the random points as a batch process, then re-merge the point layer?
    – jcarlson
    Feb 27, 2018 at 16:58
  • 1
    There are 17 years. Indeed I could use this workaround! Feb 28, 2018 at 10:19
  • I'll post it as an answer, but I'm gonna keep thinking about other solutions.
    – jcarlson
    Feb 28, 2018 at 11:03

1 Answer 1


One method of accomplishing this is to split the polygon layer and run your points as a batch process.

  1. Starting with a layer of overlapping polygons, run Split vector layer, using year field to split it.

overlapping polygons layer and table

  1. Run Random points inside polygons as a batch process, selecting the newly-created vector layers.
  2. Run Join attributes by location as a batch process, matching each point_year_num with the accompanying year_layer.
  3. Run Merge vector layers, selecting the joined layers from the output. You should be left with a layer of points, with an attribute table like below:

table post merge

It is an inelegant solution to be sure, but will accomplish the task. Much of it could be built into a model to save you from cluttering your layers panel with useless output.

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.