Skip to main content
Question

How can a write an attribute from the first feature to every other feature?

  • July 16, 2018
  • 6 replies
  • 97 views

I have gps points, each with a creation_time attribute. I would like calculate the elapsed time for each point using the creation_time of the first point as the start_time.

My thoughts are to write the start_time to each feature and use DateTimeCalculator.

Any ideas how I can select the creation_time from feature 1 and write it to all other features as start_time?

If there is a better, I would love to here it.

regards

Martin

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.

6 replies

takashi
Celebrity
  • 7843 replies
  • July 16, 2018

Hi @martino51, I think this is a case where a global variable can be used effectively.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • 2252 replies
  • July 16, 2018

@martino51

Variable setter/retriever is usually my preffred one too but..one has to hope the retriever does not pre-empt the setter..wich often makes me revert to simply

unconditionally feature merging the sampled value to the non sampled. ( sampler and a FeatureMerger)


Forum|alt.badge.img
  • 275 replies
  • July 16, 2018

Hi @martino51

you could also use Adjacent Features in AttributeCreator. Combined with Conditional Value, this functionality will allow you to pass the first point start_time onto all other points:

As a matter of fact, you could also calculate the time difference using @DateTimeDiff() function in your expression.


  • 1 reply
  • July 16, 2018

Hi @martino51

try, complete and modify

attached workbench

gps-elapsed-time-from-first-point-2-all-other-poin.fmwgps-elapsed-time-from-first-point-2-all-other-poin.png


  • Author
  • 1 reply
  • July 17, 2018

Thank you to all for your suggestions. I used @takashi's and @gio's suggestions of a global variable using the VariableSetter and VariableRetriever. This is what I was looking for but didn't know how to do it in FME. Many thanks to the FME community for your support.


takashi
Celebrity
  • 7843 replies
  • July 17, 2018

Thank you to all for your suggestions. I used @takashi's and @gio's suggestions of a global variable using the VariableSetter and VariableRetriever. This is what I was looking for but didn't know how to do it in FME. Many thanks to the FME community for your support.

0684Q00000ArK3NQAV.png

Good to hear.

 

I found another solution. The StatisticsCalculater can also be used to calculate elapsed time (seconds) since the first point.

 

Expression for calculating time interval (seconds) between two adjacent records (assuming that "creation_t" is formatted with standard FME date/time format)

 

@DateTimeDiff(@Value(creation_t),@Value(feature[-1].creation_t),seconds)

0684Q00000ArMCxQAN.png