Skip to content

Commit

Permalink
Deploy commit: Update exercises before tackling #766 a28def3
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Mar 18, 2022
1 parent 2bca540 commit 71ba595
Show file tree
Hide file tree
Showing 29 changed files with 528 additions and 398 deletions.
5 changes: 4 additions & 1 deletion 04-spatial-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,12 @@ data(nz_height, package = "spData")
E1. It was established in Section \@ref(spatial-vec) that Canterbury was the region of New Zealand containing most of the 100 highest points in the country.
How many of these high points does the Canterbury region contain?

**Bonus:** plot the result using the `plot()` function to show all of New Zealand, `canterbury` region highlighted in yellow, high points in Canterbury represented with black dots and


E2. Which region has the second highest number of `nz_height` points in, and how many does it have?


E2. Which region has the second highest number of `nz_height` points, and how many does it have?



Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 05-geometry-operations_files/figure-html/points-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 09-mapping_files/figure-html/layout3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 09-mapping_files/figure-html/tmstyles-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Geocomputation with R</title>
<meta name="author" content="Robin Lovelace, Jakub Nowosad, Jannes Muenchow">
<meta name="description" content="Geocomputation with R is for people who want to analyze, visualize and model geographic data with open source software. It is based on R, a statistical programming language that has powerful data processing, visualization, and geospatial capabilities. The book equips you with the knowledge and skills to tackle a wide range of issues manifested in geographic data, including those with scientific, societal, and environmental implications. This book will interest people from many backgrounds, especially Geographic Information Systems (GIS) users interested in applying their domain-specific knowledge in a powerful open source language for data science, and R users interested in extending their skills to handle spatial data.">
<meta name="generator" content="bookdown 0.24 with bs4_book()">
<meta name="generator" content="bookdown 0.25 with bs4_book()">
<meta property="og:title" content="Geocomputation with R">
<meta property="og:type" content="book">
<meta property="og:url" content="https://geocompr.robinlovelace.net/404.html">
Expand All @@ -17,7 +17,7 @@
<meta name="twitter:title" content="Geocomputation with R">
<meta name="twitter:description" content="Geocomputation with R is for people who want to analyze, visualize and model geographic data with open source software. It is based on R, a statistical programming language that has powerful data processing, visualization, and geospatial capabilities. The book equips you with the knowledge and skills to tackle a wide range of issues manifested in geographic data, including those with scientific, societal, and environmental implications. This book will interest people from many backgrounds, especially Geographic Information Systems (GIS) users interested in applying their domain-specific knowledge in a powerful open source language for data science, and R users interested in extending their skills to handle spatial data.">
<meta name="twitter:image" content="https://geocompr.robinlovelace.net/images/cover.png">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/header-attrs-2.12/header-attrs.js"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="libs/bootstrap-4.6.0/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-4.6.0/bootstrap.bundle.min.js"></script><link href="libs/_Lato-0.4.0/font.css" rel="stylesheet">
<link href="libs/_Roboto%20Mono-0.4.0/font.css" rel="stylesheet">
Expand Down Expand Up @@ -113,7 +113,7 @@ <h2>Note: Second Edition is under construction 🏗</h2>
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">

<div class="col-12 col-md-6 mt-3">
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2022-03-17.</p>
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2022-03-18.</p>
</div>

<div class="col-12 col-md-6 mt-3">
Expand Down
18 changes: 11 additions & 7 deletions adv-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Chapter 9 Making maps with R | Geocomputation with R</title>
<meta name="author" content="Robin Lovelace, Jakub Nowosad, Jannes Muenchow">
<meta name="description" content="Prerequisites This chapter requires the following packages that we have already been using: library(sf) library(raster) library(dplyr) library(spData) library(spDataLarge) In addition, it uses the...">
<meta name="generator" content="bookdown 0.24 with bs4_book()">
<meta name="generator" content="bookdown 0.25 with bs4_book()">
<meta property="og:title" content="Chapter 9 Making maps with R | Geocomputation with R">
<meta property="og:type" content="book">
<meta property="og:url" content="https://geocompr.robinlovelace.net/adv-map.html">
Expand All @@ -17,7 +17,7 @@
<meta name="twitter:title" content="Chapter 9 Making maps with R | Geocomputation with R">
<meta name="twitter:description" content="Prerequisites This chapter requires the following packages that we have already been using: library(sf) library(raster) library(dplyr) library(spData) library(spDataLarge) In addition, it uses the...">
<meta name="twitter:image" content="https://geocompr.robinlovelace.net/images/cover.png">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/header-attrs-2.12/header-attrs.js"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="libs/bootstrap-4.6.0/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-4.6.0/bootstrap.bundle.min.js"></script><link href="libs/_Lato-0.4.0/font.css" rel="stylesheet">
<link href="libs/_Roboto%20Mono-0.4.0/font.css" rel="stylesheet">
Expand Down Expand Up @@ -260,7 +260,8 @@ <h3>
The purpose of this section is to show how.</p>
<p>There are two main types of map aesthetics: those that change with the data and those that are constant.
Unlike <strong>ggplot2</strong>, which uses the helper function <code><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes()</a></code> to represent variable aesthetics, <strong>tmap</strong> accepts aesthetic arguments directly.
To map a variable to an aesthetic, pass its column name to the corresponding argument, and to set a fixed aesthetic, pass the desired value instead.<a href="references.html#fn42" class="footnote-ref" id="fnref42"><sup>42</sup></a>
To map a variable to an aesthetic, pass its column name to the corresponding argument, and to set a fixed aesthetic, pass the desired value instead.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;
If there is a clash between a fixed value and a column name, the column name takes precedence. This can be verified by running the next code chunk after running &lt;code&gt;nz$red = 1:nrow(nz)&lt;/code&gt;.&lt;/p&gt;"><sup>42</sup></a>
The most commonly used aesthetics for fill and border layers include color, transparency, line width and line type, set with <code>col</code>, <code>alpha</code>, <code>lwd</code>, and <code>lty</code> arguments, respectively.
The impact of setting these with fixed values is illustrated in Figure <a href="adv-map.html#fig:tmstatic">9.3</a>.</p>
<div class="sourceCode" id="cb302"><pre class="downlit sourceCode r">
Expand Down Expand Up @@ -366,7 +367,8 @@ <h3>
<p>There are three main groups of color palettes: categorical, sequential and diverging (Figure <a href="adv-map.html#fig:colpal">9.7</a>), and each of them serves a different purpose.
Categorical palettes consist of easily distinguishable colors and are most appropriate for categorical data without any particular order such as state names or land cover classes.
Colors should be intuitive: rivers should be blue, for example, and pastures green.
Avoid too many categories: maps with large legends and many colors can be uninterpretable.<a href="references.html#fn43" class="footnote-ref" id="fnref43"><sup>43</sup></a></p>
Avoid too many categories: maps with large legends and many colors can be uninterpretable.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content='&lt;p&gt;
&lt;code&gt;col = "MAP_COLORS"&lt;/code&gt; can be used in maps with a large number of individual polygons (for example, a map of individual countries) to create unique colors for adjacent polygons.&lt;/p&gt;'><sup>43</sup></a></p>
<p>The second group is sequential palettes.
These follow a gradient, for example from light to dark colors (light colors tend to represent lower values), and are appropriate for continuous (numeric) variables.
Sequential palettes can be single (<code>Blues</code> go from light to dark blue, for example) or multi-color/hue (<code>YlOrBr</code> is gradient from light yellow to brown via orange, for example), as demonstrated in the code chunk below — output not shown, run the code yourself to see the results!</p>
Expand All @@ -391,7 +393,7 @@ <h3>
This property is not preserved in the rainbow color palette; therefore, we suggest avoiding it in geographic data visualization <span class="citation">(<a href="references.html#ref-borland_rainbow_2007" role="doc-biblioref">Borland and Taylor II 2007</a>)</span>.
Instead, <a href="https://cran.r-project.org/web/packages/viridis/">the viridis color palettes</a>, also available in <strong>tmap</strong>, can be used.
Secondly, changes in colors should be accessible to the largest number of people.
Therefore, it is important to use colorblind friendly palettes as often as possible.<a href="references.html#fn44" class="footnote-ref" id="fnref44"><sup>44</sup></a></p>
Therefore, it is important to use colorblind friendly palettes as often as possible.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;See the “Color blindness simulator” options in &lt;code&gt;tmaptools::palette_explorer()&lt;/code&gt;.&lt;/p&gt;"><sup>44</sup></a></p>
</div>
<div id="layouts" class="section level3" number="9.2.5">
<h3>
Expand Down Expand Up @@ -798,7 +800,8 @@ <h2>
<code>shiny-server</code> also serves apps defined by a single <code>app.R</code> file in an ‘app folder’.
Learn more at: <a href="https://github.com/rstudio/shiny-server" class="uri">https://github.com/rstudio/shiny-server</a>.
</div>
<p>Before considering large apps, it is worth seeing a minimal example, named ‘lifeApp’, in action.<a href="references.html#fn45" class="footnote-ref" id="fnref45"><sup>45</sup></a>
<p>Before considering large apps, it is worth seeing a minimal example, named ‘lifeApp’, in action.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;
The word ‘app’ in this context refers to ‘web application’ and should not be confused with smartphone apps, the more common meaning of the word.&lt;/p&gt;"><sup>45</sup></a>
The code below defines and launches — with the command <code><a href="https://rdrr.io/pkg/shiny/man/shinyApp.html">shinyApp()</a></code> — a lifeApp, which provides an interactive slider allowing users to make countries appear with progressively lower levels of life expectancy (see Figure <a href="adv-map.html#fig:lifeApp">9.24</a>):</p>
<div class="sourceCode" id="cb329"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://shiny.rstudio.com/">shiny</a></span><span class="op">)</span> <span class="co"># for shiny apps</span>
Expand Down Expand Up @@ -1189,6 +1192,7 @@ <h2>
</ol>
</div>
</div>

<div class="chapter-nav">
<div class="prev"><a href="read-write.html"><span class="header-section-number">8</span> Geographic data I/O</a></div>
<div class="next"><a href="gis.html"><span class="header-section-number">10</span> Bridges to GIS software</a></div>
Expand Down Expand Up @@ -1241,7 +1245,7 @@ <h2>Note: Second Edition is under construction 🏗</h2>
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">

<div class="col-12 col-md-6 mt-3">
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2022-03-17.</p>
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2022-03-18.</p>
</div>

<div class="col-12 col-md-6 mt-3">
Expand Down
Loading

0 comments on commit 71ba595

Please sign in to comment.