xoolive / traffic

A toolbox for processing and analysing air traffic data
https://traffic-viz.github.io/
MIT License
361 stars 80 forks source link

Integration with lonboard #424

Open xoolive opened 4 months ago

xoolive commented 4 months ago

Hi @kylebarron,

Could you have a look at this first tentative? If you have some feedback, better ideas?

I wrote some basic examples blocks below, maybe there are smarter things to do.

With lines, I often see glitches (spikes) that I don't get with other visualization methods. Maybe there's something wrong in my code...

image

from lonboard import Map, PathLayer, ScatterplotLayer
from traffic.data.samples import belevingsvlucht

table = belevingsvlucht.pyarrow_table(geo="line2d")
layer_traj = PathLayer(
    table=table,
    width_min_pixels=1,
    get_color="#4c78a8",
)
layer_scat = ScatterplotLayer(
    table=belevingsvlucht.next("holding_pattern").pyarrow_table(geo="point2d"),
    radius_min_pixels=3,
    get_fill_color="#f58518",
)
Map(layers=[layer_traj, layer_scat])

image

from lonboard import Map, PathLayer, ScatterplotLayer
from traffic.data.samples import quickstart

lfpo_landing = PathLayer(
    table=quickstart.filter("aggressive")
    .resample("1s")
    .has("aligned_on_ils('LFPO')")
    .eval(desc="", max_workers=6)
    .pyarrow_table(geo="line3d"),
    width_min_pixels=1,
    get_color="#4c78a8",
)

lfpg_landing = PathLayer(
    table=quickstart.filter("aggressive")
    .resample("1s")
    .has("aligned_on_ils('LFPG')")
    .eval(desc="", max_workers=6)
    .pyarrow_table(geo="line3d"),
    width_min_pixels=1,
    get_color="#f58518",
)

Map(layers=[lfpo_landing, lfpg_landing])

image

# %%
from lonboard import Map, PathLayer, ScatterplotLayer
from traffic.data.datasets import landing_heathrow_2019

subset = (
    # a bit long to process on a laptop, therefore limiting to 5000 flights
    landing_heathrow_2019[:5000]
    .label("holding_pattern", holding=True)
    .eval(desc="", max_workers=4, cache_file="holding.parquet")
)

# %%

# Can we have a different color when the `holding` flag is True ?
holding_patterns = subset.query('holding').pyarrow_table(columns=["holding"], geo="point3d")
holding_layer = ScatterplotLayer(table=holding_patterns, radius_min_pixels=3)

Map(layers=[holding_layer])

Edit from a more powerful machine:

image

It looks like some paths are very well separated, i.e. runway threshold connected to beginning of trajectories sometimes.

With points and colors:

kylebarron commented 4 months ago

Apologies, I've been so busy lately. I'm trying to get a new release of lonboard out early next week and then hope to focus on the trips layer for the following release.

It looks like these examples are using data from the traffic library, right? So I should be able to easily reproduce them myself?

xoolive commented 4 months ago

No worry, I also have a real job aside 😉

You should be able to run the code from traffic, but be careful to get it from the lonboard branch (attached to this PR) so you can get the pyarrow_table() methods (and few glitches fixed)

I will probably come with pathlayer() and scatterplotlayer() methods later after we converge.

xoolive commented 2 months ago

Hi @kylebarron I see there have been some version update since our last discussion. Is there something related to our topic that I should be particularly aware of?

kylebarron commented 1 month ago

No not yet, but I have more time over the next few months to focus on Lonboard, so I'm motivated to push this over the line!