首页 > 解决方案 > 具有分组要素图层控制的时间戳 geojson

问题描述

我想用时间戳信息可视化地理数据。我在我的 python 代码中使用 plugins.TimestampedGeoJson 来做到这一点。代码实际上是有效的,但我需要在地图中显示超过 1 个功能,并且这些功能中的每一个都可以从 LayerControl 显示/隐藏。

有什么想法吗?

#example 具有一项功能

features_3 = []
for  row in DF_3.itertuples():
    long = row.longitude
    lat = row.latitude
    data= row.data

    features_3 .append (
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [long,lat],
            },
            "properties": {
                "time": str(row.xdate),
                "popup": "Record : " + str(data) ,
                "icon": "circle",
                "iconstyle": {
                    "fillColor": color_scale(data),
                    "fillOpacity": 0.6,
                    "stroke": "false",
                    "radius": 8,
                },
                "style": {"weight": 0},
            },
        }
    )

plugins.TimestampedGeoJson(
    {"type": "FeatureCollection", "features": features_3 },
    period="P1D",
    add_last_point=True,
    auto_play=True,
    loop=False,
    max_speed=1,
    loop_button=True,
    time_slider_drag_update=True,
    duration="P1D",
).add_to(map)
LayerControl().add_to(map)

标签: pythongeojsonfolium

解决方案


TimestampedGeoJson 持续时间参数导致多边形消失

此链接中的代码可能会对您有所帮助。您可以看到它是如何在同一张地图中添加多个多边形图层的。


推荐阅读