Skip to content

Commit c1353c9

Browse files
committed
Update with edit page button
1 parent 1f7ebaf commit c1353c9

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

Diff for: config/_default/params.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ privacy_pack = false
7676

7777
# Enable visitors to edit pages?
7878
# `repo` defines the repository URL. `editable` defines which page types can be edited.
79-
edit_page = {repo_url = "https://github.com/rbind/robinlovelace", content_dir = "", repo_branch = "master", editable = {docs = true, page = false, post = false}}
79+
edit_page = {repo_url = "https://github.com/rbind/robinlovelace", content_dir = "", repo_branch = "master", editable = {docs = true, page = false, post = true}}
8080

8181
# Show related content at the bottom of pages?
8282
show_related = {docs = true, page = false, post = true, project = true, publication = true, talk = true}

Diff for: content/post/2017-05-02-can-geographic-data-save-the-world.html

+15-9
Original file line numberDiff line numberDiff line change
@@ -78,32 +78,32 @@ <h2>A reproducible example</h2>
7878
<blockquote>
7979
<p>Talk is cheap. Show me the code.</p>
8080
</blockquote>
81-
<p>On that basis, to show what I meant by reproducibility and ‘data carpentry’ <span class="citation">(<a href="#ref-gillespie_efficient_2016" role="doc-biblioref"><strong>gillespie_efficient_2016?</strong></a>)</span> (a concept mentioned in the slides not discussed in audio for lack of time) I provided some some example code that illustrated the kinds of techniques underlying the PCT.</p>
81+
<p>On that basis, to show what I meant by reproducibility and ‘data carpentry’ <span class="citation">(<a href="#ref-gillespie_efficient_2016" role="doc-biblioref">Gillespie and Lovelace 2016</a>)</span> (a concept mentioned in the slides not discussed in audio for lack of time) I provided some some example code that illustrated the kinds of techniques underlying the PCT.</p>
8282
<p>First download and visualise some transport data (from the Isle of Wight as, the smallest region in the PCT):</p>
8383
<pre class="r"><code>u_pct = &quot;https://github.com/npct/pct-data/raw/master/isle-of-wight/l.Rds&quot;
8484
if(!file.exists(&quot;l.Rds&quot;))
8585
download.file(u_pct, &quot;l.Rds&quot;)
8686
l = readRDS(&quot;l.Rds&quot;)
8787
library(sp)
8888
plot(l)</code></pre>
89-
<pre><code>## Warning in wkt(obj): CRS object has no comment</code></pre>
9089
<p><img src="/post/2017-05-02-can-geographic-data-save-the-world_files/figure-html/unnamed-chunk-4-1.png" width="672" /></p>
9190
<p>Now that we have an idea of the commute patterns in the area, and the nature of ‘OD’ data (converted to geographical desire lines with the <strong><a href="https://github.com/ropensci/stplanr">stplanr</a></strong> package), we can do some analysis.</p>
9291
<pre class="r"><code>sel_walk = l$foot &gt; 9
9392
l_walk = l[sel_walk,]
94-
plot(l)</code></pre>
95-
<pre><code>## Warning in wkt(obj): CRS object has no comment</code></pre>
96-
<pre class="r"><code>plot(l_walk, add = T, col = &quot;red&quot;, lwd = 3)</code></pre>
93+
plot(l)
94+
plot(l_walk, add = T, col = &quot;red&quot;, lwd = 3)</code></pre>
9795
<p><img src="/post/2017-05-02-can-geographic-data-save-the-world_files/figure-html/unnamed-chunk-5-1.png" width="672" /></p>
9896
<pre class="r"><code>library(dplyr) # for next slide...</code></pre>
99-
<p>The above code subsets all the lines that have 10 or more people walking to work in the 2011 census and plots the results (as you’d expect the shorter trips are more commonly walked). It works, but could be interpretted as a little clunky. Enter <a href="https://github.com/tidyverse/dplyr"><strong>dplyr</strong></a>, a package for data science <span class="citation">(<a href="#ref-grolemund_r_2016" role="doc-biblioref"><strong>grolemund_r_2016?</strong></a>)</span>:</p>
97+
<p>The above code subsets all the lines that have 10 or more people walking to work in the 2011 census and plots the results (as you’d expect the shorter trips are more commonly walked). It works, but could be interpretted as a little clunky. Enter <a href="https://github.com/tidyverse/dplyr"><strong>dplyr</strong></a>, a package for data science <span class="citation">(<a href="#ref-grolemund_r_2016" role="doc-biblioref">Grolemund and Wickham 2016</a>)</span>:</p>
10098
<pre class="r"><code>l_walk1 = l %&gt;% filter(All &gt; 10) # fails</code></pre>
10199
<p>Doh! That code nice ‘clean’ (well certainly consistent) code does not work because <code>Spatial</code> objects are not compatible with the pipe operator <code>%&gt;%</code> syntax.</p>
102100
<p>Enter the <a href="https://github.com/edzer/sfr"><strong>sf</strong></a> package, which represents a step change in how R handles spatial data. First let’s convert that <code>l</code> object into a ‘simple feature’ object:</p>
103101
<pre class="r"><code>library(sf)</code></pre>
104-
<pre><code>## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 7.0.0</code></pre>
105-
<pre class="r"><code>l_sf = st_as_sf(l)
106-
class(l_sf)</code></pre>
102+
<pre><code>## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1</code></pre>
103+
<pre class="r"><code>l_sf = st_as_sf(l)</code></pre>
104+
<pre><code>## Warning in CPL_crs_from_input(x): GDAL Message 1: +init=epsg:XXXX syntax is
105+
## deprecated. It might return a CRS with a non-EPSG compliant axis order.</code></pre>
106+
<pre class="r"><code>class(l_sf)</code></pre>
107107
<pre><code>## [1] &quot;sf&quot; &quot;data.frame&quot;</code></pre>
108108
<pre class="r"><code>plot(l_sf[6:15])</code></pre>
109109
<pre><code>## Warning: plotting the first 9 out of 10 attributes; use max.plot = 10 to plot
@@ -144,6 +144,12 @@ <h2>References</h2>
144144
<div id="ref-arribas-bel_accidental_2014" class="csl-entry">
145145
Arribas-Bel, Daniel. 2014. <span>“Accidental, Open and Everywhere: <span>Emerging</span> Data Sources for the Understanding of Cities.”</span> <em>Applied Geography</em> 49: 45–53.
146146
</div>
147+
<div id="ref-gillespie_efficient_2016" class="csl-entry">
148+
Gillespie, Colin, and Robin Lovelace. 2016. <em>Efficient <span>R Programming</span>: <span>A Practical Guide</span> to <span>Smarter Programming</span></em>. <span>O’Reilly Media</span>. <a href="https://csgillespie.github.io/efficientR/">https://csgillespie.github.io/efficientR/</a>.
149+
</div>
150+
<div id="ref-grolemund_r_2016" class="csl-entry">
151+
Grolemund, Garrett, and Hadley Wickham. 2016. <em>R for <span>Data Science</span></em>. 1 edition. <span>O’Reilly Media</span>.
152+
</div>
147153
<div id="ref-lovelace_big_2016" class="csl-entry">
148154
Lovelace, Robin, Mark Birkin, Philip Cross, and Martin Clarke. 2016. <span>“From <span>Big Noise</span> to <span>Big Data</span>: <span>Toward</span> the <span>Verification</span> of <span>Large Data</span> Sets for <span>Understanding Regional Retail Flows</span>.”</span> <em>Geographical Analysis</em> 48 (1): 59–81. <a href="https://doi.org/10.1111/gean.12081">https://doi.org/10.1111/gean.12081</a>.
149155
</div>
Loading
Loading

0 commit comments

Comments
 (0)