forked from npct/pct-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
87 lines (62 loc) · 2.92 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: "Propensity to Cycle Tool - data loading"
output:
html_document:
keep_md: yes
---
This repository generates data hosted in [pct-data](https://github.com/npct/pct-data).
It was originally cloned from [pct](https://github.com/npct/pct).
The main script on this repo is [load.Rmd](https://github.com/npct/pct-load/blob/master/load.Rmd).
This script runs the R code contained within while creating a summary of the data generating process.
It even reports summary statistics from the data as it is created.
To run `load.Rmd` you should be able to simply hit 'Knit HTML' while loaded RStudio.
There are other dependencies, listed below.
## Relationship to other pct- folders
The purpose of this repo is to build the data used by [pct-shiny](https://github.com/npct/pct-shiny).
To do this it creates new folders and creates files in [pct-data](https://github.com/npct/pct-data).
It relies on open data hosted on [pct-bigdata](https://github.com/npct/pct-bigdata/).
**Each of the these folder should be 'siblings' in the same folder.**
All of the folders needed to run the Propensity to Cycle Tool, and modify the input data it uses (e.g. to create new scenarios), can be created with the following shell commands:
```{r, engine='bash', eval=FALSE}
# clone the pct data creation scripts
git clone [email protected]:npct/pct-load.git
# clone the data (warning - large)
git clone [email protected]:npct/pct-data.git --depth 1
# clone the shiny online visualisation framework
git clone [email protected]:npct/pct-shiny.git
# clone the national level input data
git clone [email protected]:npct/pct-bigdata.git --depth 1
```
The other dependencies are described below.
If you have issues with any of these, please report them as an [issue](https://github.com/npct/pct-load/issues).
## Set the `CS_API_KEY` Environment variable
Some of the examples pull data from the
[CycleStreets.net API](http://www.cyclestreets.net/api/).
Once you have a token, you can add it to R by
adding the following line
to your `.Renviron` file in your home directory:
```{r, engine='bash', eval=FALSE}
CYCLESTREET=xxx
```
where `xxx` is the api key.
If the file does not yet exist, you can create it.
This can also be made available to other programs,
a session variable using the following in your terminal (tested in Ubuntu):
```{r, engine='bash', eval = FALSE}
echo "export CS_API_KEY='my_token'" >> ~/.profile
```
or system wide variable
```{r, engine='bash', eval = FALSE}
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
```{r}
rgdal::getGDALVersionInfo()
# 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.
```{r, engine='bash', eval = FALSE}
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt-get update
sudo apt-get install gdal-bin libgdal-dev
```