|
1 | 1 | { |
2 | 2 | "cells": [ |
3 | 3 | { |
| 4 | + "attachments": {}, |
4 | 5 | "cell_type": "markdown", |
5 | 6 | "metadata": {}, |
6 | 7 | "source": [ |
|
47 | 48 | "outputs": [], |
48 | 49 | "source": [ |
49 | 50 | "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')" |
51 | 52 | ] |
52 | 53 | }, |
53 | 54 | { |
| 55 | + "attachments": {}, |
54 | 56 | "cell_type": "markdown", |
55 | 57 | "metadata": {}, |
56 | 58 | "source": [ |
|
65 | 67 | "source": [ |
66 | 68 | "xmin, xmax, ymin, ymax = 116.365035,116.3702945,39.904675,39.907728\n", |
67 | 69 | "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", |
69 | 70 | "\n", |
70 | | - "my_traj = traj_collection.trajectories[2]\n", |
| 71 | + "my_traj = tc.trajectories[2]\n", |
71 | 72 | "intersections = my_traj.clip(polygon)\n", |
72 | 73 | " \n", |
73 | 74 | "print(\"Found {} intersections\".format(len(intersections)))" |
|
80 | 81 | "outputs": [], |
81 | 82 | "source": [ |
82 | 83 | "ax = my_traj.plot()\n", |
83 | | - "polygon_gdf.plot(ax=ax, color='lightgray')\n", |
| 84 | + "gpd.GeoSeries(polygon).plot(ax=ax, color='lightgray')\n", |
84 | 85 | "intersections.plot(ax=ax, color='red', linewidth=5)" |
85 | 86 | ] |
86 | 87 | }, |
87 | 88 | { |
| 89 | + "attachments": {}, |
88 | 90 | "cell_type": "markdown", |
89 | 91 | "metadata": {}, |
90 | 92 | "source": [ |
91 | 93 | "## Clipping a TrajectoryCollection" |
92 | 94 | ] |
93 | 95 | }, |
94 | 96 | { |
| 97 | + "attachments": {}, |
95 | 98 | "cell_type": "markdown", |
96 | 99 | "metadata": {}, |
97 | 100 | "source": [ |
|
104 | 107 | "metadata": {}, |
105 | 108 | "outputs": [], |
106 | 109 | "source": [ |
107 | | - "clipped = traj_collection.clip(polygon)\n", |
| 110 | + "clipped = tc.clip(polygon)\n", |
108 | 111 | "clipped" |
109 | 112 | ] |
110 | 113 | }, |
|
118 | 121 | ] |
119 | 122 | }, |
120 | 123 | { |
| 124 | + "attachments": {}, |
121 | 125 | "cell_type": "markdown", |
122 | 126 | "metadata": {}, |
123 | 127 | "source": [ |
|
142 | 146 | "metadata": {}, |
143 | 147 | "outputs": [], |
144 | 148 | "source": [ |
145 | | - "my_traj = traj_collection.trajectories[2]\n", |
| 149 | + "my_traj = tc.trajectories[2]\n", |
146 | 150 | "intersections = my_traj.intersection(polygon_feature)\n", |
147 | 151 | "intersections" |
148 | 152 | ] |
|
180 | 184 | "name": "python", |
181 | 185 | "nbconvert_exporter": "python", |
182 | 186 | "pygments_lexer": "ipython3", |
183 | | - "version": "3.10.8" |
| 187 | + "version": "3.10.10" |
184 | 188 | } |
185 | 189 | }, |
186 | 190 | "nbformat": 4, |
|
0 commit comments