Skip to main content
Solved

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


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

 

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.

View original
Did this help you find an answer to your question?

5 replies

Forum|alt.badge.img+2
  • 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+9
  • Author
  • Contributor
  • 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+9
  • Author
  • Contributor
  • March 13, 2020
markatsafe wrote:

@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+9
  • Author
  • Contributor
  • March 30, 2020
markatsafe wrote:

@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
ronnie.utter wrote:

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.


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