Skip to main content
Question

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


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

takashi
Evangelist
  • 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
  • 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

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.


  • 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
  • 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
Evangelist
  • July 17, 2018
martino51 wrote:

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


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