Coder Social home page Coder Social logo

pct-team's Introduction

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 = \alpha e^{- \beta 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(-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

pct-team's People

Contributors

annagoodman1 avatar audev avatar jdwoodcock avatar mem48 avatar mvl22 avatar nikolai-b avatar rachelaldred avatar robinlovelace avatar usr110 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pct-team's Issues

Rewriting front page text

Here's my first go at proposed changes to the front page text so we can fit in the video... I think we could actually cut it right down - at the moment we provide a little information but the video is better at getting that across.

Welcome to the Propensity to Cycle Tool (PCT)

Created by the Propensity to Cycle Tool team.

Last updated: 2016-07-27.

Welcome to the Propensity to Cycle Tool for England (PCT-England), which provides an evidence base to inform cycling investment. To find out more about the tool, its use and the four scenarios, please watch the video below. More detailed information can be found on PCT blog, the Manual, an academic paper or the about page [include links].

To run the PCT, click on a region in the map to the left. This will open up the PCT for that region. The PCT will then show you cycling levels in that region at area, ‘desire line’ and route network levels, from 2011 Census for commuting and for various scenarios that illustrate where cycling has the greatest potential to grow. This is based on a model that estimates cycling potential based upon trip distances and hilliness.

Currently the PCT only shows commuting trips but additional layers are planned.

Add % by car variable

This is not a priority issue but would be a useful way to see the potential congestion benefit of cycling uptake in different areas.

Link to PCT blog on main map page

Hi @Robinlovelace @nikolai-b @JDWoodcock - it would be great to get a link to the PCT blog on the main map page, now that I've got a few posts up there including our LTT piece. Ideally I think an additional link after FAQs would be great, but one other option would be to have a 'more info' tab/dropdown that would contain links to 'About', 'FAQs', and the blog.

Start/finish points that are not routable due to OSM data

The following locations are not routable, due to them being in the midst of non-cycleable areas which are technically routable locally by bicycle but which can't be exited from, e.g. motorways or one-way systems.

I recommend these be manually adjusted, as routes from/to these specific locations will fail.

I used the script created by @Robinlovelace in 4a96267 and ran this through our batch routing system, which picks up these cases quickly.

This is not at this stage a complete list as I tried the batch on a server that only has about half of the UK loaded. I will edit this opening posting if more are found in future.

(It's on our list to fix these rare cases at engine level, but it's non-trivial because the local routability remains valid. Essentially we need a re-entrant algorithm that can invalidate a nearest point lookup if the other end is on a different network island and then second time around treat the local-only network as if it were bicycle=no even though it the data is bicycle=yes. I have a feeling that Simon has been doing some work on this general area recently but we don't have a stable engine implementation yet.)

List of local files

  • ~/Documents/Transport.bib in flow-model.Rmd
  • /home/robin/Dropbox/DfT bid/figures/las-gender-pcycle.png in flow-model.Rmd
  • /home/robin/Dropbox/DfT bid/Data analysis/Test_DD/TestPlanck_150303/150304_SegmentationCompare_8cat.xlsx in testing-dd-ffs.Rmd and dd-paper.Rmd
  • /media/robin/data/data-to-add/msoa-2011-sex-method-ttw-nomis-lc7103ew.csv in load-cents.R
  • /media/robin/data/data/UKDA-5340-spss/spss/spss19/ in pswitch-model-NTS.R/blob/master/models/pswitch-model-NTS.R)
  • /media/robin/data/data-to-add/public-flow-data-msoa/wu03ew_v2.csv in a few (case-studies/manchester.R, case-studies/leeds-minitest.R, case-studies/leeds-wider.R, and case-studies/manchester.md)

and others. If there are old files in here then let's get rid of them and clean it up.
I think we should aim to get no links to external files included.

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.