Question

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

  • 4 March 2019
  • 4 replies
  • 25 views

Badge +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

Userlevel 4
Badge +30

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

 

Userlevel 2
Badge +17

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.
Badge +10

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.

Badge +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

Reply