Skip to content
/ pct Public
forked from npct/pct-team

Development of a 'Propensity to Cycle Tool'

License

Notifications You must be signed in to change notification settings

audev/pct

This branch is 468 commits behind npct/pct-team:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3f9fd45 · Jun 21, 2016
Jun 8, 2015
Apr 29, 2016
Jun 15, 2015
May 16, 2016
Apr 30, 2016
Mar 10, 2015
Apr 30, 2016
May 20, 2016
May 27, 2016
Jun 21, 2016
Apr 9, 2015
Feb 16, 2016
Mar 15, 2016
May 20, 2016
Jul 15, 2015
Jun 8, 2015
Jun 2, 2015
Jan 31, 2015
Apr 30, 2016
Dec 4, 2015
Jan 23, 2016
Jan 23, 2016
Jun 15, 2015
Dec 13, 2015
Oct 5, 2015
Mar 25, 2015
Feb 21, 2015
Aug 25, 2015
Feb 16, 2016
Jan 23, 2015
May 20, 2016
Oct 5, 2015

Repository files navigation

pct: Propensity to cycle tool

This repo contains miscellaneous R scipts, documentation and figures related to the Propensity to Cycle Tool.

This repo is not needed to run the PCT on your computer. For that, see pct-load.

Information on the PCT

The project is funded by the Department for Transport (DfT) so the initial case studies will be taken from the UK. However, it is expected that the methods will be of use elsewhere. For that reason, attempts have been made to make the examples generalisable. All examples presented here are reproducible using data stored in the pct-data repository.

A simple example

If you run the following lines of code on from a local copy of the pct repository you will get the same results.

source("set-up.R")
# load some flow data
fleeds <- read.csv("README_files/data/sample-leeds-centre-dists.csv")
# load the zones
leeds <- readOGR("README_files/data", "leeds-central-sample")
## OGR data source with driver: ESRI Shapefile 
## Source: "README_files/data", layer: "leeds-central-sample"
## with 25 features
## It has 3 fields

Now we can estimate propensity to cycle, by using the distance decay function from (Iacono et al. 2010):

p = α e β d

where α , the proportion of made for the shortest distances and β , the rate of decay are parameters to be calculated from empirical evidence.

To implement this understanding in R code we can use the following function:

# Distance-dependent mode switch probs
iac <- function(x, a = 0.3, b = 0.2){
  a * exp(-b * x)
}

Apply this function to openly accessible flow data:

fleeds$p_cycle <- iac(fleeds$dist / 1000)
fleeds$n_cycle <- fleeds$p_cycle * fleeds$All.categories..Method.of.travel.to.work
fleeds$pc1 <- fleeds$n_cycle - fleeds$Bicycle

Now we can create a simple visualisation of the result:

plot(leeds)

for(i in which(fleeds$Area.of.residence == leeds$geo_code[1])){
  from <- leeds$geo_code %in% fleeds$Area.of.residence[i]
  to <- leeds$geo_code %in% fleeds$Area.of.workplace[i]
  x <- coordinates(leeds[from, ])
  y <- coordinates(leeds[to, ])
  lines(c(x[1], y[1]), c(x[2], y[2]), lwd = fleeds$pc1[i] )
}

\

Set the CS_API_KEY Environment variable

Some of the examples pull data from the CycleStreets.net API. Once you have a token, you can add it in Ubuntu as a session variable using the following in your terminal

echo "export CS_API_KEY='my_token'" >> ~/.profile

or system wide variable

sudo echo "export CS_API_KEY='my_token'" > /etc/profile.d/cyclestreet.sh

Set up rgdal

The version of gdal needs to be newer than 1.11

rgdal::getGDALVersionInfo()
## [1] "GDAL 1.11.2, released 2015/02/10"
# Should return GDAL 1.11.2, released 2015/02/10 (or newer)

It is possible to use the following Personal Package Archive (PPA) to get the latest version of gdal on Ubuntu.

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt-get update
sudo apt-get install gdal-bin libgdal-dev

About

Development of a 'Propensity to Cycle Tool'

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • R 63.8%
  • TeX 36.2%