mirror of
https://github.com/kidwellj/hacking_religion_textbook.git
synced 2025-06-15 16:54:10 +00:00
updated intro
This commit is contained in:
parent
3a657d6b2f
commit
a7109b28a8
37 changed files with 925 additions and 388 deletions
|
@ -7,7 +7,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||||
|
||||
|
||||
<title>Hacking Religion: TRS & Data Science in Action - 4 Mapping churches: geospatial data science</title>
|
||||
<title>Hacking Religion: TRS & Data Science in Action - 3 Mapping churches: geospatial data science</title>
|
||||
<style>
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
|
@ -127,7 +127,7 @@ div.csl-indent {
|
|||
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
||||
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
||||
</button>
|
||||
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_3.html"><span class="chapter-number">4</span> <span class="chapter-title">Mapping churches: geospatial data science</span></a></li></ol></nav>
|
||||
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./chapter_3.html"><span class="chapter-number">3</span> <span class="chapter-title">Mapping churches: geospatial data science</span></a></li></ol></nav>
|
||||
<a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar,#quarto-sidebar-glass" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
||||
</a>
|
||||
<button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
|
||||
|
@ -161,31 +161,37 @@ div.csl-indent {
|
|||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./intro.html" class="sidebar-item-text sidebar-link">
|
||||
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Introduction: Hacking Religion</span></span></a>
|
||||
<span class="menu-text">Introduction: Hacking Religion</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./chapter_1.html" class="sidebar-item-text sidebar-link">
|
||||
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">The 2021 UK Census</span></span></a>
|
||||
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">The 2021 UK Census</span></span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./chapter_2.html" class="sidebar-item-text sidebar-link">
|
||||
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
|
||||
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Survey Data: Spotlight Project</span></span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./chapter_3.html" class="sidebar-item-text sidebar-link active">
|
||||
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
|
||||
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">Mapping churches: geospatial data science</span></span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./chapter_4.html" class="sidebar-item-text sidebar-link">
|
||||
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
|
||||
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<div class="sidebar-item-container">
|
||||
<a href="./chapter_5.html" class="sidebar-item-text sidebar-link">
|
||||
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">What’s next?</span></span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
|
@ -210,8 +216,8 @@ div.csl-indent {
|
|||
<h2 id="toc-title">Table of contents</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="#administrative-shapes---the-uk" id="toc-administrative-shapes---the-uk" class="nav-link active" data-scroll-target="#administrative-shapes---the-uk"><span class="header-section-number">5</span> Administrative shapes - the UK</a></li>
|
||||
<li><a href="#load-in-ordnance-survey-openmap-points-data" id="toc-load-in-ordnance-survey-openmap-points-data" class="nav-link" data-scroll-target="#load-in-ordnance-survey-openmap-points-data"><span class="header-section-number">6</span> Load in Ordnance Survey OpenMap Points Data</a></li>
|
||||
<li><a href="#administrative-shapes---the-uk" id="toc-administrative-shapes---the-uk" class="nav-link active" data-scroll-target="#administrative-shapes---the-uk"><span class="header-section-number">4</span> Administrative shapes - the UK</a></li>
|
||||
<li><a href="#load-in-ordnance-survey-openmap-points-data" id="toc-load-in-ordnance-survey-openmap-points-data" class="nav-link" data-scroll-target="#load-in-ordnance-survey-openmap-points-data"><span class="header-section-number">5</span> Load in Ordnance Survey OpenMap Points Data</a></li>
|
||||
<li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -221,7 +227,7 @@ div.csl-indent {
|
|||
|
||||
<header id="title-block-header" class="quarto-title-block default">
|
||||
<div class="quarto-title">
|
||||
<h1 class="title"><span class="chapter-number">4</span> <span class="chapter-title">Mapping churches: geospatial data science</span></h1>
|
||||
<h1 class="title"><span class="chapter-number">3</span> <span class="chapter-title">Mapping churches: geospatial data science</span></h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -243,8 +249,8 @@ div.csl-indent {
|
|||
<p>The most complex aspect of point data relates to the ways that coordinates are encoded, as they will aways need to be associated with a coordinate reference system (CRS) which describes how they are situated with respect to the planet earth. The most common CRS is the WGS, though for our data sets we’ll also come into contact with the BGS, a specifically British coordinate reference system. There are dozens of CRS, usually mapping onto a specific geographical region. Bearing in mind the way that you need to use a CRS to understand how coordinates can be associated with specific parts of the earth, you can see how this is a bit like survey data, where you also need a “codebook” to understand what the specific response values map onto, e.g. a “1” means “strongly agree” and so on. We also saw, in a previous chapter, how some forms of data have the codebook already baked into the factor data, simplifying the process of interpreting the data. In a similar way, some types of geospatial data sets can also come with CRS “baked in” while we’ll need to define CRS for other types. Here are some of the most common types of geospatial data files:</p>
|
||||
<p>CSV: “comma separated values” a plain text file containing various coordinates Shapefile: a legacy file format, often still in use, but being replaced by others for a variety of good reasons. For more on this see [http://switchfromshapefile.org/] Geopackage: one of the more recent ways of packaging up geospatial data. Geopackages can contain a wide variety of different data and are easily portable. GeoJSON: a file format commonly used in other forms of coding, the “JSON” (an acronym for JavaScript Object Notation) is meant to be easily interchangeable across various platforms. GeoJSON is an augmented version of JSON data with coordinates added in.</p>
|
||||
<p>Now that you have a sense of some of the basic aspects of geospatial data, let’s dive in and do a bit of learning in action.</p>
|
||||
<section id="administrative-shapes---the-uk" class="level1" data-number="5">
|
||||
<h1 data-number="5"><span class="header-section-number">5</span> Administrative shapes - the UK</h1>
|
||||
<section id="administrative-shapes---the-uk" class="level1" data-number="4">
|
||||
<h1 data-number="4"><span class="header-section-number">4</span> Administrative shapes - the UK</h1>
|
||||
<p>A good starting point is to aquire some adminstrative data. This is a way of referring to political boundaries, whether country borders or those of a local authority or some other administrative unit. For our purposes, we’re going to import several different types of administrative boundary which will be used at different points in our visualisations below. It’s worth noting that the data we use here was prepared to support the 2011 census, and make use of the shapefile format.</p>
|
||||
<div class="cell">
|
||||
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sf) <span class="sc">|></span> <span class="fu">suppressPackageStartupMessages</span>()</span>
|
||||
|
@ -298,65 +304,62 @@ i Use the conflicted package (<http://conflicted.r-lib.org/>) to force all
|
|||
</div>
|
||||
<p>Before we move on, let’s plot a simple map and have a look at one of our administrative layers. We can use ggplot with a new type of shape <code>geom_sf()</code> to plot the contents of a geospatial data file with polygons which is loaded as a <code>simplefeature</code> in R.</p>
|
||||
<div class="cell">
|
||||
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(bench) <span class="sc">|></span> <span class="fu">suppressPackageStartupMessages</span>()</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">bench_time</span>(<span class="fu">ggplot</span>(uk_countries) <span class="sc">+</span> <span class="fu">geom_sf</span>())</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-stdout">
|
||||
<pre><code>process real
|
||||
6.83ms 7.05ms </code></pre>
|
||||
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(uk_countries) <span class="sc">+</span> <span class="fu">geom_sf</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output-display">
|
||||
<p><img src="chapter_3_files/figure-html/unnamed-chunk-2-1.png" class="img-fluid" width="672"></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="load-in-ordnance-survey-openmap-points-data" class="level1" data-number="6">
|
||||
<h1 data-number="6"><span class="header-section-number">6</span> Load in Ordnance Survey OpenMap Points Data</h1>
|
||||
<section id="load-in-ordnance-survey-openmap-points-data" class="level1" data-number="5">
|
||||
<h1 data-number="5"><span class="header-section-number">5</span> Load in Ordnance Survey OpenMap Points Data</h1>
|
||||
<div class="cell">
|
||||
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: for more advanced reproducible scripts which demonstrate how these data surces have been </span></span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="co"># obtained, see the companion cookbook here: https://github.com/kidwellj/hacking_religion_cookbook/blob/main/ordnance_survey.R</span></span>
|
||||
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a>os_openmap_pow <span class="ot"><-</span> <span class="fu">st_read</span>(<span class="fu">here</span>(<span class="st">"data"</span>, <span class="st">"os_openmap_pow.gpkg"</span>), <span class="at">quiet =</span> <span class="cn">TRUE</span>)</span>
|
||||
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a><span class="fu">bench_time</span>(<span class="fu">ggplot</span>(os_openmap_pow) <span class="sc">+</span> <span class="fu">geom_sf</span>())</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-stdout">
|
||||
<pre><code>process real
|
||||
1.17ms 1.15ms </code></pre>
|
||||
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: for more advanced reproducible scripts which demonstrate how these data surces have been </span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="co"># obtained, see the companion cookbook here: https://github.com/kidwellj/hacking_religion_cookbook/blob/main/ordnance_survey.R</span></span>
|
||||
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a>os_openmap_pow <span class="ot"><-</span> <span class="fu">st_read</span>(<span class="fu">here</span>(<span class="st">"data"</span>, <span class="st">"os_openmap_pow.gpkg"</span>), <span class="at">quiet =</span> <span class="cn">TRUE</span>)</span>
|
||||
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(os_openmap_pow) <span class="sc">+</span> <span class="fu">geom_sf</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output-display">
|
||||
<p><img src="chapter_3_files/figure-html/unnamed-chunk-3-1.png" class="img-fluid" width="672"></p>
|
||||
</div>
|
||||
</div>
|
||||
<p>It’s worth noting that the way that you load geospatial data in R has changed quite dramatically since 2020 with the introduction of the simplefeature class in R. Much of the documentation you will come across “out there” will make reference to a set of functions which are now deprecated.</p>
|
||||
<p>Let’s use that data we’ve just loaded to make our first map:</p>
|
||||
<div class="cell">
|
||||
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate choropleth map of respondent locations</span></span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="co"># using temporary palette here so that 0s are white</span></span>
|
||||
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tmap) <span class="sc">|></span> <span class="fu">suppressPackageStartupMessages</span>()</span>
|
||||
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="co"># palette <- c(white, "#a8ddb5", "#43a2ca")</span></span>
|
||||
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a>map1 <span class="ot"><-</span> <span class="fu">tm_shape</span>(local_authorities) <span class="sc">+</span> </span>
|
||||
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a><span class="co"># tm_fill(col = "surveys_count", , palette = palette, title = "Concentration of survey respondents") +</span></span>
|
||||
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_borders</span>(<span class="at">alpha=</span>.<span class="dv">5</span>, <span class="at">lwd=</span><span class="fl">0.1</span>) <span class="sc">+</span></span>
|
||||
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> <span class="co"># for intermediate polygon geometries</span></span>
|
||||
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_shape(local_authorities) +</span></span>
|
||||
<span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_borders(lwd=0.6) +</span></span>
|
||||
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># for dots from original dataset</span></span>
|
||||
<span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_dots("red", size = .05, alpha = .4) +</span></span>
|
||||
<span id="cb10-14"><a href="#cb10-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_scale_bar</span>(<span class="at">position =</span> <span class="fu">c</span>(<span class="st">"right"</span>, <span class="st">"bottom"</span>)) <span class="sc">+</span></span>
|
||||
<span id="cb10-15"><a href="#cb10-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_style</span>(<span class="st">"gray"</span>) <span class="sc">+</span></span>
|
||||
<span id="cb10-16"><a href="#cb10-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_credits</span>(<span class="st">"Data: UK Data Service (OGL)</span><span class="sc">\n</span><span class="st">& Jeremy H. Kidwell,</span><span class="sc">\n</span><span class="st">Graphic is CC-by-SA 4.0"</span>, </span>
|
||||
<span id="cb10-17"><a href="#cb10-17" aria-hidden="true" tabindex="-1"></a> <span class="at">size =</span> <span class="fl">0.4</span>, </span>
|
||||
<span id="cb10-18"><a href="#cb10-18" aria-hidden="true" tabindex="-1"></a> <span class="at">position =</span> <span class="fu">c</span>(<span class="st">"left"</span>, <span class="st">"bottom"</span>),</span>
|
||||
<span id="cb10-19"><a href="#cb10-19" aria-hidden="true" tabindex="-1"></a> <span class="at">just =</span> <span class="fu">c</span>(<span class="st">"left"</span>, <span class="st">"bottom"</span>),</span>
|
||||
<span id="cb10-20"><a href="#cb10-20" aria-hidden="true" tabindex="-1"></a> <span class="at">align =</span> <span class="st">"left"</span>) <span class="sc">+</span></span>
|
||||
<span id="cb10-21"><a href="#cb10-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_layout</span>(<span class="at">asp =</span> <span class="cn">NA</span>,</span>
|
||||
<span id="cb10-22"><a href="#cb10-22" aria-hidden="true" tabindex="-1"></a> <span class="at">frame =</span> <span class="cn">FALSE</span>, </span>
|
||||
<span id="cb10-23"><a href="#cb10-23" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Figure 1a"</span>, </span>
|
||||
<span id="cb10-24"><a href="#cb10-24" aria-hidden="true" tabindex="-1"></a> <span class="at">title.size =</span> .<span class="dv">7</span>,</span>
|
||||
<span id="cb10-25"><a href="#cb10-25" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.title.size =</span> .<span class="dv">7</span>,</span>
|
||||
<span id="cb10-26"><a href="#cb10-26" aria-hidden="true" tabindex="-1"></a> <span class="at">inner.margins =</span> <span class="fu">c</span>(<span class="fl">0.1</span>, <span class="fl">0.1</span>, <span class="fl">0.05</span>, <span class="fl">0.05</span>)</span>
|
||||
<span id="cb10-27"><a href="#cb10-27" aria-hidden="true" tabindex="-1"></a> )</span>
|
||||
<span id="cb10-28"><a href="#cb10-28" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb10-29"><a href="#cb10-29" aria-hidden="true" tabindex="-1"></a>map1</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Generate choropleth map of respondent locations</span></span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="co"># using temporary palette here so that 0s are white</span></span>
|
||||
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tmap) <span class="sc">|></span> <span class="fu">suppressPackageStartupMessages</span>()</span>
|
||||
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="co"># palette <- c(white, "#a8ddb5", "#43a2ca")</span></span>
|
||||
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a>map1 <span class="ot"><-</span> <span class="fu">tm_shape</span>(local_authorities) <span class="sc">+</span> </span>
|
||||
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a><span class="co"># tm_fill(col = "surveys_count", , palette = palette, title = "Concentration of survey respondents") +</span></span>
|
||||
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_borders</span>(<span class="at">alpha=</span>.<span class="dv">5</span>, <span class="at">lwd=</span><span class="fl">0.1</span>) <span class="sc">+</span></span>
|
||||
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="co"># for intermediate polygon geometries</span></span>
|
||||
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_shape(local_authorities) +</span></span>
|
||||
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_borders(lwd=0.6) +</span></span>
|
||||
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># for dots from original dataset</span></span>
|
||||
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># tm_dots("red", size = .05, alpha = .4) +</span></span>
|
||||
<span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_scale_bar</span>(<span class="at">position =</span> <span class="fu">c</span>(<span class="st">"right"</span>, <span class="st">"bottom"</span>)) <span class="sc">+</span></span>
|
||||
<span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_style</span>(<span class="st">"gray"</span>) <span class="sc">+</span></span>
|
||||
<span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_credits</span>(<span class="st">"Data: UK Data Service (OGL)</span><span class="sc">\n</span><span class="st">& Jeremy H. Kidwell,</span><span class="sc">\n</span><span class="st">Graphic is CC-by-SA 4.0"</span>, </span>
|
||||
<span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a> <span class="at">size =</span> <span class="fl">0.4</span>, </span>
|
||||
<span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a> <span class="at">position =</span> <span class="fu">c</span>(<span class="st">"left"</span>, <span class="st">"bottom"</span>),</span>
|
||||
<span id="cb8-19"><a href="#cb8-19" aria-hidden="true" tabindex="-1"></a> <span class="at">just =</span> <span class="fu">c</span>(<span class="st">"left"</span>, <span class="st">"bottom"</span>),</span>
|
||||
<span id="cb8-20"><a href="#cb8-20" aria-hidden="true" tabindex="-1"></a> <span class="at">align =</span> <span class="st">"left"</span>) <span class="sc">+</span></span>
|
||||
<span id="cb8-21"><a href="#cb8-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">tm_layout</span>(<span class="at">asp =</span> <span class="cn">NA</span>,</span>
|
||||
<span id="cb8-22"><a href="#cb8-22" aria-hidden="true" tabindex="-1"></a> <span class="at">frame =</span> <span class="cn">FALSE</span>, </span>
|
||||
<span id="cb8-23"><a href="#cb8-23" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">"Figure 1a"</span>, </span>
|
||||
<span id="cb8-24"><a href="#cb8-24" aria-hidden="true" tabindex="-1"></a> <span class="at">title.size =</span> .<span class="dv">7</span>,</span>
|
||||
<span id="cb8-25"><a href="#cb8-25" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.title.size =</span> .<span class="dv">7</span>,</span>
|
||||
<span id="cb8-26"><a href="#cb8-26" aria-hidden="true" tabindex="-1"></a> <span class="at">inner.margins =</span> <span class="fu">c</span>(<span class="fl">0.1</span>, <span class="fl">0.1</span>, <span class="fl">0.05</span>, <span class="fl">0.05</span>)</span>
|
||||
<span id="cb8-27"><a href="#cb8-27" aria-hidden="true" tabindex="-1"></a> )</span>
|
||||
<span id="cb8-28"><a href="#cb8-28" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb8-29"><a href="#cb8-29" aria-hidden="true" tabindex="-1"></a>map1</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output-display">
|
||||
<p><img src="chapter_3_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid" width="672"></p>
|
||||
</div>
|
||||
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co"># save image</span></span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="fu">tmap_save</span>(map1, <span class="fu">here</span>(<span class="st">"figures"</span>, <span class="st">"map.png"</span>), <span class="at">width=</span><span class="dv">1920</span>, <span class="at">height=</span><span class="dv">1080</span>, <span class="at">asp=</span><span class="dv">0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="co"># save image</span></span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">tmap_save</span>(map1, <span class="fu">here</span>(<span class="st">"figures"</span>, <span class="st">"map.png"</span>), <span class="at">width=</span><span class="dv">1920</span>, <span class="at">height=</span><span class="dv">1080</span>, <span class="at">asp=</span><span class="dv">0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-stderr">
|
||||
<pre><code>Map saved to /Users/kidwellj/gits/hacking_religion_textbook/hacking_religion/figures/map.png</code></pre>
|
||||
</div>
|
||||
|
@ -368,26 +371,26 @@ i Use the conflicted package (<http://conflicted.r-lib.org/>) to force all
|
|||
</div>
|
||||
</div>
|
||||
<div class="cell">
|
||||
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="co"># subsetting ordnance survey openmap data for measuring clusters and proximity</span></span>
|
||||
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a>os_openmap_important_buildings <span class="ot"><-</span> <span class="fu">st_read</span>(<span class="fu">here</span>(<span class="st">"data"</span>, <span class="st">"os_openmap_important_buildings.gpkg"</span>), <span class="at">quiet =</span> <span class="cn">TRUE</span>)</span>
|
||||
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a><span class="co"># add pubs, check_cashing, pawnbrokers, SSSI</span></span>
|
||||
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a><span class="do">## subsets</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="co"># subsetting ordnance survey openmap data for measuring clusters and proximity</span></span>
|
||||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>os_openmap_important_buildings <span class="ot"><-</span> <span class="fu">st_read</span>(<span class="fu">here</span>(<span class="st">"data"</span>, <span class="st">"os_openmap_important_buildings.gpkg"</span>), <span class="at">quiet =</span> <span class="cn">TRUE</span>)</span>
|
||||
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="co"># add pubs, check_cashing, pawnbrokers, SSSI</span></span>
|
||||
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="do">## subsets</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
</div>
|
||||
<ol type="1">
|
||||
<li>Count the number of churches in Local Authorities</li>
|
||||
</ol>
|
||||
<div class="cell">
|
||||
<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="co"># OSM data</span></span>
|
||||
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: for more advanced reproducible scripts which demonstrate how these data surces have been </span></span>
|
||||
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a><span class="co"># obtained, see the companion cookbook here: https://github.com/kidwellj/hacking_religion_cookbook/blob/main/ordnance_survey.R</span></span>
|
||||
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a><span class="co"># osm_uk_points <- st_read(system.file(here("data", "pow_osm.gpkg", package = "spData")))</span></span>
|
||||
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a><span class="co"># vector_filepath = system.file("data/osm-gb-2018Aug29_pow_osm.pbf", package = "sf")</span></span>
|
||||
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a><span class="co"># osm_uk_points = st_read(vector_filepath)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="co"># OSM data</span></span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: for more advanced reproducible scripts which demonstrate how these data surces have been </span></span>
|
||||
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="co"># obtained, see the companion cookbook here: https://github.com/kidwellj/hacking_religion_cookbook/blob/main/ordnance_survey.R</span></span>
|
||||
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="co"># osm_uk_points <- st_read(system.file(here("data", "pow_osm.gpkg", package = "spData")))</span></span>
|
||||
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a><span class="co"># vector_filepath = system.file("data/osm-gb-2018Aug29_pow_osm.pbf", package = "sf")</span></span>
|
||||
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="co"># osm_uk_points = st_read(vector_filepath)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
</div>
|
||||
<p>Guides to geographies: https://rconsortium.github.io/censusguide/ https://ocsi.uk/2019/03/18/lsoas-leps-and-lookups-a-beginners-guide-to-statistical-geographies/</p>
|
||||
<p>Calculate proximity to pubs</p>
|
||||
|
@ -638,12 +641,12 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
|
|||
<nav class="page-navigation">
|
||||
<div class="nav-page nav-page-previous">
|
||||
<a href="./chapter_2.html" class="pagination-link">
|
||||
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">3</span> <span class="chapter-title">Survey Data: Spotlight Project</span></span>
|
||||
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">2</span> <span class="chapter-title">Survey Data: Spotlight Project</span></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-page nav-page-next">
|
||||
<a href="./chapter_4.html" class="pagination-link">
|
||||
<span class="nav-page-text"><span class="chapter-number">5</span> <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span> <i class="bi bi-arrow-right-short"></i>
|
||||
<span class="nav-page-text"><span class="chapter-number">4</span> <span class="chapter-title">Data scraping, corpus analysis and wordclouds</span></span> <i class="bi bi-arrow-right-short"></i>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue