ποΈTrack Interpolation
Example data preparation
import plotly.graph_objects as go
import plotly.express as px
import pandas as pd
def track2dataframe(tracks):
data = []
for track in tracks:
times = track['time']
mmsi = track['mmsi']
lons = track['lon']
lats = track['lat']
# Iterate over the dynamic arrays and create a row for each time point
for i in range(len(times)):
data.append({
'mmsi': mmsi,
'time': times[i],
'longitude': lons[i],
'latitude': lats[i],
})
return pd.DataFrame(data)
def plotly_visualize(data, visual_type='lines'):
if (visual_type=='scatter'):
# Create a scatter plot for the vessel data points using scatter_geo
fig = px.scatter_geo(
data,
lat="latitude",
lon="longitude",
color="mmsi", # Color by vessel identifier
hover_name="mmsi",
hover_data={"time": True},
title="Vessel Data Points"
)
else:
# Create a line plot for the vessel trajectory using line_geo
fig = px.line_geo(
data,
lat="latitude",
lon="longitude",
color="mmsi", # Color by vessel identifier
hover_name="mmsi",
hover_data={"time": True},
title="Vessel Trajectory"
)
# Set the map style and projection
fig.update_geos(
projection_type="azimuthal equal area", # Change this to 'natural earth', 'azimuthal equal area', etc.
showland=True,
landcolor="rgb(243, 243, 243)",
countrycolor="rgb(204, 204, 204)",
)
# Set the layout to focus on a specific area or zoom level
fig.update_layout(
geo=dict(
projection_type="azimuthal equal area",
),
width=1200, # Increase the width of the plot
height=800, # Increase the height of the plot
)
fig.show()
Linear interpolation
With equal time window intervals

With equal distance intervals

Geodesic Track Interpolation

Cubic Spline Interpolation

Custom Track Interpolation

Last updated