Skip to content

Commit ea673c3

Browse files
committed
Misc updates
1 parent 5ee59b3 commit ea673c3

8 files changed

+64
-37
lines changed

1-tutorials/1-getting-started.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@
274274
" }\n",
275275
")\n",
276276
"gdf = gpd.GeoDataFrame(df, crs=4326)\n",
277-
"trajs = mpd.TrajectoryCollection(gdf, traj_id_col='trajectory_id', t='t')\n",
278-
"trajs"
277+
"tc = mpd.TrajectoryCollection(gdf, traj_id_col='trajectory_id', t='t')\n",
278+
"tc"
279279
]
280280
},
281281
{
@@ -284,7 +284,7 @@
284284
"metadata": {},
285285
"outputs": [],
286286
"source": [
287-
"trajs.hvplot()"
287+
"tc.hvplot()"
288288
]
289289
},
290290
{
@@ -294,8 +294,8 @@
294294
"outputs": [],
295295
"source": [
296296
"min_duration = timedelta(minutes=1)\n",
297-
"trajs.trajectories = [traj for traj in trajs if traj.get_duration() > min_duration]\n",
298-
"trajs"
297+
"tc.trajectories = [traj for traj in tc if traj.get_duration() > min_duration]\n",
298+
"tc"
299299
]
300300
},
301301
{

1-tutorials/2-computing-speed.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"outputs": [],
153153
"source": [
154154
"gdf = read_file('../data/geolife_small.gpkg')\n",
155-
"trajs = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')"
155+
"tc = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')"
156156
]
157157
},
158158
{
@@ -161,7 +161,7 @@
161161
"metadata": {},
162162
"outputs": [],
163163
"source": [
164-
"my_traj = trajs.trajectories[1]"
164+
"my_traj = tc.trajectories[1]"
165165
]
166166
},
167167
{
@@ -205,7 +205,7 @@
205205
"metadata": {},
206206
"outputs": [],
207207
"source": [
208-
"trajs.plot(column='speed', linewidth=5, capstyle='round', legend=True, vmax=20)"
208+
"tc.plot(column='speed', linewidth=5, capstyle='round', legend=True, vmax=20)"
209209
]
210210
},
211211
{

1-tutorials/4-exporting-trajectories.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"outputs": [],
4949
"source": [
5050
"gdf = read_file('../data/geolife_small.gpkg')\n",
51-
"trajs = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')\n",
52-
"trajs"
51+
"tc = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')\n",
52+
"tc"
5353
]
5454
},
5555
{
@@ -68,7 +68,7 @@
6868
"metadata": {},
6969
"outputs": [],
7070
"source": [
71-
"trajs.to_point_gdf()"
71+
"tc.to_point_gdf()"
7272
]
7373
},
7474
{
@@ -85,7 +85,7 @@
8585
"metadata": {},
8686
"outputs": [],
8787
"source": [
88-
"trajs.to_line_gdf()"
88+
"tc.to_line_gdf()"
8989
]
9090
},
9191
{
@@ -102,7 +102,7 @@
102102
"metadata": {},
103103
"outputs": [],
104104
"source": [
105-
"trajs.to_traj_gdf(wkt=True)"
105+
"tc.to_traj_gdf(wkt=True)"
106106
]
107107
},
108108
{
@@ -111,7 +111,7 @@
111111
"metadata": {},
112112
"outputs": [],
113113
"source": [
114-
"trajs.to_traj_gdf(agg={'tracker':'mode', 'sequence':['min', 'max']})"
114+
"tc.to_traj_gdf(agg={'tracker':'mode', 'sequence':['min', 'max']})"
115115
]
116116
},
117117
{
@@ -136,7 +136,7 @@
136136
"metadata": {},
137137
"outputs": [],
138138
"source": [
139-
"export_gdf = trajs.to_traj_gdf(agg={'sequence':['min', 'max']})\n",
139+
"export_gdf = tc.to_traj_gdf(agg={'sequence':['min', 'max']})\n",
140140
"export_gdf.to_file(\"temp.gpkg\", layer='trajectories', driver=\"GPKG\")"
141141
]
142142
},

1-tutorials/5-intersecting-with-polygons.ipynb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"metadata": {},
67
"source": [
@@ -47,10 +48,11 @@
4748
"outputs": [],
4849
"source": [
4950
"gdf = read_file('../data/geolife_small.gpkg')\n",
50-
"traj_collection = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')"
51+
"tc = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')"
5152
]
5253
},
5354
{
55+
"attachments": {},
5456
"cell_type": "markdown",
5557
"metadata": {},
5658
"source": [
@@ -65,9 +67,8 @@
6567
"source": [
6668
"xmin, xmax, ymin, ymax = 116.365035,116.3702945,39.904675,39.907728\n",
6769
"polygon = Polygon([(xmin,ymin), (xmin,ymax), (xmax,ymax), (xmax,ymin), (xmin,ymin)])\n",
68-
"polygon_gdf = GeoDataFrame(pd.DataFrame([{'geometry':polygon, 'id':1}]), crs=31256)\n",
6970
"\n",
70-
"my_traj = traj_collection.trajectories[2]\n",
71+
"my_traj = tc.trajectories[2]\n",
7172
"intersections = my_traj.clip(polygon)\n",
7273
" \n",
7374
"print(\"Found {} intersections\".format(len(intersections)))"
@@ -80,18 +81,20 @@
8081
"outputs": [],
8182
"source": [
8283
"ax = my_traj.plot()\n",
83-
"polygon_gdf.plot(ax=ax, color='lightgray')\n",
84+
"gpd.GeoSeries(polygon).plot(ax=ax, color='lightgray')\n",
8485
"intersections.plot(ax=ax, color='red', linewidth=5)"
8586
]
8687
},
8788
{
89+
"attachments": {},
8890
"cell_type": "markdown",
8991
"metadata": {},
9092
"source": [
9193
"## Clipping a TrajectoryCollection"
9294
]
9395
},
9496
{
97+
"attachments": {},
9598
"cell_type": "markdown",
9699
"metadata": {},
97100
"source": [
@@ -104,7 +107,7 @@
104107
"metadata": {},
105108
"outputs": [],
106109
"source": [
107-
"clipped = traj_collection.clip(polygon)\n",
110+
"clipped = tc.clip(polygon)\n",
108111
"clipped"
109112
]
110113
},
@@ -118,6 +121,7 @@
118121
]
119122
},
120123
{
124+
"attachments": {},
121125
"cell_type": "markdown",
122126
"metadata": {},
123127
"source": [
@@ -142,7 +146,7 @@
142146
"metadata": {},
143147
"outputs": [],
144148
"source": [
145-
"my_traj = traj_collection.trajectories[2]\n",
149+
"my_traj = tc.trajectories[2]\n",
146150
"intersections = my_traj.intersection(polygon_feature)\n",
147151
"intersections"
148152
]
@@ -180,7 +184,7 @@
180184
"name": "python",
181185
"nbconvert_exporter": "python",
182186
"pygments_lexer": "ipython3",
183-
"version": "3.10.8"
187+
"version": "3.10.10"
184188
}
185189
},
186190
"nbformat": 4,

1-tutorials/6-splitting-trajectories.ipynb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"metadata": {},
67
"source": [
@@ -51,7 +52,7 @@
5152
"outputs": [],
5253
"source": [
5354
"gdf = read_file('../data/geolife_small.gpkg')\n",
54-
"traj_collection = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')"
55+
"tc = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')"
5556
]
5657
},
5758
{
@@ -60,7 +61,7 @@
6061
"metadata": {},
6162
"outputs": [],
6263
"source": [
63-
"my_traj = traj_collection.trajectories[1]\n",
64+
"my_traj = tc.trajectories[1]\n",
6465
"print(my_traj)"
6566
]
6667
},
@@ -74,13 +75,15 @@
7475
]
7576
},
7677
{
78+
"attachments": {},
7779
"cell_type": "markdown",
7880
"metadata": {},
7981
"source": [
8082
"## ObservationGapSplitter"
8183
]
8284
},
8385
{
86+
"attachments": {},
8487
"cell_type": "markdown",
8588
"metadata": {},
8689
"source": [
@@ -118,13 +121,15 @@
118121
]
119122
},
120123
{
124+
"attachments": {},
121125
"cell_type": "markdown",
122126
"metadata": {},
123127
"source": [
124128
"## StopSplitter"
125129
]
126130
},
127131
{
132+
"attachments": {},
128133
"cell_type": "markdown",
129134
"metadata": {},
130135
"source": [
@@ -162,13 +167,15 @@
162167
]
163168
},
164169
{
170+
"attachments": {},
165171
"cell_type": "markdown",
166172
"metadata": {},
167173
"source": [
168174
"## SpeedSplitter"
169175
]
170176
},
171177
{
178+
"attachments": {},
172179
"cell_type": "markdown",
173180
"metadata": {},
174181
"source": [
@@ -229,7 +236,7 @@
229236
"name": "python",
230237
"nbconvert_exporter": "python",
231238
"pygments_lexer": "ipython3",
232-
"version": "3.10.8"
239+
"version": "3.10.10"
233240
}
234241
},
235242
"nbformat": 4,

1-tutorials/7-generalizing-trajectories.ipynb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"metadata": {},
67
"source": [
@@ -57,7 +58,7 @@
5758
"outputs": [],
5859
"source": [
5960
"gdf = read_file('../data/geolife_small.gpkg')\n",
60-
"traj_collection = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')"
61+
"tc = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')"
6162
]
6263
},
6364
{
@@ -66,7 +67,7 @@
6667
"metadata": {},
6768
"outputs": [],
6869
"source": [
69-
"original_traj = traj_collection.trajectories[1]\n",
70+
"original_traj = tc.trajectories[1]\n",
7071
"print(original_traj)"
7172
]
7273
},
@@ -80,13 +81,15 @@
8081
]
8182
},
8283
{
84+
"attachments": {},
8385
"cell_type": "markdown",
8486
"metadata": {},
8587
"source": [
8688
"## Spatial generalization (DouglasPeuckerGeneralizer)"
8789
]
8890
},
8991
{
92+
"attachments": {},
9093
"cell_type": "markdown",
9194
"metadata": {},
9295
"source": [
@@ -123,6 +126,7 @@
123126
]
124127
},
125128
{
129+
"attachments": {},
126130
"cell_type": "markdown",
127131
"metadata": {},
128132
"source": [
@@ -160,6 +164,7 @@
160164
]
161165
},
162166
{
167+
"attachments": {},
163168
"cell_type": "markdown",
164169
"metadata": {},
165170
"source": [
@@ -176,6 +181,7 @@
176181
]
177182
},
178183
{
184+
"attachments": {},
179185
"cell_type": "markdown",
180186
"metadata": {},
181187
"source": [
@@ -217,7 +223,7 @@
217223
"name": "python",
218224
"nbconvert_exporter": "python",
219225
"pygments_lexer": "ipython3",
220-
"version": "3.10.8"
226+
"version": "3.10.10"
221227
}
222228
},
223229
"nbformat": 4,

0 commit comments

Comments
 (0)