Giter Site home page Giter Site logo

pct's Introduction

<script type="text/javascript" src="http://www.math.union.edu/~dpvc/transfer/mathjax/mathjax-in-github.user.js"></script>

pct: Propensity to cycle tool

This repository allows users to estimate the 'propensity to cycle' between different origin-destination pairs.

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 code in this repository and data stored in the pct-data repository.

So, if you run the following lines of code on your computer from within this folder, you should get the same result. Reproducible research!

A simple example

# system("git clone [email protected]:Robinlovelace/pct-data.git") # see set-up.R
source("set-up.R")
# load some flow data
fleeds <- read.csv("pct-data/leeds/sample-leeds-centre-dists.csv")
# load the zones
leeds <- readOGR("pct-data/leeds/", "leeds-central-sample")
## OGR data source with driver: ESRI Shapefile 
## Source: "pct-data/leeds/", layer: "leeds-central-sample"
## with 25 features and 3 fields
## Feature type: wkbPolygon with 2 dimensions

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

p = \alpha \times e^{- \beta \times d}

where $\alpha$, the proportion of made for the shortest distances and $\beta$, 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(1)^(-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] )
}

pct's People

Contributors

robinlovelace avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.