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?
-
1How 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– jcarlson2018年02月27日 16:58:45 +00:00Commented Feb 27, 2018 at 16:58
-
1There are 17 years. Indeed I could use this workaround!mamouthautapis– mamouthautapis2018年02月28日 10:19:57 +00:00Commented Feb 28, 2018 at 10:19
-
I'll post it as an answer, but I'm gonna keep thinking about other solutions.jcarlson– jcarlson2018年02月28日 11:03:31 +00:00Commented 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.
- Starting with a layer of overlapping polygons, run Split vector layer, using
year
field to split it.
overlapping polygons layer and table
- Run Random points inside polygons as a batch process, selecting the newly-created vector layers.
- Run Join attributes by location as a batch process, matching each
point_year_num
with the accompanyingyear_layer
. - 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:
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.