Skip to main content
Question

How to construct lines from one dataset of points and one dataset of pairs


nicholas
Contributor
Forum|alt.badge.img+10

I have two tables.

One is a dataset of points, each point has a unique ID

The other is a (attribute only) dataset of pairs, each record refers to two points, via their unique ID

How do I construct a feature dataset of lines? Each line consisting of two points.

 

To re-phrase, how do I add line geometry to the dataset of pairs, using the appropriate points from the point dataset, based on the unique ID of the from and to points?

4 replies

danilo_fme
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • March 3, 2019

Hi @nicholas

I suggest you to use the transformer FeatureMerger - to find the relation between the two datasets by ID.

 

After the use the transformer LineBuilder.

Thanks,

Danilo

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • March 4, 2019

A possibly way I can think of is:

  1. Merge the first point geometry to the features containing pair of IDs, with a FeatureMerger (Join On: ID of the first point, Feature Merge Type: Geometry).
  2. Extract coordinates (x, y) from the original point geometries with the CoordinateExtractor (Mode: Specify Coordinate, Coordinate Index: 0), and merge the (x, y) to the features output from the Merged port of the first FeatureMerger, with another FeatureMerger (Join On: ID of the second point, Feature Merge Type: Attributes Only).
  3. Use the VertexCreator (Mode: Add Point) to add the second point to the features output from the Merged port of the second FeatureMerger.

nicholas
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • March 4, 2019
takashi wrote:

A possibly way I can think of is:

  1. Merge the first point geometry to the features containing pair of IDs, with a FeatureMerger (Join On: ID of the first point, Feature Merge Type: Geometry).
  2. Extract coordinates (x, y) from the original point geometries with the CoordinateExtractor (Mode: Specify Coordinate, Coordinate Index: 0), and merge the (x, y) to the features output from the Merged port of the first FeatureMerger, with another FeatureMerger (Join On: ID of the second point, Feature Merge Type: Attributes Only).
  3. Use the VertexCreator (Mode: Add Point) to add the second point to the features output from the Merged port of the second FeatureMerger.

I have done exactly that.

It works, but it seems not elegant.

I was hoping that there was a way to merge the geometries directly without converting the points from geometry to coordinate values and back to geometry again.


Forum|alt.badge.img+2

@nicholas I think I would go with @takashi 's approach - it would be much clearer for others to understand the workflow - even if it does require extracting the coordinates. However, there is an obscure part of the FeatureMerger functionality that can build geometries: Geometry Merge Type: Build Lines From Points. I've never used this before so thought this might be an excuse to try that. Here is the result:

 

Here's the workspace (2018.1): createlinesfromnodes.fmwt

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings