Question

Random points on lines in FME?

  • 20 January 2022
  • 4 replies
  • 17 views

Badge +14
  • Contributor
  • 120 replies

In QGIS there is a useful tool that generates Random points on lines. It snaps the points to the lines whilst keeping an even spacing between all points. It also has a setting of points per line.

Any ideas on how to achieve the same result in FME?

 

Description of the function in QGIS:

This algorithm creates a point layer, with points placed randomly on the lines of the Input line layer. The default behaviour is that the generated point features inherit the attributes of the line feature on which they were was generated.

Parameters / options:

  • For each feature in the Input line layer, the algorithm attempts to add the specified Number of points for each feature to the output layer.
  • A Minimum distance between points and a Global minimum distance between points can be specified. A point will not be added if there is an already generated point within this (Euclidean) distance from the generated location. With Minimum distance between points, only points on the same line feature are considered, while for Global minimum distance between points all previously generated points are considered. If the Global minimum distance between points is set larger than the (local) Minimum distance between points, the latter has no effect.
  • If the Minimum distance between points is too large, it may not be possible to generate the specified Number of points for each feature.
  • The Maximum number of attempts per point is only relevant if Minimum distance between points or Global minimum distance between points is greater than 0. The total number of points will be
  • number of input features * Number of points for each feature
  • if there are no misses and all features have proper geometries.
  • The seed for the random generator can be provided (Random seed - integer, greater than 0).
  • The user can choose not to Include line feature attributes in the generated point features.

4 replies

Userlevel 4

It's not quite the same, but there is the Densifier to add vertices to a line geometry. You can then use a Chopper to split the vertices to points.

There's also the RandomPointGenerator on the FME Hub that might be used for inspiration in case you have to develop your own custom transformer.

Userlevel 2
Badge +17

Hi @aron​ , ​may not be exactly the same function as QGIS, but this workflow illustrates the basic concept of a possible way, I think.

ramdom-points-on-line-exampleresult

Badge +14

The tricky bit is how to space the points evenly. Is there a transformer that can lay out points in a matrix? Say every NN x NN meters? If so an AnchoredSnapper could be used to pull points onto the lines, given a set distance, and those that are to far away to be moved could be discarded.

Badge +4

Hi @aron​ ,

 

maybe the attached workspace could help you. It asks the user to specify a number of points and then calculates an even space distribution by dividing 100 for the number of points and then multiplying for a numeric unique counter (the _copynum attribute in this case).

 

Thanks to @Takashi Iijima​ for the main idea!

 

Reply