How to synchronize Timestamps

Learn how to synchronize timestamps of two Geo Time Series and copy the locations from one to the other.

Thinking in WarpScript #13: Time synchronization

Imagine that we have a reference series without geolocation (called "reference") and a second series with geolocalized data (called "dummy").

We would like to copy the location of datapoints of the second series to the reference series, but there is no timestamps in common.

In fact, I encountered this use case and the Javascript implementation took dozens lines of code. Of course you can do that easily with WarpScript with just (Spoil Alert) a single line of code.

Random data generation

At first, for this blog post, we will generate random data:

NEWGTS 'reference' RENAME
1 10 <% 
  'index' STORE
  NOW RAND 100 * STU * - TOLONG // timestamp
  NaN NaN NaN // lat long elevation
  $index TOSTRING // value
%> FOR 'reference' STORE
1 100 <% 
  'index' STORE
  NOW RAND 100 * STU * - TOLONG // timestamp
  48.2 RAND + -4.3 RAND + NaN // lat long elevation
  $index // value
%> FOR  'dummy' STORE

The algorithm

The data process consists on:

  • Fill the "dummy " GTS with timestamps coming from the "reference" GTS
  • Interpolate values and locations for those new datapoints
  • Copy the geolocation from "dummy" to "reference"
$reference $dummy filler.interpolate FILL COPYGEO

That's all.

Final result: the timestamps on a map

To sum up, the full code sample is here:

More info about:

filler.interpolate, FILL, COPYGEO