# Create Random Points with based on Attributes values in FME

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.

• FME Hub RandomPointGenerator hub.safe.com/transformers/randompointgenerator and groupby 'Block'
– Mapperz
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
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
Oct 11, 2017 at 1:53

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.

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.

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.

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

And the VertexCreator parameters will just be as follows:

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

## Output:

You can further process the output if required.

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.