deck.gl 中的 TripsLayer 动画 python

Animating TripsLayer in deck.gl with python

我在 deck.gl 网站 (this one) and it looks really cool. I would like to accomplish the same but using pydeck, the python bindings for deck.gl. The example in pydeck's webpage (this one) 中看到 TripsLayer 示例没有动画,我不确定我应该怎么做才能获得如 [=] 中所示的流畅动画18=] 例子。我尝试了多种方法(传递列表、函数、具有变化值的变量等),但没有一个起作用,我找不到任何 pydeck 的例子。

谢谢!

的确,该示例应该包含更多行程。下面介绍如何在jupyter notebook中实现多次旅行的动画。

import time
import pandas as pd
import pydeck as pdk

data = '[{"agent_id":0,"path":[[-0.63968,50.83091,0.0],[-0.78175,50.83205,0.0]],"time":[65100,65520],"color":[228,87,86]},{"agent_id":1,"path":[[-0.63968,50.83091,0.0],[-0.78175,50.83205,0.0]],"time":[65940,66420],"color":[178,121,162]},{"agent_id":2,"path":[[-0.63968,50.83091,0.0],[-0.37617,50.8185,0.0]],"time":[65340,66360],"color":[157,117,93]},{"agent_id":3,"path":[[-0.63968,50.83091,0.0],[-0.78175,50.83205,0.0]],"time":[65940,66420],"color":[238,202,59]},{"agent_id":4,"path":[[-0.63968,50.83091,0.0],[-0.78175,50.83205,0.0]],"time":[67740,68160],"color":[157,117,93]}]'

df = pd.read_json(data)
view = {"bearing": 0, "latitude": 50.85, "longitude": -0.16, "pitch": 0, "zoom": 9}

time_min = 65_000
time_max = 80_000

layer = pdk.Layer(
    "TripsLayer",
    df,
    get_path='path',
    get_timestamps='time',
    get_color='color',
    opacity=0.8,
    width_min_pixels=3,
    rounded=True,
    trail_length=900,
    current_time=0
)

# Render
r = pdk.Deck(layers=[layer], initial_view_state=view, map_style='dark_no_labels')

r.show()

# Animate
for ct in range(time_min, time_max, 100):
    layer.current_time = ct
    r.update()
    time.sleep(0.1)