Skip to content

Commit

Permalink
Deploy commit: Merge pull request #1088 from babayoshihiko/main
Browse files Browse the repository at this point in the history
Rmd requires a new blank line when listing be08d2c
  • Loading branch information
Nowosad committed Apr 22, 2024
1 parent 8b3ad92 commit 2cd25bb
Show file tree
Hide file tree
Showing 73 changed files with 399 additions and 386 deletions.
5 changes: 5 additions & 0 deletions 05-geometry-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ linestring = st_cast(multipoint, "LINESTRING")
polyg = st_cast(multipoint, "POLYGON")
```


```
#> tmap v3 code detected. Specific changes listed below.
```

<div class="figure" style="text-align: center">
<img src="figures/single-cast-1.png" alt="Examples of a linestring and a polygon casted from a multipoint geometry." width="100%" />
<p class="caption">(\#fig:single-cast)Examples of a linestring and a polygon casted from a multipoint geometry.</p>
Expand Down
7 changes: 7 additions & 0 deletions 09-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,7 @@ nlcd = rast(system.file("raster/nlcd.tif", package = "spDataLarge"))
```

E1. Create a map showing the geographic distribution of the Human Development Index (`HDI`) across Africa with base **graphics** (hint: use `plot()`) and **tmap** packages (hint: use `tm_shape(africa) + ...`).

- Name two advantages of each based on the experience.
- Name three other mapping packages and an advantage of each.
- Bonus: create three more maps of Africa using these three other packages.
Expand All @@ -1236,6 +1237,7 @@ Next, combine this map and the map created in the previous exercise into a singl


E4. Create a land cover map of the Zion National Park.

- Change the default colors to match your perception of the land cover categories
- Add a scale bar and north arrow and change the position of both to improve the map's aesthetic appeal
- Bonus: Add an inset map of Zion National Park's location in the context of the Utah state. (Hint: an object representing Utah can be subset from the `us_states` dataset.)
Expand All @@ -1245,18 +1247,21 @@ E4. Create a land cover map of the Zion National Park.


E5. Create facet maps of countries in Eastern Africa:

- With one facet showing HDI and the other representing population growth (hint: using variables `HDI` and `pop_growth`, respectively)
- With a 'small multiple' per country



E6. Building on the previous facet map examples, create animated maps of East Africa:

- Showing each country in order
- Showing each country in order with a legend showing the HDI



E7. Create an interactive map of HDI in Africa:

- With **tmap**
- With **mapview**
- With **leaflet**
Expand All @@ -1265,13 +1270,15 @@ E7. Create an interactive map of HDI in Africa:


E8. Sketch on paper ideas for a web mapping app that could be used to make transport or land-use policies more evidence based:

- In the city you live, for a couple of users per day
- In the country you live, for dozens of users per day
- Worldwide for hundreds of users per day and large data serving requirements



E9. Update the code in `coffeeApp/app.R` so that instead of centering on Brazil the user can select which country to focus on:

- Using `textInput()`
- Using `selectInput()`

Expand Down
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ <h2>Note: Second Edition is under final polishing 🏗</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 2024-04-13.</p>
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2024-04-22.</p>
</div>

<div class="col-12 col-md-6 mt-3">
Expand Down
148 changes: 74 additions & 74 deletions adv-map.html

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions algorithms.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion attr.html
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ <h2>Note: Second Edition is under final polishing 🏗</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 2024-04-13.</p>
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2024-04-22.</p>
</div>

<div class="col-12 col-md-6 mt-3">
Expand Down
10 changes: 5 additions & 5 deletions conclusion.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h2>
</h2>
<p>A feature of R, and open source software in general, is that there are often multiple ways to achieve the same result.
The code chunk below illustrates this by using three functions, covered in Chapters <a href="attr.html#attr">3</a> and <a href="geometry-operations.html#geometry-operations">5</a>, to combine the 16 regions of New Zealand into a single geometry:</p>
<div class="sourceCode" id="cb511"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb519"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><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://jakubnowosad.com/spData/">spData</a></span><span class="op">)</span></span>
<span><span class="va">nz_u1</span> <span class="op">=</span> <span class="fu">sf</span><span class="fu">::</span><span class="fu"><a href="https://r-spatial.github.io/sf/reference/geos_combine.html">st_union</a></span><span class="op">(</span><span class="va">nz</span><span class="op">)</span></span>
<span><span class="va">nz_u2</span> <span class="op">=</span> <span class="fu"><a href="https://rspatial.github.io/terra/reference/aggregate.html">aggregate</a></span><span class="op">(</span><span class="va">nz</span><span class="op">[</span><span class="st">"Population"</span><span class="op">]</span>, <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/rep.html">rep</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fu"><a href="https://rspatial.github.io/terra/reference/dimensions.html">nrow</a></span><span class="op">(</span><span class="va">nz</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>, <span class="va">sum</span><span class="op">)</span></span>
Expand All @@ -154,7 +154,7 @@ <h2>
The same applies for all packages showcased in this book, although it can be helpful (when not distracting) to be aware of alternatives and being able to justify your choice of software.</p>
<p>A common choice, for which there is no simple answer, is between <strong>tidyverse</strong> and base R for geocomputation.
The following code chunk, for example, shows <strong>tidyverse</strong> and base R ways to extract the <code>Name</code> column from the <code>nz</code> object, as described in Chapter <a href="attr.html#attr">3</a>:</p>
<div class="sourceCode" id="cb512"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb520"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><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://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span> <span class="co"># attach a tidyverse package</span></span>
<span><span class="va">nz_name1</span> <span class="op">=</span> <span class="va">nz</span><span class="op">[</span><span class="st">"Name"</span><span class="op">]</span> <span class="co"># base R approach</span></span>
<span><span class="va">nz_name2</span> <span class="op">=</span> <span class="va">nz</span> <span class="op">|&gt;</span> <span class="co"># tidyverse approach</span></span>
Expand Down Expand Up @@ -280,13 +280,13 @@ <h3>
You could simply ask how to do this in one of the places outlined in the previous section.
However, it is likely that you will get a better response if you provide a reproducible example of what you have tried so far.
The following code creates a map of the world with blue sea and green land, but the land is not filled in:</p>
<div class="sourceCode" id="cb513"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb521"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><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://r-spatial.github.io/sf/">sf</a></span><span class="op">)</span></span>
<span><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://jakubnowosad.com/spData/">spData</a></span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rspatial.github.io/terra/reference/plot.html">plot</a></span><span class="op">(</span><span class="fu"><a href="https://r-spatial.github.io/sf/reference/st_geometry.html">st_geometry</a></span><span class="op">(</span><span class="va">world</span><span class="op">)</span>, col <span class="op">=</span> <span class="st">"green"</span><span class="op">)</span></span></code></pre></div>
<p>If you post this code in a forum, it is likely that you will get a more specific and useful responses.
For example, someone might respond with the following code, which demonstrably solves the problem, as illustrated in Figure <a href="conclusion.html#fig:16-synthesis-reprex">16.1</a>:</p>
<div class="sourceCode" id="cb514"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb522"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><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://r-spatial.github.io/sf/">sf</a></span><span class="op">)</span></span>
<span><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://jakubnowosad.com/spData/">spData</a></span><span class="op">)</span></span>
<span><span class="co"># use the bg argument to fill in the land</span></span>
Expand Down Expand Up @@ -444,7 +444,7 @@ <h2>Note: Second Edition is under final polishing 🏗</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 2024-04-13.</p>
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2024-04-22.</p>
</div>

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

0 comments on commit 2cd25bb

Please sign in to comment.