1

I have 6 Polygons in one shapefile with attributes Block A to Block F.

Also, I have one Excel file for materials location like shown below screenshot.

My aim is to create a random point within the polygon as per the values mentioned in the table.

For Example:

121 Sand Random points for Block A polygon

6182 Sand Random points for Block B polygon

1 Cement Random points for Block A polygon

210 Cement Random points for Block B polygon

All points if possible one single shp file. enter image description here

3
  • 1
    FME Hub RandomPointGenerator hub.safe.com/transformers/randompointgenerator and groupby 'Block'
    – Mapperz
    Commented Oct 10, 2017 at 14:46
  • @Mapperz, RandomPointGenerator won't allow attributes to drive the number of points. I suppose you could use a workspace runner and pass it to the parameter...
    – Fezter
    Commented Oct 10, 2017 at 23:42
  • The only issue is cement (block e) and steel blocks (a,c,d,f) will have zero random points. you can filter the number of points inside the polygon with the option If you specified the "Group By" parameter, this parameter means the number of points per a group.
    – Mapperz
    Commented Oct 11, 2017 at 1:53

1 Answer 1

1

There are several ways you can do this. This is the the first thing I came up with, there are likely more efficient methods to employ, but I don't have much time now.

I'll start with a screenshot of the workbench and explain it below.

enter image description here

Firstly, read the Excel file, and push the output the 6 Cloners (one for each block). The number of copies in the cloner will be the attribute for each block. For example, the first cloner will be for Block A. The second will be for Block B, and so on.

enter image description here

Next, I created a custom transformer called "random point maker" which generates a random number for the x-coordinate and a random number for the y-coordinate and makes a point from it. For that, there are two random number generators and a vertex creator.

enter image description here

The minimum and maximum values of your random numbers will depend on your coordinate system and your particular project.

enter image description here

And the VertexCreator parameters will just be as follows:

enter image description here

Finally, just pass the output to an AttributeFilter to filter out all the different materials.

enter image description here

Output:

You can further process the output if required.

enter image description here

EDIT:

I realised that I failed to read the part of your question that it needed to be within the polygon. For that, as suggested by @Mapperz, you should use the RandomPointGenerator which will constrain the random point within the polygon.

The issue is that the RandomPointGenerator doesn't actually support attributes for number of points. Instead, it accepts parameters. So, for that, I suggest creating a second workbench which runs the RandomPointGenerator and then use a WorkspaceRunner to pass the attribute as a parameter to that workbench.

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.