You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature request to enable adding a TimestampedGeoJson object to a folium FeatureGroup. This would allow different feature collections to be plotted, selected, deselected on the same map canvas. Works great for GeoJson, TimestampedGeoJson would be much improved if this was added.
Does folium.plugins.TimestampedGeoJson() have a feature_group optional argument? When using GeoJson objects I can add them to an existing FeatureGroup, but this doesn't work with TimestampedGeoJson as these can only be added to a map instance.
Yes, of course. Let me know if I can provide anything else to assist like sample code, build nums, etc.? TimestampedGeoJson is a really nice tool and I'm able to visualize coordinate-mapped dataset really well with it. But, the FeatureGroup selection tool that works with GeoJson is very useful indeed. As a workaround I just make separate maps/HTMLs for each of the collections I would aspire to add to a FeatureGroup.
I checked the code, but I do not see an easy way to fix this in the current implementation of TimestampedGeoJson. FeatureGroup objects require Layer objects on the map. However, TimestampedGeoJson combines a Leaflet Control and a Leaflet Layer object, but really is neither. I'd need to do a major refactor of the plugin to fix this.
As a workaround you could have a look at the timeline plugin. This provides the Timeline class which is a GeoJson with timestamps. It has a separate TimelineControl class. I did not test this myself yet, but it should just work out of the box. (And if it does not it may be simpler to fix.) The specifics on how times are added to the GeoJson are very different, so it may not suit your use case.
@dbpodrasky It feels to early to give up! Are there specific areas where we can improve the documentation? If you send me your geojson, perhaps I can help you re-implement the required functionality using the Timeline class.
Hans, please see the git repo containing some input data in a CSV with two scripts: one plots the data using GeoJson and includes the desired things like layer control, etc. the other uses TimestampedGeoJson to plot the same data animated by timestamps. Hoping to use these two to create a script that will plot time-aware data and also facilitate layer control using FeatureGroups.
What is missing is using a circle for the icon. You can add that to the Timeline constructor by adding a point_to_layer function.
Something like this: point_to_layer=JsCode("(f, latlng) => { return L.circleMarker(latlng, {radius: 8, fillOpacity: 0.2})}"). You can find more examples in the documentation of the Realtime plugin.
Also, the layer name is now weird. This can be remedied by wrapping Timeline in a FeatureGroup. Let me know if this helps you further.
It's the JsCode wrapper that I can't get to work. If I try to call point_to_layer in TimelineSlider the map breaks, while if I try to pass my Timeline instance to Realtime it also breaks. I would guess that Timeline is incompatible with Realtime and that point_to_layer can't be used with TimelineSlider.
I need to be able to color each point based on data run through a colormap.
Can you show me your code? Is your code in the repo you sent? Realtime is not really applicable to your use case. You should add point_to_layer to your Timeline instance (not the TimeLineSlider).
Probably the easiest way is to add a color property to each of the features in your geojson data and then create a JsCode like this:
It's working! https://github.com/dbpodrasky/FoliumTimestampToTimeline on branch main.
Is it worthwhile to make an example entry in the docs for Timeline to demonstrate point_to_layer and adding Timeline objects to FeatureGroups?
Ah cool. Happy that it works. I was just studying your code and I was afraid I had to confess I did not understand some of the pandas code. Now I can just claim that I understood everything :-).
As for documentation is that something you are willing to contribute? Our documentation is always in need of improvements.
Activity
hansthen commentedon Sep 7, 2025
@dbpodrasky Doesn't this "just work" out of the box? What happens if you try this?
dbpodrasky commentedon Sep 8, 2025
Does
folium.plugins.TimestampedGeoJson()have afeature_groupoptional argument? When usingGeoJsonobjects I can add them to an existingFeatureGroup, but this doesn't work withTimestampedGeoJsonas these can only be added to a map instance.dbpodrasky commentedon Sep 8, 2025
TypeError: TimestampedGeoJson.__init__() got an unexpected keyword argument 'feature_group'hansthen commentedon Sep 8, 2025
I think I see the issue. Thanks for clarifying.
dbpodrasky commentedon Sep 8, 2025
Yes, of course. Let me know if I can provide anything else to assist like sample code, build nums, etc.?
TimestampedGeoJsonis a really nice tool and I'm able to visualize coordinate-mapped dataset really well with it. But, theFeatureGroupselection tool that works withGeoJsonis very useful indeed. As a workaround I just make separate maps/HTMLs for each of the collections I would aspire to add to aFeatureGroup.hansthen commentedon Sep 8, 2025
I checked the code, but I do not see an easy way to fix this in the current implementation of
TimestampedGeoJson.FeatureGroupobjects requireLayerobjects on the map. However,TimestampedGeoJsoncombines a Leaflet Control and a Leaflet Layer object, but really is neither. I'd need to do a major refactor of the plugin to fix this.As a workaround you could have a look at the
timelineplugin. This provides theTimelineclass which is a GeoJson with timestamps. It has a separate TimelineControl class. I did not test this myself yet, but it should just work out of the box. (And if it does not it may be simpler to fix.) The specifics on how times are added to the GeoJson are very different, so it may not suit your use case.Let me know if
timelineworks for you.dbpodrasky commentedon Sep 8, 2025
I will look into whether
Timelinewould be workable for my project. Thanks for the advice!dbpodrasky commentedon Sep 10, 2025
Sorry, Hans. I can't make any sense of
Timelinefrom the available docs. I give up on layer control for timed geodata.hansthen commentedon Sep 10, 2025
@dbpodrasky It feels to early to give up! Are there specific areas where we can improve the documentation? If you send me your geojson, perhaps I can help you re-implement the required functionality using the
Timelineclass.dbpodrasky commentedon Sep 11, 2025
Okay, let's give it a try. Give me a few days to anonymize an input dataset? Then I can send as a GeoJson.
hansthen commentedon Sep 11, 2025
Looking forward to it.
dbpodrasky commentedon Sep 12, 2025
Hans, please see the git repo containing some input data in a CSV with two scripts: one plots the data using GeoJson and includes the desired things like layer control, etc. the other uses TimestampedGeoJson to plot the same data animated by timestamps. Hoping to use these two to create a script that will plot time-aware data and also facilitate layer control using
FeatureGroups.https://github.com/dbpodrasky/FoliumTimestampToTimeline/
hansthen commentedon Sep 14, 2025
Will have a look.
hansthen commentedon Sep 20, 2025
I got your code to work with
TimelineandLayerControl. It is still a bit rough around the edges. Here is the diff:hansthen commentedon Sep 20, 2025
What is missing is using a circle for the icon. You can add that to the Timeline constructor by adding a
point_to_layerfunction.Something like this:
point_to_layer=JsCode("(f, latlng) => { return L.circleMarker(latlng, {radius: 8, fillOpacity: 0.2})}"). You can find more examples in the documentation of theRealtimeplugin.Also, the layer name is now weird. This can be remedied by wrapping
Timelinein aFeatureGroup. Let me know if this helps you further.dbpodrasky commentedon Sep 22, 2025
Wow! Looking forward to testing this diff.
Thanks, Hans.
dbpodrasky commentedon Oct 1, 2025
Coming back to this now and it is working well so far. I need to research the JS stuff a bit, but I am familiar with
FeatureGroups.dbpodrasky commentedon Oct 3, 2025
It's the JsCode wrapper that I can't get to work. If I try to call
point_to_layerinTimelineSliderthe map breaks, while if I try to pass myTimelineinstance toRealtimeit also breaks. I would guess thatTimelineis incompatible withRealtimeand thatpoint_to_layercan't be used withTimelineSlider.I need to be able to color each point based on data run through a colormap.
hansthen commentedon Oct 4, 2025
Can you show me your code? Is your code in the repo you sent?
Realtimeis not really applicable to your use case. You should addpoint_to_layerto yourTimelineinstance (not theTimeLineSlider).Probably the easiest way is to add a
colorproperty to each of the features in your geojson data and then create a JsCode like this:dbpodrasky commentedon Oct 6, 2025
Pushed the latest version of my working branch to https://github.com/dbpodrasky/FoliumTimestampToTimeline/blob/Timestamp-to-Timeline/
As you can see, using list comprehension to create the
Timeline()object. Ispoint_to_layercompatible with the list comprehension?dbpodrasky commentedon Oct 8, 2025
It's working!
https://github.com/dbpodrasky/FoliumTimestampToTimeline on branch main.
Is it worthwhile to make an example entry in the docs for
Timelineto demonstratepoint_to_layerand addingTimelineobjects toFeatureGroups?hansthen commentedon Oct 8, 2025
Ah cool. Happy that it works. I was just studying your code and I was afraid I had to confess I did not understand some of the pandas code. Now I can just claim that I understood everything :-).
As for documentation is that something you are willing to contribute? Our documentation is always in need of improvements.