The aim of this post is to show how data generated by the Propensity to Cycle Tool can be used to analyse where short car journeys happen.

The first stage is to download some data:

# if this fails, navigate to the following link and download manually:
# https://github.com/npct/pct-data/raw/master/liverpool-city-region/l.Rds
u_pct = "https://github.com/npct/pct-data/raw/master/liverpool-city-region/l.Rds"

download.file(u_pct, "l.Rds")
library(tmap)
library(stplanr) # loads sp
## Loading required package: sp
l = readRDS("l.Rds")
tm_shape(l) + tm_lines(lwd = "all", )

What you see is a plot of the travel pattern in Liverpool City Region.

Let’s see where walking is common:

sel_walk = l$foot > 9
l_walk = l[sel_walk,]
plot(l)
plot(l_walk, add = T, col = "red")

library(dplyr) 
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Now let’s convert the data to class ‘sf’ and find short trips (< 1.5 km) where driving > walking:

library(sf)
## Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.3.2 r15302
l_sf = st_as_sf(l)
l_sf$distsf = as.numeric(st_length(l_sf))
l_drive_short = l_sf %>% 
  filter(distsf < 2000) %>% 
  filter(car_driver > foot)

The results are plotted below:

library(tmap)
tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(l_drive_short) +
  tm_lines(lwd = "all")