Skip to content

Commit d1284c4

Browse files
committed
Bonus exercise
1 parent 84e712f commit d1284c4

File tree

4 files changed

+75
-1
lines changed

4 files changed

+75
-1
lines changed

README.qmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The ultimate goal is more effective transport planning investments and decisions
4040
<details>
4141
<summary>Python Environment Setup</summary>
4242

43+
If you're using the code via the
4344

4445
Some Quarto documents in this repository utilize Python code. To ensure these documents render correctly, it's recommended to set up a Python virtual environment and install the necessary dependencies.
4546

bonus.qmd

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: "Bonus Content"
3+
format: html
4+
execute:
5+
eval: false
6+
---
7+
8+
## Thanks for attending!
9+
10+
We hope you enjoyed the course.
11+
You can find all the materials and updates on the [course website](https://itsleeds.github.io/ai4transport/).
12+
13+
Here is a quick visualisation of the data we explored:
14+
15+
### Places
16+
17+
```{r}
18+
#| label: map-places
19+
#| message: false
20+
#| warning: false
21+
library(sf)
22+
library(mapview)
23+
# Read places data
24+
places = read_sf("https://github.com/itsleeds/ai4transport/raw/main/data/places.geojson")
25+
# Visualise places
26+
mapview(places, zcol = "name")
27+
```
28+
29+
![](images/paste-11.png)
30+
31+
### OD Data
32+
33+
```{r}
34+
library(tidyverse)
35+
library(sf)
36+
```
37+
38+
<details>
39+
40+
<summary>Download and prepare OD data for TfSE</summary>
41+
42+
```{r}
43+
#| label: plot-od
44+
#| message: false
45+
#| warning: false
46+
library(od)
47+
48+
od = read_csv("od_tfse_2021.csv")
49+
zones = read_sf("tfse_msoas.gpkg")
50+
51+
# Check 1st column of zones matches 'o' and 'd' in od
52+
summary(zones[[1]] %in% c(od$o, od$d))
53+
od_sf = od_to_sf(od, zones)
54+
od_sf = od_sf |>
55+
mutate(`% Car` = Car / (Car + Bicycle + Walking + Bus + Train))
56+
od_sf$length = sf::st_length(od_sf) |> as.numeric()
57+
sf::write_sf(od_sf, "od_tfse_2021_sf.gpkg", delete_dsn = TRUE)
58+
```
59+
60+
</details>
61+
62+
```{r}
63+
od_sf = read_sf("od_tfse_2021_sf.gpkg")
64+
od_sf |>
65+
filter(Car > 10 & length > 10 * 1000) |>
66+
arrange(desc(`% Car`)) |>
67+
ggplot() +
68+
geom_sf(aes(colour = `% Car`)) +
69+
scale_colour_viridis_c(direction = -1) +
70+
theme_minimal()
71+
```
72+
73+
![OD commuting flows in TfSE, coloured by % car use](https://itsleeds.github.io/ai4transport/images/tfse_od_map.png)

images/paste-11.png

889 KB
Loading

tfse_boundary.geojson

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)