<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Notebook-based Visual Analysis of Large Tracking Datasets</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Anita Graser</string-name>
          <email>anita.graser@ait.ac.at</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>AIT Austrian Institute of Technology</institution>
          ,
          <addr-line>Vienna</addr-line>
          ,
          <institution>Austria University of Salzburg</institution>
          ,
          <addr-line>Salzburg</addr-line>
          ,
          <country country="AT">Austria</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper demonstrates some of the latest developments for the visual analysis of large tracking datasets within the Python ecosystem revolving around the Pandas and HoloViz libraries. These software tools enable the quick and interactive notebookbased exploration of large datasets with millions of location records on commodity hardware.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>INTRODUCTION</title>
      <p>
        Movement datasets collected by systems tracking vehicles,
people, goods or wildlife have the potential to improve our
understanding of complex mobility systems [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. Movement data
analysis involves multiple interconnected steps, including
collection, cleaning, (pre)processing, and data mining which often go
through multiple iterations. Conceptually, movement analysis
tasks can focus on one of three fundamental aspects of movement
[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]: objects/movers (focusing on the moving objects and their
trajectories), space (focusing on locations), and time (focusing
on linear or cyclic time units).
      </p>
      <p>
        Visualizations of movement data often sufer from visual
clutter [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Patterns that may be visible in one type of visualization
(with a specific set of parameter settings) can be completely
obscured in another visualization or with diferent parameter
settings. For an eficient data exploration workflow, analysts
therefore need to be able to explore multiple diferent
visualization types and to vary the corresponding parameter settings
[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. This makes notebook-style interfaces attractive since they
enable analysts to track “the steps in a data analysis workoflw in
a narrative way, for reporting, and for collaboration”[
        <xref ref-type="bibr" rid="ref14">14</xref>
        ].
      </p>
      <p>
        Recent years have seen an increase in movement data analysis
functionality in Python, including libraries such as
MovingPandas [
        <xref ref-type="bibr" rid="ref5 ref6">5, 6</xref>
        ] or scikit-mobility [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ]. However, these libraries sufer
from poor rendering speed that makes them unsuitable for
visualizing large datasets [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Of course, besides Python, the other large
data analysis languae is R and there are dozens of R libraries for
movement data [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] which may be used in R notebooks1.
However, we are not aware of any R notebook examples for movement
data analysis.
      </p>
      <p>
        In this paper, we demonstrate cutting-edge tools for the
interactive exploration of large tracking datasets in Python notebooks
building on the data handling capabilities of Pandas[
        <xref ref-type="bibr" rid="ref12 ref15">12, 15</xref>
        ] and
the visualization capabilities of HoloViz2 family of tools. Amongst
others, this family of tools includes3:
• hvPlot[
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]: creates interactive HoloViews, GeoViews or
      </p>
      <p>
        Panel objects from Pandas, Xarray, or other data structures
• HoloViews[
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]: builds interactive Bokeh4 plots from
highlevel specifications
• Datashader[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]: rasterizes huge datasets quickly as
fixedsize images
      </p>
      <p>The key tool for the visualization of large datasets in the
following examples is HoloViz Datashader. Computation-intensive
steps in the Datashader process are written in Python that is
compiled to machine code using Numba5 to increase performance.
Furthermore, Datashader distributes the computations across
CPU cores and processors (using Dask6) or GPUs (using CUDA7).
Conventional visualization packages for interactive plotting used
1https://blog.rstudio.com/2016/10/05/r-notebooks/
2http://holoviz.org
3https://holoviz.org/background.html
4https://bokeh.org
5https://numba.pydata.org
6https://dask.org
7https://developer.nvidia.com/cuda-zone
in notebook environments (for example, Folium8 used by
scikitmobility) pass all data records directly to the browser where they
are then displayed. This enables interaction with each data point
but it quickly runs into limitations on how much data can be
visualized. Datashader instead generates a fixed-size (rasterized)
data structure (regardless of the original number of records) and
transfers that to the browser for display.</p>
      <p>In the following section we illustrate the capabilities of the
HoloViz family of tools for the purposes of movement data
exploration with a focus on the moving object trajectories using
a dataset of vessel tracking data (AIS) published by the Danish
Maritime Authority with more than 12 million location records.
Afterwards, we discuss current limitations that movement data
analysts should be aware of and have an outlook at what might
come next.</p>
    </sec>
    <sec id="sec-2">
      <title>2 ANALYSIS EXAMPLES</title>
      <p>The analysis examples covered in this demo are primarily
moverfocused. The first examples show point-based visualisations of
individual location records, as well as segment-based
visualizations of consecutive records in their geographic context. Later
examples show non-spatial visualizations that can provide further
insight into other important characteristics of tracking datasets,
such as sampling intervals and mover identification. The data
requirements for these examples are minimal: columns for mover
ID (MMSI in our AIS data example), timestamp (Timestamp),
location (Longitude and Latitude), and optionally speed (SOG which is
short for ‘speed over ground’ used in the histogram in Figure 1).</p>
    </sec>
    <sec id="sec-3">
      <title>2.1 Individual records</title>
      <p>Classic scatter plots, as shown in Figure 1, are popular tools
(particularly for early steps in the movement data exploration
process) to assess the spatial extent of the dataset, find outliers,
and identify gaps in the data coverage. This commonly
reoccurring task should therefore be straightforward to support data
analysts in their work. Indeed, as Listing 1 shows, creating a
scatterplot from a Pandas DataFrame and linking it to another plot (a
histogram of speed values in this case) requires only a few lines
of code9. To plot the locations on top of background map tiles,
the original latitude and longitude values need to be reprojected
to a metric coordinate system (Pseudo-Mercator, EPSG:3857).
For this purpose, Datashader provides the convenience function
lnglat_to_meters.</p>
      <p>The linked functionality is automatically created by calling
link_selections. The linking is based on the common IDs of records
in the DataFrame df that is visualized in both plots. Another
noteworthy feature is the simple way of arranging plots. For
example, arranging plots side-by-side in one notebook cell output
is achieved by connecting them using a simple plus sign (+).
To add geographic context, background map tiles can be added
as shown in the following example in Listing 2. The diferent
layers of the map plot are combined using simple multiplication
operators (*).</p>
      <p>Figure 1 also illustrates how the user can apply spatial filters
(by drawing a bounding box in the map view) and attribute-based
iflters (by selecting certain bin ranges in the histogram). This
way, location records of vessels travelling faster than 10 knots
are highlighted in the map.
8https://python-visualization.github.io/folium/
9Linked brushing demo notebook at
https://github.com/anitagraser/movingpandasexamples/blob/bmda2021/tech-demos/linked-brushing.ipynb
Listing 1: Source code for the linked scatter plot and
histogram in Figure 1
import p a n d a s a s pd
import h v p l o t . p a n d a s
from d a t a s h a d e r . u t i l s import l n g l a t _ t o _ m e t e r s
from h o l o v i e w s . s e l e c t i o n import l i n k _ s e l e c t i o n s</p>
    </sec>
    <sec id="sec-4">
      <title>2.2 Track segments</title>
      <p>
        Segment-based visualizations (Figure 2-3) enable more advance
analysis tasks, such as the identification of gaps in trajectories or
discovery of large jumps and other common movement data
quality issues [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. HoloViews provides a quick solution for plotting
segments between consecutive location records. In contrast to
other libraries the HoloViews solution does not create expensive
spatial geometry objects (such as Shapely10 LineStrings used by
MovingPandas). Instead, it relies on eficient implementations of
HoloViews Path objects. Analysts only have to take care of
creating distinct paths for each mover by setting a timestamp-based
index (to ensure the correct temporal order) and grouping the
Pandas DataFrame by mover ID, as shown in Listing 2.
      </p>
      <p>For more advanced segment-based analysis, for example, to
filter segments based on their length (to detect gaps and jumps), as
shown in Figure 3, additional computing steps need to be added.
This step (using a custom compute_segment_info function in the
notebook11) is currently considerably more computationally
expensive than the plotting steps because of the necessary pair-wise
operations such as distance computations between consecutive
records of the same mover.</p>
      <p>
        As the previously presented point and segment density map
examples show, Datashader is eficient at visualizing large sets
of points or paths in two-dimensional plots by rasterizing the
inputs. However, Datashader is of course not limited to plots
in geographic space. For example, Figure 4 shows a coordinate
change plot which visualizes the location change between
consecutive location records. These coordinate change plots can
help identify issues related to systematic changes in sampling
intervals [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] which can be caused, for example, by resampling
strategies that discard locations that are too close to the previous
reported location. Like the trajectory gap plot (Figure 3), this
coordinate change plot requires that the diferences in x and y
values are computed beforehand.
11Trajectory exploration notebook at
https://github.com/anitagraser/movingpandasexamples/blob/bmda2021/analysis-examples/5-exploration-protocol.ipynb
Of course, the visual analysis process does not stop at the
segment level. By dividing the raw continuous movement tracks
into individual trajectories, analysts can perform more advanced
analyses of trajectory properties, such as length, duration, start
and end time and location, mean speed, and overall direction.
The results of these trajectory-based analyses, of course, vary
depending on the method used to extract trajectories from the
raw continuous tracks, for example, by splitting at regular time
intervals, at stops, or at temporal gaps.
      </p>
      <p>A convenient hvplot tool for exploring the relationships
between trajectory properties are scatter matrixes (a combination
of scatter plots and histograms). For example, a scatter matrix of
trajectory duration versus start time, as shown in Figure 5, can
help identify issues related to unstable object IDs. These issues
can be caused by reassignment of IDs at certain points in time
(often at midnight) or in certain intervals which lead to visible
start time or duration clusters, respectively. These scatter
matrixes can be used to visualized the relationship between two or
more DataFrame columns. The scatter matrix in Figure 5 is not
datashaded, however, since trajectories are aggregates of the raw
tracking data, the resulting DataFrame of trajectory properties
(traj_df ) is much smaller than the original DataFrame of
individual location records (df ) and can therefore be plotted using
conventional means, that is, using hvplot without Datashader.
3</p>
    </sec>
    <sec id="sec-5">
      <title>DISCUSSION AND OUTLOOK</title>
      <p>
        Notebook-based visualizations continue to advance and many
of the limitations listed in prior work (such as a lack of linked
views [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ] or limited support for large datasets [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]) are already
addressed in HoloViz. However, currently, the cartographic
capabilities are rather limited when compared to dedicated visual
analytics tools or desktop geographic information systems. For
example, Datashader currently does not provide a convenient
way to color track segments based on their attribute values (as
shown in Figure 6).
      </p>
      <p>Using regular Pandas DataFrame, the size of the dataset is
limited by the available memory since the whole DataFrame has
to fit into memory. This may be addressed by adopting Dask</p>
      <p>DataFrames which can break down larger datasets into
manageable chunks.</p>
      <p>While Bokeh plots can usually be exported (that is saved as
images), this is currently not possible for map plot, as indicated
by a lack of a save icon in the Bokeh tool bar in Figures 2/3/6.
This makes the process of generating plots for publications less
convenient.</p>
      <p>
        While linked plots allow for intuitive data exploration, their
interactive nature makes it hard to keep track of the changes
and to reproduce results [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. Analysts need to be aware of these
limitations and select tools accordingly, meaning that static plots
may be preferable in settings where certain specific results need
to be reproducible by others.
      </p>
      <p>Further research will look into the possibility of creating
notebook-based animations of movement data, similar to what is
possible in desktop GIS such as QGIS with TimeManager
extension. This may be achieved using hvPlot’s support for streaming
DataFrames or other similar tools that still need to be evaluated.</p>
    </sec>
    <sec id="sec-6">
      <title>ACKNOWLEDGMENTS</title>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Natalia</given-names>
            <surname>Adrienko</surname>
          </string-name>
          and
          <string-name>
            <given-names>Gennady</given-names>
            <surname>Adrienko</surname>
          </string-name>
          .
          <year>2010</year>
          .
          <article-title>Spatial generalization and aggregation of massive movement data</article-title>
          .
          <source>IEEE Transactions on visualization and computer graphics 17</source>
          ,
          <issue>2</issue>
          (
          <year>2010</year>
          ),
          <fpage>205</fpage>
          -
          <lpage>219</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Gennady</given-names>
            <surname>Andrienko</surname>
          </string-name>
          , Natalia Andrienko, Peter Bak, Daniel Keim, Slava Kisilevich, and
          <string-name>
            <given-names>Stefan</given-names>
            <surname>Wrobel</surname>
          </string-name>
          .
          <year>2011</year>
          .
          <article-title>A conceptual framework and taxonomy of techniques for analyzing movement</article-title>
          .
          <source>Journal of Visual Languages &amp; Computing</source>
          <volume>22</volume>
          ,
          <issue>3</issue>
          (
          <year>2011</year>
          ),
          <fpage>213</fpage>
          -
          <lpage>232</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Gennady</given-names>
            <surname>Andrienko</surname>
          </string-name>
          , Natalia Andrienko, and
          <string-name>
            <given-names>Georg</given-names>
            <surname>Fuchs</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Understanding movement data quality</article-title>
          .
          <source>Journal of location Based services 10</source>
          ,
          <issue>1</issue>
          (
          <year>2016</year>
          ),
          <fpage>31</fpage>
          -
          <lpage>46</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <article-title>[4] The datashader development team</article-title>
          .
          <year>2020</year>
          . holoviz/datashader. https://doi.org/ 10.5281/zenodo.3844614
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <article-title>[5] The MovingPandas development team</article-title>
          .
          <year>2020</year>
          . anitagraser/movingpandas: v0.5rc1. https://doi.org/10.5281/zenodo.4051343
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Anita</given-names>
            <surname>Graser</surname>
          </string-name>
          .
          <year>2019</year>
          .
          <article-title>Movingpandas: Eficient structures for movement data in python</article-title>
          .
          <source>GIForum</source>
          <volume>1</volume>
          (
          <year>2019</year>
          ),
          <fpage>54</fpage>
          -
          <lpage>68</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Anita</given-names>
            <surname>Graser</surname>
          </string-name>
          and
          <string-name>
            <given-names>Melitta</given-names>
            <surname>Dragaschnig</surname>
          </string-name>
          .
          <year>2020</year>
          .
          <article-title>Exploring movement data in notebook environments</article-title>
          .
          <source>IEEE VIS 2020 Workshop on Information Visualization of Geospatial Networks, Flows and Movement (MoVis)</source>
          (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Anita</given-names>
            <surname>Graser</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Peter</given-names>
            <surname>Widhalm</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Melitta</given-names>
            <surname>Dragaschnig</surname>
          </string-name>
          .
          <year>2020</year>
          .
          <article-title>Extracting Patterns from Large Movement Datasets</article-title>
          .
          <source>GI_Forum</source>
          <year>2020</year>
          8 (
          <issue>2020</issue>
          ),
          <fpage>153</fpage>
          -
          <lpage>163</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <article-title>[9] The holoviews development team</article-title>
          .
          <year>2020</year>
          . holoviz/holoviews. https://doi.org/10. 5281/zenodo.596560
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <article-title>The holoviz development team</article-title>
          .
          <year>2020</year>
          . holoviz/hvplot. https://doi.org/10.5281/ zenodo.3634719
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>Rocio</surname>
            <given-names>Joo</given-names>
          </string-name>
          , Matthew E Boone, Thomas A Clay, Samantha C Patrick,
          <string-name>
            <surname>Susana</surname>
            Clusella-Trullas, and
            <given-names>Mathieu</given-names>
          </string-name>
          <string-name>
            <surname>Basille</surname>
          </string-name>
          .
          <year>2020</year>
          .
          <article-title>Navigating through the R packages for movement</article-title>
          .
          <source>Journal of Animal Ecology</source>
          <volume>89</volume>
          ,
          <issue>1</issue>
          (
          <year>2020</year>
          ),
          <fpage>248</fpage>
          -
          <lpage>267</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <article-title>The pandas development team</article-title>
          .
          <year>2020</year>
          . pandas-dev/pandas: Pandas. https: //doi.org/10.5281/zenodo.3509134
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>Luca</given-names>
            <surname>Pappalardo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F</given-names>
            <surname>Simini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G</given-names>
            <surname>Barlacchi</surname>
          </string-name>
          , and
          <string-name>
            <given-names>R</given-names>
            <surname>Pellungrini</surname>
          </string-name>
          .
          <year>2019</year>
          .
          <article-title>scikit-mobility: A Python library for the analysis, generation and risk assessment of mobility data</article-title>
          .
          <source>arXiv preprint arXiv:1907</source>
          .
          <volume>07062</volume>
          (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>Johanna</given-names>
            <surname>Schmidt</surname>
          </string-name>
          and
          <string-name>
            <given-names>Thomas</given-names>
            <surname>Ortner</surname>
          </string-name>
          .
          <year>2020</year>
          .
          <article-title>Visualization in Notebook-Style Interfaces</article-title>
          .
          <source>The Eurographics Association</source>
          (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>Wes</given-names>
            <surname>McKinney</surname>
          </string-name>
          .
          <year>2010</year>
          .
          <article-title>Data Structures for Statistical Computing in Python</article-title>
          .
          <source>In Proceedings of the 9th Python in Science Conference, Stéfan van der Walt and Jarrod Millman (Eds.)</source>
          .
          <fpage>56</fpage>
          -
          <lpage>61</lpage>
          . https://doi.org/10.25080/Majora-92bf1922-00a
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>