Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement TripsLayer for animating moving objects and connect to MovingPandas #292

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

kylebarron
Copy link
Member

@kylebarron kylebarron commented Dec 5, 2023

a minimal example
Screen Recording 2023-12-05 at 5 15 35 PM

Change list

  • Add new TripsLayer under the experimental module
  • Add optional dependency on movingpandas so I can use it for type checking. Maybe this should be a dev dependency and only imported as a type?
  • Add from_movingpandas class method to construct a TripsLayer from a movingpandas TrajectoryCollection

Todo

Open questions

  • How to handle offsetted timestamps? deck.gl stores timestamps as float32, which means there isn't enough integer precision to store milliseconds or nanoseconds since epoch.
  • Where to handle animation? It looks like syncing animation via an ipywidgets.Play widget (connected via jslink) is probably good enough for now, even if it appears to have a decent amount of overhead. The alternative would be to have a manual animation component on the JS side that maintains its own time state.
  • Is there a faster way to import from moving pandas? It looks like there's no way around aggregating timestamps into a nested column myself.

Example repro

I got data from Access AIS, with a custom bounding box and time range, though it would probably be straightforward to use other data files as well.

import pyarrow as pa
import pandas as pd
import movingpandas as mpd
from lonboard import Map
from lonboard.experimental import TripsLayer
import ipywidgets

path = '/Users/kyle/Downloads/AIS_170180417406763049_2306-1701804175229.csv'
df = pd.read_csv(path)
traj_collection = mpd.TrajectoryCollection(df, 'MMSI', t='BaseDateTime', x='LON', y='LAT')

layer.width_min_pixels = 5
layer.trail_length = 100000

play = ipywidgets.Play(
    value=0,
    min=0,
    max=86399000,
    step=50_000,
    interval=50,
    repeat=True
)
play
ipywidgets.jsdlink(
    (play, 'value'),
    (layer, 'current_time'),
)

cc @anitagraser, you may be interested in this, and/or have ideas for how to better integrate with movingpandas

@anitagraser
Copy link

Thanks for tagging me. This development looks really exciting. Let me know if you have any movingpandas questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants