You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: routing.qmd
+60-27Lines changed: 60 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,8 @@ engine: knitr
11
11
::: callout-note
12
12
### OD data
13
13
14
-
If you have **travel survey** data, for some exercises you may use that one. See also [Jittering](jittering.qmd), if needed.
14
+
If you have **travel survey** data, for some exercises you may use that one.
15
+
See also [Jittering](jittering.qmd), if needed.
15
16
16
17
For all the other, we can simply use **census** data.
17
18
:::
@@ -26,11 +27,15 @@ nrow(POINTS) # 2822
26
27
sum(POINTS$residents) # 545.796
27
28
```
28
29
29
-
With census data, each statistical unit represents \~300 residents. In Lisbon, we have 2822 census units.
30
+
With census data, each statistical unit represents \~300 residents.
31
+
In Lisbon, we have 2822 census units.
30
32
31
-
Routing between all origins and destinations (2822 x 2822 = **7.963.684 OD pairs**) can potentially be a long-duration process. Nothing that r5r wouldn't handle! 🙂
33
+
Routing between all origins and destinations (2822 x 2822 = **7.963.684 OD pairs**) can potentially be a long-duration process.
34
+
Nothing that r5r wouldn't handle!
35
+
🙂
32
36
33
-
But here we will consider a `city_center` location, and route our census population to the city center. Search in an online map the coordinates for a point that you would like to consider your attractor.
37
+
But here we will consider a `city_center` location, and route our census population to the city center.
38
+
Search in an online map the coordinates for a point that you would like to consider your attractor.
34
39
35
40
```{r}
36
41
# Create origin point - Baixa / Downtown
@@ -86,7 +91,8 @@ hist(ttm_car$travel_time_p50)
86
91
87
92
By car, all the 2822 points with residents are able to be reach from city center.
88
93
89
-
In free-flow, the longest trip takes 26 minutes. 50% of the trips are shorter than 12 minutes.
The longest trip takes 120 minutes (equal to the max travel time). The time distribution is pretty even.
133
+
The longest trip takes 120 minutes (equal to the max travel time).
134
+
The time distribution is pretty even.
128
135
129
136
### Bike
130
137
131
138
When considering **bike** trips, we can also set a maximum level of traffic stress [@LTSmineta] that cyclists will tolerate.
132
139
133
140
#### LTS
134
141
135
-
A value of 1 means cyclists will only travel through the quietest streets, while a value of 4 indicates cyclists can travel through any road. **Defaults to 2, which can be very restrictive in Lisbon (depends on your case study).**
142
+
A value of 1 means cyclists will only travel through the quietest streets, while a value of 4 indicates cyclists can travel through any road.
143
+
**Defaults to 2, which can be very restrictive in Lisbon (depends on your case study).**
136
144
137
145
From @Pereira2021r5r:
138
146
139
-
When cycling is enabled in `R5` (by passing the value `BIKE` to either `mode` or `mode_egress`), setting `max_lts` will allow cycling only on streets with a given level of danger/stress. Setting `max_lts` to 1, for example, will allow cycling only on separated bicycle infrastructure or low-traffic streets and routing will revert to walking when traversing any links with LTS exceeding 1. Setting `max_lts` to 3 will allow cycling on links with LTS 1, 2 or 3. Routing also reverts to walking if the street segment is tagged as non-bikable in OSM (e.g. a staircase), independently of the specified max LTS.
147
+
When cycling is enabled in `R5` (by passing the value `BIKE` to either `mode` or `mode_egress`), setting `max_lts` will allow cycling only on streets with a given level of danger/stress.
148
+
Setting `max_lts` to 1, for example, will allow cycling only on separated bicycle infrastructure or low-traffic streets and routing will revert to walking when traversing any links with LTS exceeding 1.
149
+
Setting `max_lts` to 3 will allow cycling on links with LTS 1, 2 or 3.
150
+
Routing also reverts to walking if the street segment is tagged as non-bikable in OSM (e.g. a staircase), independently of the specified max LTS.
140
151
141
-
The default methodology for assigning LTS values to network edges is based on commonly tagged attributes of OSM ways. See more info about LTS in the original documentation of R5 from Conveyal at <https://docs.conveyal.com/learn-more/traffic-stress>. In summary:
152
+
The default methodology for assigning LTS values to network edges is based on commonly tagged attributes of OSM ways.
153
+
See more info about LTS in the original documentation of R5 from Conveyal at <https://docs.conveyal.com/learn-more/traffic-stress>.
154
+
In summary:
142
155
143
-
-**LTS 1**: Tolerable for children. This includes low-speed, low-volume streets, as well as those with separated bicycle facilities (such as parking-protected lanes or cycle tracks).
156
+
-**LTS 1**: Tolerable for children.
157
+
This includes low-speed, low-volume streets, as well as those with separated bicycle facilities (such as parking-protected lanes or cycle tracks).
144
158
145
-
-**LTS 2**: Tolerable for the mainstream adult population. This includes streets where cyclists have dedicated lanes and only have to interact with traffic at formal crossing.
159
+
-**LTS 2**: Tolerable for the mainstream adult population.
160
+
This includes streets where cyclists have dedicated lanes and only have to interact with traffic at formal crossing.
146
161
147
-
-**LTS 3**: Tolerable for "enthused and confident" cyclists. This includes streets which may involve close proximity to moderate- or high-speed vehicular traffic.
162
+
-**LTS 3**: Tolerable for "enthused and confident" cyclists.
163
+
This includes streets which may involve close proximity to moderate- or high-speed vehicular traffic.
148
164
149
-
-**LTS 4**: Tolerable only for "strong and fearless" cyclists. This includes streets where cyclists are required to mix with moderate- to high-speed vehicular traffic.
165
+
-**LTS 4**: Tolerable only for "strong and fearless" cyclists.
166
+
This includes streets where cyclists are required to mix with moderate- to high-speed vehicular traffic.
150
167
151
168
For advanced users, you can provide custom LTS values by adding a tag `<key = "lts">` to the `osm.pbf` file.
152
169
@@ -184,19 +201,23 @@ When estimating travel time with public transit, some considerations should be p
184
201
185
202
-**Date and time** of the trips
186
203
187
-
- Which **modes** are allowed? All or just some of PT?
204
+
- Which **modes** are allowed?
205
+
All or just some of PT?
188
206
189
207
- How many **transfers** are allowed
190
208
191
-
- How to **get to the PT stop**? By foot, bike or car? The same from the last stop to the destination
209
+
- How to **get to the PT stop**?
210
+
By foot, bike or car?
211
+
The same from the last stop to the destination
192
212
193
213
- How many minutes it is **reasonable to walk** (of bike) in max during the whole trip?
194
214
195
215
- Is my best time-travel estimate the same, if I consider a 5min **time-window** period or a 30min time-window period?
196
216
197
217
#### Date and time
198
218
199
-
This is a very relevant parameter (`departure_datetime)`. If your selected date is not part of your GTFS calendar, you will not be able to estimate travel by **PT** on those dates.
219
+
This is a very relevant parameter (`departure_datetime)`.
220
+
If your selected date is not part of your GTFS calendar, you will not be able to estimate travel by **PT** on those dates.
200
221
201
222
##### Confirm service calendar
202
223
@@ -219,7 +240,8 @@ uses stop_times (no frequencies)
219
240
# shapes 307
220
241
```
221
242
222
-
My GTFS runs from **2025-09-01** to **2025-12-01**. I will select a **working day**, and a **peak hour** for this exercises.
243
+
My GTFS runs from **2025-09-01** to **2025-12-01**.
244
+
I will select a **working day**, and a **peak hour** for this exercises.
The option `TRANSIT` automatically considers **all public transport modes** available.
@@ -239,13 +262,16 @@ When I change this parameter, my results may be totally different.
239
262
240
263
#### Transfers
241
264
242
-
The maximum number of public transport rides allowed in the same trip. The `max_rides` defaults to 3. Consider a plausible number, and take into consideration that shifting from one metro line to other will be considered as 2 rides.
265
+
The maximum number of public transport rides allowed in the same trip.
266
+
The `max_rides` defaults to 3.
267
+
Consider a plausible number, and take into consideration that shifting from one metro line to other will be considered as 2 rides.
243
268
244
269
#### Egress mode and max walk time
245
270
246
271
The transport mode used after egress from the last public transport.\
247
272
It can be either `WALK`, `BICYCLE` or `CAR`.\
248
-
Defaults to `WALK`. Ignored when public transport is not used.
273
+
Defaults to `WALK`.
274
+
Ignored when public transport is not used.
249
275
250
276
The `max_walk_time` (or bike or car) time (in minutes) to access and egress the transit network, to make transfers within the network or to complete walk-only trips.
251
277
@@ -257,7 +283,8 @@ To calculate the travel time from A to B, or to calculate the accessibility leve
257
283
258
284
Even a small difference, say leaving at `10:00am` or `10:04am` might importantly change travel time and accessibility estimates depending on when a person departs relative to when a public transport vehicle arrives, and how well transfers are coordinated given a service timetable.
259
285
260
-
When `time_window` is set, R^5^ computes multiple travel times / accessibility estimates starting at the specified `departure_datetime` and within the `time_window` selected by the user. By default, `r5r` will generate **one estimate per minute**.
286
+
When `time_window` is set, R^5^ computes multiple travel times / accessibility estimates starting at the specified `departure_datetime` and within the `time_window` selected by the user.
287
+
By default, `r5r` will generate **one estimate per minute**.
261
288
262
289
By default, r5r results have the **50th percentile** of travel time.
50% of the trips take less than 31 minutes. The distribution is pretty normal.
333
+
50% of the trips take less than 31 minutes.
334
+
The distribution is pretty normal.
307
335
308
336
::: {.callout-tip appearance="simple"}
309
337
Try to change some parameters, such as the `max_rides` or the `max_trip_duration` and compare the results.
@@ -313,13 +341,15 @@ Try to change some parameters, such as the `max_rides` or the `max_trip_duration
313
341
314
342
With the [`detailed_itineraries`](https://ipeagit.github.io/r5r/reference/detailed_itineraries.html)`()`, we can extract more information about each trip, such as:
315
343
316
-
- Which modes were used for trip *x*? In which order?
344
+
- Which modes were used for trip *x*?
345
+
In which order?
317
346
318
347
- What is the duration for each leg?
319
348
320
349
- Which route (shape) was estimated?
321
350
322
-
This function is also pretty flexible and allows to see more details. Also, because of this, it may require some **more processing cost**.
351
+
This function is also pretty flexible and allows to see more details.
352
+
Also, because of this, it may require some **more processing cost**.
323
353
324
354
### Multi-modal legs
325
355
@@ -409,7 +439,8 @@ Click on each segment to analyse the details, in particular the segment duration
409
439
410
440
## Circuity
411
441
412
-
**Circuity** measures how direct or indirect a travel route is compared to the straight-line (Euclidean) distance between an origin and a destination. It reflects the efficiency of the transport network in providing direct connections.
442
+
**Circuity** measures how direct or indirect a travel route is compared to the straight-line (Euclidean) distance between an origin and a destination.
443
+
It reflects the efficiency of the transport network in providing direct connections.
413
444
414
445
The **circuity index** (C) measures how indirect a route is compared to the straight-line distance between an origin and a destination, and is defined as:
415
446
@@ -428,7 +459,8 @@ In this exercise, circuity will be estimated separately for **car, walking, cycl
428
459
429
460
### Euclidean distances
430
461
431
-
First we will create lines connecting the survey locations to the university, using the `st_nearest_points()` function. This function finds returns the nearest points between two geometries, and creates a line between them.
462
+
First we will create lines connecting the survey locations to the university, using the `st_nearest_points()` function.
463
+
This function finds returns the nearest points between two geometries, and creates a line between them.
@@ -670,7 +702,8 @@ Finally, we visualized and aggregated routes using `stplanr::overline()`, combin
670
702
671
703
## Stop
672
704
673
-
`r5r` objects are still allocated to any amount of memory previously set after they are done with their calculations. In order to remove an existing `r5r` object and reallocate the memory it had been using, we use the `stop_r5` function followed by a call to Java’s garbage collector, as follows:
705
+
`r5r` objects are still allocated to any amount of memory previously set after they are done with their calculations.
706
+
In order to remove an existing `r5r` object and reallocate the memory it had been using, we use the `stop_r5` function followed by a call to Java’s garbage collector, as follows:
0 commit comments