I have a GeoJSON file with time series data, representing repeating polygons with varying data. I have managed to display the data for one time interval (a subset of the data representing one interval) using Leaflet but have so far failed to animate the data using the Leaflet Timedimension plugin (I tried with a subset representing 2 intervals). My data is repeating every one hour, the geometry is the same while the attribute value is changing every hour. I keep getting "Time not available" on the plugin control.
My data has an attribute field called time and the date is in this format:
"time": "2006-03-11 09:00:00"
This is one feature from the GeoJSON data:
{ "type": "Feature", "id": -1549271008, "properties": { "id": 827793, "time": "2006-03-11 08:00:00", "insol": 61.73542 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 39.151222675648221, 34.199670805202523 ], [ 39.151222675712766, 34.199675276071595 ], [ 39.151228272367668, 34.199675276015682 ], [ 39.151228272302838, 34.199670805146624 ], [ 39.151222675648221, 34.199670805202523 ] ] ] } }
I have loaded the relevant js libraries for TimeDimension to work (plus the CSS):
<script type="text/javascript" src="https://cdn.rawgit.com/nezasa/iso8601-js-period/master/iso8601.min.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/socib/Leaflet.TimeDimension/master/dist/leaflet.timedimension.min.js"></script>
The JavaScript code is at JSFiddle
I'm not sure if the time format is wrong or if I simply have the wrong code for loading the data using the TimeDimension plugin. I have looked through the examples and elsewhere but didn't see something that resembles my case.
So what is the correct way to load a GeoJSON polygon dataset with hourly interval repeating geometry using the Leaflet TimeDimension plugin?
Best Answer
You guessed right, time format is wrong. In Leaflet TimeDimension plugin time is parsed with Java Script function
Date.parse(dateTime)
. This function accepts date/time strings in IETF RFC 2822 format or Ecma-262 5.1 format.The right format for your time would then be
2006/03/11 09:00:00
or2006-03-11T09:00:00
.EDIT: From your comment below I understand you are loading GeoJSON layer as GeoJSON object. Parameter
layer
inL.timeDimension.layer.geoJson(layer)
has to be Leaflet layer. You first have to load GeoJSON as Leaflet layer and then use it inL.timeDimension.layer.geoJson
call.This code worked for me: