pythonfolium

folium, plugins.TimestampedGeoJson, "Time not avaliable"


I want to draw Timestamped GeoJSON using plugins.TimestampedGeoJson.

But my time bar in folium map shows "Time not available" and doesn't work.

I cannot find which part of my variables are wrong.

Variables I used are as follows.

How can I make my time bar work?

points




[{'coordinates': [[37.4725028, 126.4313798],
   [37.478525899999994, 126.6663152],
   [37.561648999999996, 126.79433700000001]],
  'popup': 1,
  'time': '2020-01-19'},
 {'coordinates': [[37.679657, 126.763737],
   [37.4725028, 126.4313798],
   [37.0796065, 127.0561043],
   [37.0220402, 126.8134938],
   [37.557176, 127.00768799999999]],
  'popup': 1,
  'time': '2020-01-20'},
 {'coordinates': [[37.673517, 126.7553],
   [37.670964, 126.761146],
   [37.679657, 126.763737],
   [37.520878, 127.02286299999999],
   [37.524661, 127.028002],
   [37.503137, 127.04909099999999],
   [37.0520115, 126.91724440000002],
   [37.463504, 126.65055600000001]],
  'popup': 1,
  'time': '2020-01-21'},
 {'coordinates': [[37.560362700000006, 126.776299],
   [37.567226899999994, 126.75337079999998],
   [37.549605299999996, 126.86608829999999],
   [37.567226899999994, 126.75337079999998],
   [37.5672454, 127.00347020000001],
   [37.524661, 127.028002],
   [37.530772, 127.031924],
   [37.503137, 127.04909099999999],
   [37.0220402, 126.8134938],
   [37.523118200000006, 127.03281489999999],
   [37.555136, 126.97048899999999]],
  'popup': 1,
  'time': '2020-01-22'},
 {'coordinates': [[37.524703, 127.015943],
   [37.500735, 127.036373],
   [37.494607, 127.06329199999999],
   [37.503137, 127.04909099999999],
   [37.0220402, 126.8134938],
   [37.483702, 126.77811299999999]],
  'popup': 1,
  'time': '2020-01-23'},
 {'coordinates': [[37.524661, 127.028002],
   [37.658513, 126.832025],
   [37.674671999999994, 126.776701],
   [37.678166, 126.812165],
   [37.0220402, 126.8134938],
   [37.5616902, 126.97456809999998],
   [37.266184, 126.999655],
   [37.263417, 127.028654],
   [37.361576, 126.935174]],
  'popup': 1,
  'time': '2020-01-24'},
 {'coordinates': [[37.679657, 126.763737],
   [37.642371999999995, 126.831253],
   [37.0520115, 126.91724440000002],
   [37.5616902, 126.97456809999998],
   [37.483538, 127.032643],
   [35.967625, 126.73678899999999],
   [35.967625, 126.73678899999999],
   [37.359123, 126.93095500000001],
   [37.359123, 126.93095500000001]],
  'popup': 1,
  'time': '2020-01-25'},
 {'coordinates': [[37.35132410000001, 127.12124329999999],
   [37.5917891, 127.0164831],
   [37.564001, 127.02953500000001],
   [37.5903342, 127.01303200000001],
   [37.590492100000006, 127.0119803],
   [37.590611700000004, 126.9441293],
   [37.5863425, 126.99763390000001],
   [37.5616902, 126.97456809999998],
   [35.9867, 126.70813000000001]],
  'popup': 1,
  'time': '2020-01-26'},
 {'coordinates': [[37.5920615, 127.01670959999998],
   [37.590611700000004, 126.9441293],
   [37.5921286, 126.98387890000001],
   [37.5863425, 126.99763390000001],
   [37.5863425, 126.99763390000001],
   [37.5863425, 126.99763390000001],
   [37.5616902, 126.97456809999998],
   [35.968089, 126.716128],
   [37.557176, 127.00768799999999]],
  'popup': 1,
  'time': '2020-01-27'},
 {'coordinates': [[37.5916736, 127.016226],
   [37.5854777, 127.08637140000002],
   [37.5982157, 127.0797739],
   [37.5236782, 127.04434930000001],
   [37.60656420000001, 127.09043],
   [37.5616902, 126.97456809999998],
   [35.954685, 126.71244399999999],
   [37.483702, 126.77811299999999]],
  'popup': 1,
  'time': '2020-01-28'},
 {'coordinates': [[37.594741799999994, 127.0728561],
   [37.60656420000001, 127.09043],
   [37.5616902, 126.97456809999998],
   [35.976046000000004, 126.705522],
   [35.982751, 126.734844]],
  'popup': 1,
  'time': '2020-01-29'},
 {'coordinates': [[37.5647424, 126.99496140000001],
   [37.579669, 126.99897],
   [35.964349, 126.959676],
   [37.641158000000004, 126.791979],
   [37.5863425, 126.99763390000001],
   [37.641158000000004, 126.791979],
   [37.5863425, 126.99763390000001],
   [37.498415, 126.762864]],
  'popup': 1,
  'time': '2020-01-30'},
 {'coordinates': [[35.964349, 126.959676],
   [37.5673125, 126.9706395],
   [37.579669, 126.99897],
   [37.579669, 126.99897],
   [37.561648, 126.7855822],
   [37.481458, 126.7804963]],
  'popup': 1,
  'time': '2020-01-31'},
 {'coordinates': [[37.351375, 127.123411],
   [37.481458, 126.7804963],
   [37.304349, 127.0079881],
   [37.391714799999995, 127.147098]],
  'popup': 1,
  'time': '2020-02-01'},
 {'coordinates': [[37.5672412, 127.00347020000001], [37.351375, 127.123411]],
  'popup': 1,
  'time': '2020-02-02'}]

Below is my features variable.

features

[{'geometry': {'coordinates': [[37.4725028, 126.4313798],
    [37.478525899999994, 126.6663152],
    [37.561648999999996, 126.79433700000001]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-19'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.679657, 126.763737],
    [37.4725028, 126.4313798],
    [37.0796065, 127.0561043],
    [37.0220402, 126.8134938],
    [37.557176, 127.00768799999999]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-20'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.673517, 126.7553],
    [37.670964, 126.761146],
    [37.679657, 126.763737],
    [37.520878, 127.02286299999999],
    [37.524661, 127.028002],
    [37.503137, 127.04909099999999],
    [37.0520115, 126.91724440000002],
    [37.463504, 126.65055600000001]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-21'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.560362700000006, 126.776299],
    [37.567226899999994, 126.75337079999998],
    [37.549605299999996, 126.86608829999999],
    [37.567226899999994, 126.75337079999998],
    [37.5672454, 127.00347020000001],
    [37.524661, 127.028002],
    [37.530772, 127.031924],
    [37.503137, 127.04909099999999],
    [37.0220402, 126.8134938],
    [37.523118200000006, 127.03281489999999],
    [37.555136, 126.97048899999999]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-22'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.524703, 127.015943],
    [37.500735, 127.036373],
    [37.494607, 127.06329199999999],
    [37.503137, 127.04909099999999],
    [37.0220402, 126.8134938],
    [37.483702, 126.77811299999999]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-23'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.524661, 127.028002],
    [37.658513, 126.832025],
    [37.674671999999994, 126.776701],
    [37.678166, 126.812165],
    [37.0220402, 126.8134938],
    [37.5616902, 126.97456809999998],
    [37.266184, 126.999655],
    [37.263417, 127.028654],
    [37.361576, 126.935174]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-24'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.679657, 126.763737],
    [37.642371999999995, 126.831253],
    [37.0520115, 126.91724440000002],
    [37.5616902, 126.97456809999998],
    [37.483538, 127.032643],
    [35.967625, 126.73678899999999],
    [35.967625, 126.73678899999999],
    [37.359123, 126.93095500000001],
    [37.359123, 126.93095500000001]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-25'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.35132410000001, 127.12124329999999],
    [37.5917891, 127.0164831],
    [37.564001, 127.02953500000001],
    [37.5903342, 127.01303200000001],
    [37.590492100000006, 127.0119803],
    [37.590611700000004, 126.9441293],
    [37.5863425, 126.99763390000001],
    [37.5616902, 126.97456809999998],
    [35.9867, 126.70813000000001]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-26'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.5920615, 127.01670959999998],
    [37.590611700000004, 126.9441293],
    [37.5921286, 126.98387890000001],
    [37.5863425, 126.99763390000001],
    [37.5863425, 126.99763390000001],
    [37.5863425, 126.99763390000001],
    [37.5616902, 126.97456809999998],
    [35.968089, 126.716128],
    [37.557176, 127.00768799999999]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-27'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.5916736, 127.016226],
    [37.5854777, 127.08637140000002],
    [37.5982157, 127.0797739],
    [37.5236782, 127.04434930000001],
    [37.60656420000001, 127.09043],
    [37.5616902, 126.97456809999998],
    [35.954685, 126.71244399999999],
    [37.483702, 126.77811299999999]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-28'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.594741799999994, 127.0728561],
    [37.60656420000001, 127.09043],
    [37.5616902, 126.97456809999998],
    [35.976046000000004, 126.705522],
    [35.982751, 126.734844]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-29'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.5647424, 126.99496140000001],
    [37.579669, 126.99897],
    [35.964349, 126.959676],
    [37.641158000000004, 126.791979],
    [37.5863425, 126.99763390000001],
    [37.641158000000004, 126.791979],
    [37.5863425, 126.99763390000001],
    [37.498415, 126.762864]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-30'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[35.964349, 126.959676],
    [37.5673125, 126.9706395],
    [37.579669, 126.99897],
    [37.579669, 126.99897],
    [37.561648, 126.7855822],
    [37.481458, 126.7804963]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-01-31'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.351375, 127.123411],
    [37.481458, 126.7804963],
    [37.304349, 127.0079881],
    [37.391714799999995, 127.147098]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-02-01'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [[37.5672412, 127.00347020000001],
    [37.351375, 127.123411]],
   'type': 'Point'},
  'properties': {'icon': 'marker',
   'iconstyle': {'iconSize': [20, 20],
    'iconUrl': 'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'},
   'id': 'house',
   'popup': 1,
   'time': '2020-02-02'},
  'type': 'Feature'}]

I tried to draw folium map.

But my time lower left in map left doesn't work.


m = folium.Map([37.5650172,126.8494648], zoom_start = 10)


plugins.TimestampedGeoJson( { 'type': 'FeatureCollection', 'features': features },
                           period='P1D',
                           add_last_point=True,
                           auto_play=False,
                           loop=False,
                           max_speed=1,
                           loop_button=True,
                           date_options='YYYY-MM-DD',
                           time_slider_drag_update=True,
                           duration='P1D' ).add_to(m)

m




Solution

  • I had the same problem, which was solved by the following in my case:

    The issue you described occurs likely because your sub-dict-keyword "time" doesn't contain a list of equal length to the employed "coordinates" in each "feature".

    Also, I suggest you to rename "time" to "times", as you will see in the original post on GitHub mentioned below.

    Hereafter, I made a minimal example based on your provided feature list:

    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    
    # * Example of correct feature list with length 1 * #
    
    ## Coordinates
    coordinate_list1 = [[37.4725028, 126.4313798],
        [37.478525899999994, 126.6663152],
        [37.561648999999996, 126.79433700000001]]
    ## Times
    # NOTE: if the same timestamp applies to all coordinates, create list with repeating timestamp of same length as coordinate list
    times_list1 = ['2020-01-19'] * len(coordinate_list1)
    
    ## Features
    # NOTE: fill in the coordinates and times, and name the associated time-keyword "times"
    features = [{
        'geometry': {
            'coordinates': coordinate_list1,
            'type': 'Point'
        },
        'properties': {
            'icon': 'marker',
            'iconstyle': {
                'iconSize': [20, 20],
                'iconUrl':
                'http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png'
            },
            'id': 'house',
            'popup': 1,
            'times': times_list1
        },
        'type': 'Feature'
    }]
    

    Fix this and it should work just fine.

    The solution was cited from this discussion:

    [...] the plugin requires each feature to have a property "times", which should be a list containing either unix epoch timestamps in ms or ISO format timestamps. See https://python-visualization.github.io/folium/plugins.html#folium.plugins.TimestampedGeoJson