Sunday 15 November 2015

geojson - Show time series data with non-contiguous times using Leaflet TimeDimension plugin


My data is made up of squares forming a grid where the value of each square changes with time. The times are equally spaced with 1 hour intervals, however, the data is only available for a certain number of hours each day (daylight). The data covers 365 days of a year and the time is stored with each feature (perhaps an inefficient way to store the time data).


I have already managed to show the animation for the first day (linked question). However, when loading data for 2 days, the first day plays well but the player doesn't stop at the end of the data for that particular day and keeps incrementing the time where there is no data.


I have tried to use TimeDimension timeDimensionOptions: times but with lack of usage examples, I fear that I got the syntax wrong. Here is the JavaScript code.


What would be the way to visualize my data with non-contiguous times using Leaflet TimeDimension?



Answer




Solution is actually quite simple. When creating time dimension layer with L.timeDimension.layer.geoJson method, just set updateTimeDimensionMode option to 'replace':


var timeSeriesLayer = L.geoJSON(timeSeriesGeoJSON, {style: style});
var geojson = L.timeDimension.layer.geoJson(timeSeriesLayer, {updateTimeDimensionMode: 'replace'});
geojson.addTo(map);

Default value for this option is 'extremes', which means you get all the interval times between min and max time.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...