Question

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

  • 16 July 2018
  • 6 replies
  • 10 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


6 replies

Userlevel 2
Badge +17

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

Badge +3

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

Badge

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.

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

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.

Userlevel 2
Badge +17

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

 

Reply