As the timeline increments, instead of following the dates values which are on day 1 of each month, the timeline moves from 11/1 to 11/30 and continues "off" the programmed dates until we hit 4/1/24.
I tried times in place of dates, no change.
Reason I'm doing this is the project I'm working on will be plotting many LineStrings and I need to show changes in [various parameters] month to month, always on day 1.
import folium
from folium.plugins import TimestampedGeoJson
def create_geojson() -> dict:
lines: list = [
{"coordinates": [[139.76451, 35.68159],[139.75964, 35.68259]],
"dates": ["2017-09-01T00:00:00", "2017-10-01T00:00:00"]},
{"coordinates": [[139.76451, 35.68159],[139.75964, 35.68259]],
"dates": ["2017-10-01T00:00:00", "2017-11-01T00:00:00"]},
{"coordinates": [[139.76451, 35.68159],[139.75964, 35.68259]],
"dates": ["2017-11-01T00:00:00", "2017-12-01T00:00:00"]},
{"coordinates": [[139.76451, 35.68159],[139.75964, 35.68259]],
"dates": ["2017-12-01T00:00:00", "2018-01-01T00:00:00"]},
{"coordinates": [[139.76451, 35.68159],[139.75964, 35.68259]],
"dates": ["2018-01-01T00:00:00", "2018-02-01T00:00:00"]},
{"coordinates": [[139.76451, 35.68159],[139.75964, 35.68259]],
"dates": ["2018-02-01T00:00:00", "2018-03-01T00:00:00"]},
{"coordinates": [[139.76451, 35.68159],[139.75964, 35.68259]],
"dates": ["2018-03-01T00:00:00", "2018-04-01T00:00:00"]},
{"coordinates": [[139.76451, 35.68159],[139.75964, 35.68259]],
"dates": ["2018-04-01T00:00:00", "2018-05-01T00:00:00"]}
]
features: list = [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": line["coordinates"],
},
"properties": {
"times": line["dates"],
"style": {
"weight": 10
},
},
}
for line in lines
]
pipelines: dict = {
"type": "FeatureCollection",
"features": features,
}
return pipelines
def create_timeline_map():
m: folium.Map = folium.Map(location=[35.6815965, 139.7645151], zoom_start=16)
pipelines: dict = create_geojson()
TimestampedGeoJson(
pipelines,
period="P1M",
).add_to(m)
m.save('timeline_map-manual.html')
if __name__ == '__main__':
create_timeline_map()
I've tried many different combinations for period and duration, but no matter what I do, I cannot get the timeline to follow the values in 'dates`. How can I get the timeline to work correctly and increment from day 1 on one month to day 1 on the next month?
edit: I removed the period data from TimestampedGeoJson and watched the time slider moving forward. On 11/5 it jumps from 2023-11-05 00:00:00 to 2023-11-05 23:00:00 instead of moving to 2023-11-06 00:00:00. Hopefully that will provide a clue as to what's going on?
edit2: My esteemed colleague observed that this is most likely due to daylight savings time. If this is the case, is there a way to get TimestampedGeoJson to ignore daylight savings time? Or better yet, ignore duration and period and just use the time stamps from the dictionary?