Skip to main content
Solved

Connect all areas with the shortest line. If area amount is X then line amount should be X-1

  • March 12, 2020
  • 5 replies
  • 23 views

ronnie.utter
Contributor
Forum|alt.badge.img+11

 

I have a set of areas. And all neighbours should be connected with a line. If I have 10 areas they should be connected with 9 lines to connect them all. I have tried to explain in detail with the attached pdf and in annotations in my workspace.

 

I have a solution but its not the best solution and could probably be edited to something better. For small amount of data it works. But for large its a heavy process.

 

 

The end result should look something like the images below

 

Alla areas are connected

 

 

 

 

Alla areas are connected

 

 

And there are 1 less line then there is areas

 

 

 

 

 

Best answer by markatsafe

@ronnieutter That's an interesting problem. Thanks for including the clear description of what you're trying to accomplish and the sample dataset.

There's usually several ways to solve a problem in FME. I've taken a completely different approach so hopefully you can borrow one or two thoughts from that.

  • Areas: to build the areas I tried HullAccumulator with concave hulls. This seems to build the areas OK for the sample data.
  • Network: I tried joining all the areas (center points) to all other areas (full outer joiner). Then merge the lines by area id and find the line with the shortest length. That seems to give a reasonable network

Attached is the workspace (FME 2019.2): join_areas2.fmwt

Still have to snap the lines to the original network points. I think you could do that by clipping the lines to the areas and then AnchorSnapper to the nearest network point.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

Forum|alt.badge.img+2
  • 1891 replies
  • Best Answer
  • March 12, 2020

@ronnieutter That's an interesting problem. Thanks for including the clear description of what you're trying to accomplish and the sample dataset.

There's usually several ways to solve a problem in FME. I've taken a completely different approach so hopefully you can borrow one or two thoughts from that.

  • Areas: to build the areas I tried HullAccumulator with concave hulls. This seems to build the areas OK for the sample data.
  • Network: I tried joining all the areas (center points) to all other areas (full outer joiner). Then merge the lines by area id and find the line with the shortest length. That seems to give a reasonable network

Attached is the workspace (FME 2019.2): join_areas2.fmwt

Still have to snap the lines to the original network points. I think you could do that by clipping the lines to the areas and then AnchorSnapper to the nearest network point.


ronnie.utter
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 37 replies
  • March 12, 2020

Thank you @markatsafe for your answer. I am eager to try your solution you are describing using full join and choose the shortest line tomorrow. :)

 


ronnie.utter
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 37 replies
  • March 13, 2020

@ronnieutter That's an interesting problem. Thanks for including the clear description of what you're trying to accomplish and the sample dataset.

There's usually several ways to solve a problem in FME. I've taken a completely different approach so hopefully you can borrow one or two thoughts from that.

  • Areas: to build the areas I tried HullAccumulator with concave hulls. This seems to build the areas OK for the sample data.
  • Network: I tried joining all the areas (center points) to all other areas (full outer joiner). Then merge the lines by area id and find the line with the shortest length. That seems to give a reasonable network

Attached is the workspace (FME 2019.2): join_areas2.fmwt

Still have to snap the lines to the original network points. I think you could do that by clipping the lines to the areas and then AnchorSnapper to the nearest network point.

Thank you @markatsafe for your alternative way to calculate the lines. I have learn more to test and look at your script and am sure that some of the logic can be applied in my script. I will try to experiment more with lists and joins. I think thats the best way to slim the process instead of alot of buffers and dissolves. Thank you for your time and to have shared an alternative logic.


ronnie.utter
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 37 replies
  • March 30, 2020

@ronnieutter That's an interesting problem. Thanks for including the clear description of what you're trying to accomplish and the sample dataset.

There's usually several ways to solve a problem in FME. I've taken a completely different approach so hopefully you can borrow one or two thoughts from that.

  • Areas: to build the areas I tried HullAccumulator with concave hulls. This seems to build the areas OK for the sample data.
  • Network: I tried joining all the areas (center points) to all other areas (full outer joiner). Then merge the lines by area id and find the line with the shortest length. That seems to give a reasonable network

Attached is the workspace (FME 2019.2): join_areas2.fmwt

Still have to snap the lines to the original network points. I think you could do that by clipping the lines to the areas and then AnchorSnapper to the nearest network point.

Hello again @markatsafe Sorry for my late answer. I have now tested your example and its a smart solution that will work for my idea. I understand its a prototype so some parts still need further development to match the rest of my logik.. But your example is really smart and I will apply a modifed version of it. Thank you for your time


Forum|alt.badge.img+2
  • 1891 replies
  • March 30, 2020

Hello again @markatsafe Sorry for my late answer. I have now tested your example and its a smart solution that will work for my idea. I understand its a prototype so some parts still need further development to match the rest of my logik.. But your example is really smart and I will apply a modifed version of it. Thank you for your time

@ronnieutter Great. Thanks for letting me know that some of this was useful. Hopefully the rest of your project goes well.