<jupyter_start><jupyter_text>Panel DemoThis notebook demonstrates the use of Holoviz [Panel](https://panel.holoviz.org/index.html). *Panel is an open-source Python library that lets you create custom interactive web apps and dashboards by connecting user-defined widgets to plots, images, tables, or text.*<jupyter_code>%matplotlib inline
import urllib
import os
import pandas as pd
import geopandas as gpd
from geopandas import GeoDataFrame, read_file
from shapely.geometry import Point, LineString, Polygon
from pyproj import CRS
from datetime import datetime, timedelta
from matplotlib import pyplot as plt

import sys
sys.path.append("..")
import movingpandas as mpd

import warnings
warnings.simplefilter("ignore")

import panel as pn
import panel.widgets as pnw
df = read_file('data/demodata_geolife.gpkg')
df['t'] = pd.to_datetime(df['t'])
df = df.set_index('t').tz_localize(None)
traj_collection = mpd.TrajectoryCollection(df, 'trajectory_id')
my_traj = traj_collection.trajectories[1].to_crs(CRS(4088))
my_traj.is_latlon
def my_plot(tolerance=0.001, generalizer='douglas-peucker'):
    if generalizer=='douglas-peucker':
        generalized = mpd.DouglasPeuckerGeneralizer(my_traj).generalize(tolerance=tolerance)
    else:
        generalized = mpd.MinDistanceGeneralizer(my_traj).generalize(tolerance=tolerance)
    generalized.add_speed(overwrite=True)
    return ( generalized.hvplot(title='Trajectory {}'.format(generalized.id), c='speed', cmap='Viridis', colorbar=True, clim=(0,20), line_width=10, width=500, height=500) + 
             generalized.df['speed'].hvplot.hist(title='Speed histogram', width=300, height=500) 
           )

my_plot()
kw = dict(tolerance=(0, 1000), generalizer=['douglas-peucker', 'min-distance'])
pn.interact(my_plot, **kw)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11686143572621036, 'fraction_numerical': 0.01725097384529772, 'mean_word_length': 6.106719367588933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '51634', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 635, 'n_tokens_neox': 594, 'n_words': 137, 'path': 'tutorials/demo_panel.ipynb', 'repo_name': 'sglvladi/movingpandas', 'size': '1797'}