2

I have a number of polygons with an integer value in a field. I would like to create N number of centroid points for each polygon where N corresponds to the value in the polygon's field.

So sort of like Random Points in Polygon, but centroids instead of Random.

I've done it before by generating random points, adding the centroid X and Y as a attributes to the source polygon and then rejoining the points with the source polygon's fields with Join By Location. And then replacing the geometry in the random points with the source polygon's centroid X and Y.

But this feels suuuper clunky.

So is there some easy way to accomplish the same thing? Maybe some succinct SQL for Virtual Layers? Or clever Geometry Generator snippet for the polygon layer (generating new data is not necessary)?

2
  • So, you want overlapping geometries? Why not simply add the number to the centroids?
    – Erik
    Feb 4, 2020 at 12:50
  • @Erik In this case, I want overlapping geometries (ie. duplicate points.)
    – hexamon
    Feb 4, 2020 at 12:53

1 Answer 1

2

Uh, there actually is a tool you can "abuse" to create what you'd like:

array translated features - you can search for it in the toolbox.

You give the tool any feature layer, tell it how many copies you'd like to create (which can be set based on the attribute table) and how far you want to translate each copied feature (in your case 0).


Either do this before creating centroids, or then duplicate your centroids if they have the correct attribute attached.

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.