Question

how to connect points from two different datasets with lines?

  • 26 April 2022
  • 8 replies
  • 63 views

Badge +3

Hi! 

I'm trying to connect points to each other using lines. The points are in two seperate postGIS datasets, but have an ID-value in common. So I would need help to join points based on a common field / attribute. Does anyone know how to do this?

 

I have successfully done this in QGIS using the Hublines tool.

https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectoranalysis.html#qgishublines


8 replies

Userlevel 5
Badge +25

There's a couple ways of doing this. One would be to use a CoordinateExtractor on one of the two sets to store the coordinates of the points in attributes. Then a FeatureMerger with that set as the Supplier and the other set as the Requestors. Join on the ID they have in common and have it merge attributes only. So you'll end up with the points from the Requestor set that have received the attributes with coordinates from the Supplier set.

 

Then run them through a VertexCreator, set its mode to Add Point and the X/Y (and Z) values taken from the attributes.

Userlevel 6
Badge +33

Another way to do this is to feed both tables to a LineBuilder transformer. Set it to group by the common id attribute.

Badge +3

There's a couple ways of doing this. One would be to use a CoordinateExtractor on one of the two sets to store the coordinates of the points in attributes. Then a FeatureMerger with that set as the Supplier and the other set as the Requestors. Join on the ID they have in common and have it merge attributes only. So you'll end up with the points from the Requestor set that have received the attributes with coordinates from the Supplier set.

 

Then run them through a VertexCreator, set its mode to Add Point and the X/Y (and Z) values taken from the attributes.

Thanks! The result I'm after is a new dataset consisting of lines, connecting points from the different datasets. The VertexCreator returns a dataset of points, but how do I use these points to generate a line between them?

Userlevel 5
Badge +25

Thanks! The result I'm after is a new dataset consisting of lines, connecting points from the different datasets. The VertexCreator returns a dataset of points, but how do I use these points to generate a line between them?

If you set the mode of the VertexCreator to "Add point" rather than the default "Replace with point" it should create a line from the original point to the one specified in the coordinate attributes.

Badge +2

@a_ericsson​ FeatureMerger has a little know (or used) function that will allow you to build the line from points.image

Badge +3

Thanks! The result I'm after is a new dataset consisting of lines, connecting points from the different datasets. The VertexCreator returns a dataset of points, but how do I use these points to generate a line between them?

Great, thanks!

Badge +3

@a_ericsson​ FeatureMerger has a little know (or used) function that will allow you to build the line from points.image

Cool, thanks a lot! :)

Badge +3

Another way to do this is to feed both tables to a LineBuilder transformer. Set it to group by the common id attribute.

Thanks!

Reply