Skip to content

Commit 090eb5a

Browse files
committedJun 3, 2021
Clean up notebooks
1 parent 629712c commit 090eb5a

File tree

3 files changed

+25
-174
lines changed

3 files changed

+25
-174
lines changed
 

‎tutorials/1-getting-started.ipynb

+10-138
Original file line numberDiff line numberDiff line change
@@ -10,65 +10,9 @@
1010
"\n",
1111
"[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/anitagraser/movingpandas/master?filepath=tutorials/1-getting-started.ipynb)\n",
1212
"\n",
13-
"MovingPandas provides a trajectory datatype based on GeoPandas.\n",
14-
"The project home is at https://github.com/anitagraser/movingpandas\n",
13+
"This notebook demonstrates the current development version of MovingPandas.\n",
1514
"\n",
16-
"This tutorial presents some of the trajectory manipulation and visualization functions implemented in MovingPandas.\n",
17-
"\n",
18-
"After following this tutorial, you will have a basic understanding of what MovingPandas is and what it can be used for. You'll be ready to dive into application examples presented in the the follow-up tutorials:\n",
19-
"\n",
20-
"Tutorials for specific functionality:\n",
21-
"\n",
22-
"* [Trajectory aggregation (flow maps)](2-generalization-and-aggregation.ipynb)\n",
23-
"* [Stop detection](3-stop-detection.ipynb)"
24-
]
25-
},
26-
{
27-
"cell_type": "markdown",
28-
"metadata": {},
29-
"source": [
30-
"## Introduction\n",
31-
"\n",
32-
"MovingPandas follows the **trajectories = timeseries with geometries** approach of modeling movement data.\n",
33-
"\n",
34-
"A MovingPandas trajectory can be interpreted as either a time series of points or a time series of line segments.\n",
35-
"The line-based approach has many advantages for trajectory analysis and visualization. (For more detail, see e.g. Westermeier (2018))\n",
36-
"\n",
37-
"![alt text](./data/trajectory_length.PNG \"Trajectory length\")\n",
38-
"![alt text](./data/trajectory_context.PNG \"Trajectory context\")\n",
39-
"![alt text](./data/trajectory_distance.PNG \"Trajectory distance\")\n",
40-
"\n",
41-
"\n",
42-
"### References\n",
43-
"\n",
44-
"* Graser, A. (2019). MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science 2019, 1-2019, 54-68. doi:10.1553/giscience2019_01_s54. URL: https://www.austriaca.at/rootcollection?arp=0x003aba2b\n",
45-
"* Westermeier, E.M. (2018). Contextual Trajectory Modeling and Analysis. Master Thesis, Interfaculty Department of Geoinformatics, University of Salzburg.\n"
46-
]
47-
},
48-
{
49-
"cell_type": "markdown",
50-
"metadata": {},
51-
"source": [
52-
"## Jupyter notebook setup"
53-
]
54-
},
55-
{
56-
"cell_type": "code",
57-
"execution_count": null,
58-
"metadata": {},
59-
"outputs": [],
60-
"source": [
61-
"%matplotlib inline"
62-
]
63-
},
64-
{
65-
"cell_type": "code",
66-
"execution_count": null,
67-
"metadata": {},
68-
"outputs": [],
69-
"source": [
70-
"from IPython.core.display import display, HTML\n",
71-
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))"
15+
"**For tutorials using the latest release visit https://github.com/anitagraser/movingpandas-examples.**\n"
7216
]
7317
},
7418
{
@@ -91,29 +35,20 @@
9135
"sys.path.append(\"..\")\n",
9236
"import movingpandas as mpd\n",
9337
"print(mpd.__version__)\n",
38+
"import holoviews\n",
39+
"print(holoviews.__version__)\n",
40+
"import geoviews\n",
41+
"print(geoviews.__version__)\n",
9442
"\n",
9543
"import warnings\n",
9644
"#warnings.simplefilter(\"ignore\")"
9745
]
9846
},
99-
{
100-
"cell_type": "code",
101-
"execution_count": null,
102-
"metadata": {},
103-
"outputs": [],
104-
"source": [
105-
"CRS_METRIC = from_epsg(31256)"
106-
]
107-
},
10847
{
10948
"cell_type": "markdown",
11049
"metadata": {},
11150
"source": [
112-
"## Creating a trajectory from scratch\n",
113-
"\n",
114-
"Trajectory objects consist of a trajectory ID and a GeoPandas GeoDataFrame with a DatetimeIndex. The data frame therefore represents the trajectory data as a Pandas time series with associated point locations (and optional further attributes).\n",
115-
"\n",
116-
"Let's create a small toy trajectory to see how this works:"
51+
"## Creating a trajectory from scratch\n"
11752
]
11853
},
11954
{
@@ -128,7 +63,7 @@
12863
" {'geometry':Point(6,6), 't':datetime(2018,1,1,12,10,0)},\n",
12964
" {'geometry':Point(9,9), 't':datetime(2018,1,1,12,15,0)}\n",
13065
"]).set_index('t')\n",
131-
"geo_df = GeoDataFrame(df, crs=None)\n",
66+
"geo_df = GeoDataFrame(df, crs=31256)\n",
13267
"toy_traj = mpd.Trajectory(geo_df, 1)\n",
13368
"toy_traj.df"
13469
]
@@ -252,31 +187,6 @@
252187
"## Analyzing trajectories"
253188
]
254189
},
255-
{
256-
"cell_type": "markdown",
257-
"metadata": {},
258-
"source": [
259-
"MovingPandas provides many functions for trajectory analysis. \n",
260-
"\n",
261-
"To see all available functions of the MovingPandas.Trajectory class use:"
262-
]
263-
},
264-
{
265-
"cell_type": "code",
266-
"execution_count": null,
267-
"metadata": {},
268-
"outputs": [],
269-
"source": [
270-
"dir(mpd.Trajectory)"
271-
]
272-
},
273-
{
274-
"cell_type": "markdown",
275-
"metadata": {},
276-
"source": [
277-
"Functions that start with an underscore (e.g. ```__str__```) should not be called directly. All other functions are free to use."
278-
]
279-
},
280190
{
281191
"cell_type": "markdown",
282192
"metadata": {},
@@ -286,22 +196,6 @@
286196
"For example, let's have a look at the get_position_at() function:"
287197
]
288198
},
289-
{
290-
"cell_type": "code",
291-
"execution_count": null,
292-
"metadata": {},
293-
"outputs": [],
294-
"source": [
295-
"help(mpd.Trajectory.get_position_at)"
296-
]
297-
},
298-
{
299-
"cell_type": "markdown",
300-
"metadata": {},
301-
"source": [
302-
"When we call this method, the resulting point is directly rendered:"
303-
]
304-
},
305199
{
306200
"cell_type": "code",
307201
"execution_count": null,
@@ -401,16 +295,7 @@
401295
"outputs": [],
402296
"source": [
403297
"intersections = toy_traj.clip(polygon)\n",
404-
"print(intersections[0])"
405-
]
406-
},
407-
{
408-
"cell_type": "code",
409-
"execution_count": null,
410-
"metadata": {},
411-
"outputs": [],
412-
"source": [
413-
"intersections[0].plot(linewidth=5, capstyle='round')"
298+
"intersections"
414299
]
415300
},
416301
{
@@ -419,8 +304,7 @@
419304
"metadata": {},
420305
"outputs": [],
421306
"source": [
422-
"for index, row in toy_traj.df.iterrows():\n",
423-
" print(index - datetime(2000,1,1))"
307+
"intersections.trajectories[0].plot(linewidth=5, capstyle='round')"
424308
]
425309
},
426310
{
@@ -584,18 +468,6 @@
584468
"my_traj.hvplot(c='speed', width=700, height=400, line_width=7.0, tiles='StamenTonerBackground', cmap='Viridis', colorbar=True, clim=(0,20))"
585469
]
586470
},
587-
{
588-
"cell_type": "code",
589-
"execution_count": null,
590-
"metadata": {},
591-
"outputs": [],
592-
"source": [
593-
"import holoviews\n",
594-
"print(holoviews.__version__)\n",
595-
"import geoviews\n",
596-
"print(geoviews.__version__)"
597-
]
598-
},
599471
{
600472
"cell_type": "code",
601473
"execution_count": null,

‎tutorials/2-generalization-and-aggregation.ipynb

+4-11
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@
1010
"\n",
1111
"[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/anitagraser/movingpandas/master?filepath=tutorials/2-generalization-and-aggregation.ipynb)\n",
1212
"\n",
13-
"This tutorial covers trajectory generalization and aggregation using flow maps. "
14-
]
15-
},
16-
{
17-
"cell_type": "code",
18-
"execution_count": null,
19-
"metadata": {},
20-
"outputs": [],
21-
"source": [
22-
"%matplotlib inline"
13+
"This notebook demonstrates the current development version of MovingPandas.\n",
14+
"\n",
15+
"**For tutorials using the latest release visit https://github.com/anitagraser/movingpandas-examples.**"
2316
]
2417
},
2518
{
@@ -308,7 +301,7 @@
308301
"name": "python",
309302
"nbconvert_exporter": "python",
310303
"pygments_lexer": "ipython3",
311-
"version": "3.7.10"
304+
"version": "3.9.4"
312305
}
313306
},
314307
"nbformat": 4,

‎tutorials/3-stop-detection.ipynb

+11-25
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
"\n",
1111
"[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/anitagraser/movingpandas/master?filepath=tutorials/3-stop-detection.ipynb)\n",
1212
"\n",
13-
"There are no definitive answers when it comes to detecting / extracting stops from movement trajectories. Due to tracking inaccuracies, movement speed rarely goes to true zero. GPS tracks, for example, tend to keep moving around the object's stop location. \n",
14-
"\n",
15-
"Suitable stop definitions are also highly application dependent. For example, an application may be interested in analyzing trip purposes. To do so, analysts would be interested in stops that are longer than, for example, 5 minutes and may try to infer the purpose of the stop from the stop location and time. Shorter stops, such as delays at traffic lights, however would not be relevant for this appication. \n",
13+
"This notebook demonstrates the current development version of MovingPandas.\n",
1614
"\n",
17-
"In the MovingPandas **TrajectoryStopDetector** implementation, a stop is detected if the movement stays within an area of specified size for at least the specified duration."
15+
"**For tutorials using the latest release visit https://github.com/anitagraser/movingpandas-examples.**\n",
16+
"\n"
1817
]
1918
},
2019
{
@@ -24,25 +23,6 @@
2423
"## Setup"
2524
]
2625
},
27-
{
28-
"cell_type": "code",
29-
"execution_count": null,
30-
"metadata": {},
31-
"outputs": [],
32-
"source": [
33-
"%matplotlib inline"
34-
]
35-
},
36-
{
37-
"cell_type": "code",
38-
"execution_count": null,
39-
"metadata": {},
40-
"outputs": [],
41-
"source": [
42-
"from IPython.core.display import display, HTML\n",
43-
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))"
44-
]
45-
},
4626
{
4727
"cell_type": "code",
4828
"execution_count": null,
@@ -68,7 +48,7 @@
6848
"metadata": {},
6949
"outputs": [],
7050
"source": [
71-
"FSIZE = 500"
51+
"FSIZE = 350"
7252
]
7353
},
7454
{
@@ -105,7 +85,13 @@
10585
"cell_type": "markdown",
10686
"metadata": {},
10787
"source": [
108-
"## Stop Detection with a SingleTrajectory"
88+
"## Stop Detection with a SingleTrajectory\n",
89+
"\n",
90+
"There are no definitive answers when it comes to detecting / extracting stops from movement trajectories. Due to tracking inaccuracies, movement speed rarely goes to true zero. GPS tracks, for example, tend to keep moving around the object's stop location. \n",
91+
"\n",
92+
"Suitable stop definitions are also highly application dependent. For example, an application may be interested in analyzing trip purposes. To do so, analysts would be interested in stops that are longer than, for example, 5 minutes and may try to infer the purpose of the stop from the stop location and time. Shorter stops, such as delays at traffic lights, however would not be relevant for this appication. \n",
93+
"\n",
94+
"In the MovingPandas **TrajectoryStopDetector** implementation, a stop is detected if the movement stays within an area of specified size for at least the specified duration."
10995
]
11096
},
11197
{

0 commit comments

Comments
 (0)
Please sign in to comment.