-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
Thanks for tagging me. This development looks really exciting. Let me know if you have any movingpandas questions. |
Howdy, we talked at SciPy, posting to track this PR’s progress 🙂 |
|
||
for field_idx in range(batch.num_columns): | ||
field = batch.schema.field(field_idx) | ||
new_field = field.with_type(DataType.list(field)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relies on arro3's list(..)
to convert the pyarrow field through the arrow pycapsule interface, and then pyarrow's with_type()
convert again in the other direction?
Nice ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, no, I see that you converted the pyarrow Table to am arro3 one (attr_table = Table.from_arrow(attr_table)
) before calling this function ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here batch
is actually an arro3.RecordBatch
, the conversion back to arro3 happened here:
attr_table = Table.from_arrow(attr_table) |
But yes, these lines should work with pyarrow input as well!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, no, I see that you converted the pyarrow Table to am arro3 one (
attr_table = Table.from_arrow(attr_table)
) before calling this function ;)
Right. I could've left it as a pyarrow table; the main difference is mostly for type hinting. It's nice to get IDE completions and type checking and pyarrow doesn't have that yet.
Co-authored-by: Joris Van den Bossche <[email protected]>
I'm not sure on the best API regarding We should also check how |
Got an air traffic control example working too: Screen.Recording.2024-10-04.at.5.11.10.PM.movScreen.Recording.2024-10-04.at.5.21.06.PM.movOn Monday we can just clean up the examples a bit, add a display for the current time of the animation, and then publish the new version! |
I'm able to view ~4 million points on my laptop with reduced performance. 800K look great. if you are looking for more examples, here are open data affiliated with our project: https://osf.io/dg6t3/ the for the wish list: will be great when the cc @hengoren |
lonboard/experimental/_layer.py
Outdated
|
||
|
||
class TripsLayer(BaseArrowLayer): | ||
"""The `TripsLayer` renders animated paths that represent vehicle trips. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not just vehicles!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I just copy that docstring from deck.gl (https://deck.gl/docs/api-reference/geo-layers/trips-layer), but in this case maybe we should choose a different description
@kdpenner if you'd like to create an example notebook in your own repo, we can link to it from our docs |
It is technically possible, though difficult, to use The only way for it to work with native datetime/pandas objects would be to have a nested list inside a pandas column, and for now that's a task for users to convert it to an arrow array. |
yeah. would the geodataframe need to be grouped by a unique identifier? for example, if one gdf has 1000 trajectories in it, such that each timestamp has 1000 duplicates, would I need to iterate through movingpandas groups internally, I think, so that each trajectory is unique to an agent oh I see you specified LineString, rather than a gdf of Points |
FWIW
|
Yes, because it's a variable-size list and numpy doesn't have variable-size lists. (I suppose we should have a clearer error there) You can flatten the list and then convert the underlying array to numpy, e.g. with |
Print current time next to the play control
a minimal example
Change list
TripsLayer
under theexperimental
modulemovingpandas
from_movingpandas
class method to construct aTripsLayer
from a movingpandasTrajectoryCollection
Todo
movingpandas.TrajectoryCollection
to GeoArrow.TimestampAccessor
. Validate timestamps have the same offsetting as the geometry in the main data frame. (Done in 37a64c6)time_offset
integer on theTripsLayer
that represents the minimum value of the trip data. Note that you'd need to recompute this when a newget_timestamps
is assigned onto the layer. (Done in 6addb2e)Open questions
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.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.
cc @anitagraser, you may be interested in this, and/or have ideas for how to better integrate with movingpandas