I am using the scikit-mobility
library to plot gps trajectory in a Jupyter notebook.
#pip -q install scikit-mobility
import skmob
# file from https://raw.githubusercontent.com/scikit-mobility/scikit-mobility/master/examples/geolife_sample.txt.gz
tdf = skmob.TrajDataFrame.from_file('geolife_sample.txt.gz', latitude='lat',
longitude='lon', user_id='user', datetime='datetime')
# print a portion of the TrajDataFrame
print(tdf.head())
lat lng datetime uid
0 39.984094 116.319236 2008-10-23 05:53:05 1
1 39.984198 116.319322 2008-10-23 05:53:06 1
2 39.984224 116.319402 2008-10-23 05:53:11 1
3 39.984211 116.319389 2008-10-23 05:53:16 1
4 39.984217 116.319422 2008-10-23 05:53:21 1
tdf.plot_trajectory(zoom=12, weight=3, opacity=0.9, tiles='Stamen Toner')
This is an interactive map plot in browser. In my case, it is intended for manuscript, ideally in png
(or pdf
) for publication quality.
Any workaround that?