Solved

Group features by an ID and within 5 minutes of each other


I'm trying to figure out how to group features based on a matching ID value and only if they have a date/time within 5 minutes of each other. For example, if I have two traffic jam features that both have the same road ID (they occur on the same stretch of road), with one happening at 12:15 pm and the other happening at 12:18 pm, these features would be considered a match and their attributes would be combined (total delay time added together, etc.). If on the other hand one had been reported at 12:15 pm and the other was reported at 12:30 pm, they wouldn't be aggregated.

 

So far, I have tried using the Aggregator transformer but it's only able to group by attributes where the values are distinct which only works for the street ID part of my example and not the time part.

 

Any suggestions would be extremely helpful.

icon

Best answer by hkingsbury 12 May 2021, 02:43

View original

2 replies

Userlevel 5
Badge +29

Something i've had a good success with when deal with dates/times is to convert them all to epoch time, then use the epoch time in a vertexcreator as the x value and set the y value to '0' (replace current geom). Then you'll have a bunch of points to do spatial operations on.

Because epoch is in seconds, you can then use spatial operations to group based on a distance of 300 (5 minutes)

Userlevel 6
Badge +33

Something i've had a good success with when deal with dates/times is to convert them all to epoch time, then use the epoch time in a vertexcreator as the x value and set the y value to '0' (replace current geom). Then you'll have a bunch of points to do spatial operations on.

Because epoch is in seconds, you can then use spatial operations to group based on a distance of 300 (5 minutes)

Ha, nice one. Learned something new today.

Reply