Skip to main content
Question

Looking for the best way to calculate distances between 2 points of non-spatial data

  • October 3, 2017
  • 9 replies
  • 63 views

jah79
Participant
Forum|alt.badge.img+1

Hi

I am still new to FME and would like to find out the best/easiest/quickest way to calculate lengths of pipe sections. In this case the distance between S01 and F01 (3.8-0.6 = 3.2). The tricky bit is that there are sometimes more than 1 pipe section per Inspec_ID which need calculating, ie S02/F02, S03/F03 etc.

Thanks in advance

J

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.

9 replies

david_r
Celebrity
  • October 3, 2017
Would it be possible for you to post a small sample dataset? I'm sure it would be very helpful for those wanting to assist :-)

jah79
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • October 3, 2017
Would it be possible for you to post a small sample dataset? I'm sure it would be very helpful for those wanting to assist :-)
Sure, there you go @david_r

 

 

book1.xlsx

david_r
Celebrity
  • October 3, 2017

So I'm not sure if I understood exactly what you need, but here's a sample workspace that calculates distances between S01-F01, S02-F02, etc. Unfortunately it isn't trivial (if I've understood the requirements correctly), so I ended up with some Python to do the actual list calculations.

The section lengths are output in the list attributes lengths{}.distance and lengths{}.name

Output from the sample dataset:

`lengths{0}.distance' has value `3.1999999999999997'`lengths{0}.name' has value `S01-F01'`lengths{1}.distance' has value `85.3'`lengths{1}.name' has value `S02-F02'`lengths{2}.distance' has value `4.299999999999997'`lengths{2}.name' has value `S03-F03'`lengths{3}.distance' has value `5.200000000000003'`lengths{3}.name' has value `S04-F04'

section-lengths.fmwt

If you need one feature per section, use a ListExploder on lengths{}. You can then also use the AttributeRounder on the distance values, if needed.


Forum|alt.badge.img
  • October 3, 2017

Hi @johannhurter

thank you for the data sample. I think the workflow might be


takashi
Celebrity
  • October 3, 2017

Hi @johannhurter, using global variables for each interval might also be a solution, if it's guaranteed that "Fxx" appears always later than the "Sxx" containing the same xx (01, 02, ...).


jah79
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • October 4, 2017
Wow, thanks for all the amazingly quick and interesting replies! I've gone for the global variable solution for now and it's working well.

 

 

The next step is to look for areas where 2 pipe sections overlap, e.g. S01/F01 and S02/F02 running on the same section of pipe, and only counting the longest section. If anybody has a quick answer in the meantime feel free to shout ;)

 


takashi
Celebrity
  • October 4, 2017
I think global variables are still helpful in the next step. The attached workspace adds section ID and overlap count attribute to each row. Here, section ID is equal to the "cd" of starting row (i.e. S01, S02, ...), and if two or more sections overlaps in a row, their section ids will be concatenated into a single comma-separated string.

 

add-section-id-and-overlap-count.fmwt (FME 2017.1)

 

 


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • October 5, 2017

@johannhurter

to complete the set of possible solutions......;)


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • October 5, 2017

@johannhurter

then again...2 transformers seem enough..