Skip to main content
Question

how to connect points from two different datasets with lines?


a_ericsson
Contributor
Forum|alt.badge.img+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

redgeographics
Celebrity
Forum|alt.badge.img+49

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.


nielsgerrits
VIP
Forum|alt.badge.img+54

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


a_ericsson
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • April 26, 2022
redgeographics wrote:

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?


redgeographics
Celebrity
Forum|alt.badge.img+49
a_ericsson wrote:

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.


Forum|alt.badge.img+2

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


a_ericsson
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • April 27, 2022
a_ericsson wrote:

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!


a_ericsson
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • April 27, 2022
markatsafe wrote:

@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! :)


a_ericsson
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • April 27, 2022
nielsgerrits wrote:

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


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