<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/possum-magic-mapping-an-australian-childrens-book/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.masalmon.eu/2017/12/16/possummagic/"> Maëlle</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Our <a rel="nofollow" href="https://twitter.com/ma_salmon/status/920660343063490562" target="_blank">brand-new baby</a> received a fantastic picture book as a gift: <a rel="nofollow" href="https://en.wikipedia.org/wiki/Possum_Magic" target="_blank">Possum magic</a>, a classic for Aussie kids. Thanks, <a rel="nofollow" href="https://twitter.com/MilesMcBain" target="_blank">Miles</a>! In that book, Hush the possum and her Grandma Poss encounter different Australian animals and travel across well eat their way through the country. It is an adorable story with great illustrations! Reading it will make you feel like travelling to Australia, for instance to <a rel="nofollow" href="https://user2018.r-project.org/" target="_blank">useR! 2018</a>, except you shouldn’t because it is a very scary country:</p>
<blockquote class="twitter-tweet" data-lang="ca">
<p lang="en" dir="ltr">Rough night with <img alt="👶" src="https://s.w.org/images/core/emoji/2.3/72x72/1f476.png" class="wp-smiley">. ☕ was a good start but it was the balcony <img alt="🐍" src="https://s.w.org/images/core/emoji/2.3/72x72/1f40d.png" class="wp-smiley"> capture and release that really <img alt="💓" src="https://s.w.org/images/core/emoji/2.3/72x72/1f493.png" class="wp-smiley"></p>
<p>— Miles McBain (@MilesMcBain) <a rel="nofollow" href="https://twitter.com/MilesMcBain/status/900887097631887360?ref_src=twsrc%5Etfw" target="_blank">25 d’agost de 2017</a></p></blockquote>
<p>However, you can travel and learn geography without leaving the comfort of a snake-free home… by mapping Hush’s adventures! Which is what I decided to do.</p>
<p><span></span></p>
<p>We shall prepare data for the maps in two main steps: first, looking where one can find the animals mentioned in the book; second, attributing a longitude and latitude to the cities Hush goes to.</p>
<h1>Locating the animals, snake included</h1>
<p>In the book, we first learn about how the magic of Grandma Poss affects some animals: wombats, kookaburras, dingoes and emus. We then read how Hush’s invisibility (sorry, spoiler) makes her interact with koalas, kangaroos and snakes. We can imagine Hush and her grandmother live near these animals, in what is called “deep in the Australian bush”. We’ll map where all these animals live so that we can guess where Hush can live for the story to be credible (I admit that the magic part kind of throws this plan out the window, oh well). Moreover, given what Wikipedia says about <a rel="nofollow" href="https://en.wikipedia.org/wiki/The_bush#Australia" target="_blank">the bush</a>, Hush and her grandmother could live anywhere in Australia as long as it’s not in a city, and since Hush’s first city visit is in Adelaide, we can suppose she did not live too far away from there. Let’s see!</p>
<p>In order to map animals, we shall get occurrences from 2011 to 2016 via the rOpenSci <code>spocc</code> package, with GBIF as a data source, and using the <code>scrubr</code> package for cleaning, like in <a rel="nofollow" href="http://www.masalmon.eu/2017/04/08/spocc/" target="_blank">my blog post visualizing waxwings migration</a>. When querying data via <code>spocc</code> one needs a bounding box, so I’ll first load an Australian map from the <a rel="nofollow" href="https://github.com/ropenscilabs/eechidna" target="_blank"><code>eechidna</code> package</a>, product from the rOpenSci 2016 Oz unconf. I was inspired by the code in <a rel="nofollow" href="https://ropensci.org/blog/2017/11/21/ochre/" target="_blank">this blog post</a> that’s also a product from an Oz unconf.</p>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;eechidna&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;ggthemes&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;ggplot2&quot;</span><span>)</span><span>
</span><span>data</span><span>(</span><span>nat_map_2016</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p>Let’s just draw an empty map.</p>
<div>
<div>
<pre><code><span>ozmap</span><span> </span><span>&lt;-</span><span> </span><span>ggplot</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_map</span><span>(</span><span>aes</span><span>(</span><span>map_id</span><span>=</span><span>id</span><span>),</span><span> </span><span>data</span><span>=</span><span>nat_map_2016</span><span>,</span><span>
</span><span>map</span><span>=</span><span>nat_map_2016</span><span>)</span><span> </span><span>+</span><span>
</span><span>expand_limits</span><span>(</span><span>x</span><span>=</span><span>nat_map</span><span>$</span><span>long</span><span>,</span><span> </span><span>y</span><span>=</span><span>nat_map</span><span>$</span><span>lat</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme_map</span><span>()</span><span>
</span><span>ozmap</span><span>
</span></code></pre>
</div>
</div>
<p><img alt="plot of chunk unnamed-chunk-2" src="https://i2.wp.com/www.masalmon.eu/figure/source/2017-12-16-possummagic/unnamed-chunk-2-1.png?w=456" data-recalc-dims="1"></p>
<p>And now, let’s prepare the bounding box!</p>
<div>
<div>
<pre><code><span>bbox</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>min</span><span>(</span><span>nat_map</span><span>$</span><span>long</span><span>),</span><span> </span><span>min</span><span>(</span><span>nat_map</span><span>$</span><span>lat</span><span>),</span><span> </span><span>max</span><span>(</span><span>nat_map</span><span>$</span><span>long</span><span>),</span><span> </span><span>max</span><span>(</span><span>nat_map</span><span>$</span><span>lat</span><span>))</span><span>
</span></code></pre>
</div>
</div>
<p>I’ll make some assumptions about species and families since the book is not completely clear regarding which animals are meant exactly. Before pondering about this I had no idea there were three species of wombats! For wombats, I’m using the two possible families, for kookaburras, emus and kangaroos the whole family and for snake the <a rel="nofollow" href="https://twitter.com/MilesMcBain/status/900957549951819776" target="_blank">one mentioned in that scary thread</a>. For possums, I’m using a family of possums whose Wikipedia page did not indicate they were mostly urban.</p>
<div>
<div>
<pre><code><span>animals</span><span> </span><span>&lt;-</span><span> </span><span>tibble</span><span>::</span><span>tibble</span><span>(</span><span>name</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;wombat&quot;</span><span>,</span><span> </span><span>&quot;wombat&quot;</span><span>,</span><span> </span><span>&quot;kookaburra&quot;</span><span>,</span><span> </span><span>&quot;dingo&quot;</span><span>,</span><span> </span><span>&quot;emu&quot;</span><span>,</span><span>
</span><span>&quot;koala&quot;</span><span>,</span><span> </span><span>&quot;kangaroo&quot;</span><span>,</span><span> </span><span>&quot;snake&quot;</span><span>,</span><span> </span><span>&quot;possum&quot;</span><span>),</span><span>
</span><span>latin</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;Lasiorhinus&quot;</span><span>,</span><span> </span><span>&quot;Vombatus&quot;</span><span>,</span><span> </span><span>&quot;Dacelo&quot;</span><span>,</span><span>
</span><span>&quot;Canis lupus dingo&quot;</span><span>,</span><span> </span><span>&quot;Dromaius&quot;</span><span>,</span><span>
</span><span>&quot;Phascolarctos cinereus&quot;</span><span>,</span><span> </span><span>&quot;Macropus&quot;</span><span>,</span><span> </span><span>&quot;Morelia spilota&quot;</span><span>,</span><span> </span><span>&quot;Phalangeridae&quot;</span><span>))</span><span>
</span><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>animals</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<table>
<thead>
<tr>
<th>name</th>
<th>latin</th>
</tr>
</thead>
<tbody>
<tr>
<td>wombat</td>
<td>Lasiorhinus</td>
</tr>
<tr>
<td>wombat</td>
<td>Vombatus</td>
</tr>
<tr>
<td>kookaburra</td>
<td>Dacelo</td>
</tr>
<tr>
<td>dingo</td>
<td>Canis lupus dingo</td>
</tr>
<tr>
<td>emu</td>
<td>Dromaius</td>
</tr>
<tr>
<td>koala</td>
<td>Phascolarctos cinereus</td>
</tr>
<tr>
<td>kangaroo</td>
<td>Macropus</td>
</tr>
<tr>
<td>snake</td>
<td>Morelia spilota</td>
</tr>
<tr>
<td>possum</td>
<td>Phalangeridae</td>
</tr>
</tbody>
</table>
<p>Here is the function to get occurrences for one species or family.</p>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;spocc&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;scrubr&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;magrittr&quot;</span><span>)</span><span>
</span><span>get_ozccurrences</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>latin</span><span>,</span><span> </span><span>year</span><span>,</span><span> </span><span>bbox</span><span>){</span><span>
</span><span>gbifopts</span><span> </span><span>&lt;-</span><span> </span><span>list</span><span>(</span><span>year</span><span> </span><span>=</span><span> </span><span>year</span><span>)</span><span>
</span><span>ozccurrences</span><span> </span><span>&lt;-</span><span> </span><span>occ</span><span>(</span><span>query</span><span> </span><span>=</span><span> </span><span>latin</span><span>,</span><span>
</span><span>from</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>'gbif'</span><span>),</span><span> </span><span>gbifopts</span><span> </span><span>=</span><span> </span><span>gbifopts</span><span>,</span><span>
</span><span>limit</span><span> </span><span>=</span><span> </span><span>200000</span><span>,</span><span>
</span><span>geometry</span><span> </span><span>=</span><span> </span><span>bbox</span><span>)</span><span>
</span><span>ozccurrences</span><span> </span><span>&lt;-</span><span> </span><span>occ2df</span><span>(</span><span>ozccurrences</span><span>)</span><span>
</span><span>ozccurrences</span><span> </span><span>&lt;-</span><span> </span><span>ozccurrences</span><span> </span><span>%>%</span><span>
</span><span>coord_impossible</span><span>()</span><span> </span><span>%>%</span><span>
</span><span>coord_incomplete</span><span>()</span><span> </span><span>%>%</span><span>
</span><span>coord_unlikely</span><span>()</span><span> </span><span>%>%</span><span>
</span><span>date_standardize</span><span>(</span><span>&quot;%Y-%m-%d&quot;</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>date_missing</span><span>()</span><span>
</span><span>ozccurrences</span><span>$</span><span>latin</span><span> </span><span>&lt;-</span><span> </span><span>latin</span><span>
</span><span>ozccurrences</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
</div>
<p>Let’s test it on kookaburras in 2016, using the whole family. Note, the maps drawn in this section are really meant to just have a look. In a better analysis I’d try to define zones based on the occurrences for instance, and I’d be more perfectionist regarding the looks of the map.</p>
<div>
<div>
<pre><code><span>kookaburras</span><span> </span><span>&lt;-</span><span> </span><span>get_ozccurrences</span><span>(</span><span>&quot;Dacelo&quot;</span><span>,</span><span> </span><span>bbox</span><span> </span><span>=</span><span> </span><span>bbox</span><span>,</span><span> </span><span>year</span><span> </span><span>=</span><span> </span><span>2016</span><span>)</span><span>
</span><span>ozmap</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>kookaburras</span><span>,</span><span>
</span><span>aes</span><span>(</span><span>longitude</span><span>,</span><span> </span><span>latitude</span><span>),</span><span>
</span><span>col</span><span> </span><span>=</span><span> </span><span>&quot;salmon&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img alt="plot of chunk unnamed-chunk-6" src="https://i0.wp.com/www.masalmon.eu/figure/source/2017-12-16-possummagic/unnamed-chunk-6-1.png?w=456" data-recalc-dims="1"></p>
<p>Note that occurrences might be misleading, since to get one you need one observer, so we’ll probably get less occurrences when there are less humans without this meaning the density of the animal itself is lower. But since Hush’s story is told by a human, we expect Hush to live in an area with at least a few observations of the different animals! Otherwise, how could the author know about all this stuff?</p>
<div>
<div>
<pre><code><span>all_ozcurrences</span><span> </span><span>&lt;-</span><span> </span><span>purrr</span><span>::</span><span>map2_df</span><span>(</span><span>rep</span><span>(</span><span>animals</span><span>$</span><span>latin</span><span>,</span><span> </span><span>6</span><span>),</span><span> </span><span>rep</span><span>(</span><span>2011</span><span>:</span><span>2016</span><span>,</span><span> </span><span>nrow</span><span>(</span><span>animals</span><span>)),</span><span> </span><span>get_ozccurrences</span><span>,</span><span>
</span><span>bbox</span><span> </span><span>=</span><span> </span><span>bbox</span><span>)</span><span>
</span><span>all_ozcurrences</span><span> </span><span>&lt;-</span><span> </span><span>dplyr</span><span>::</span><span>rename</span><span>(</span><span>all_ozcurrences</span><span>,</span><span> </span><span>scientific_name</span><span> </span><span>=</span><span> </span><span>name</span><span>)</span><span>
</span><span>all_ozcurrences</span><span> </span><span>&lt;-</span><span> </span><span>dplyr</span><span>::</span><span>left_join</span><span>(</span><span>all_ozcurrences</span><span>,</span><span> </span><span>animals</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>&quot;latin&quot;</span><span>)</span><span>
</span><span>readr</span><span>::</span><span>write_csv</span><span>(</span><span>all_ozcurrences</span><span>,</span><span> </span><span>path</span><span> </span><span>=</span><span> </span><span>&quot;data/2017-12-15-all_ozcurrences.csv&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p>Now that we have a reasonable number of occurrences, we can check where the animals have been seen, hopefully all of them have at least one place in common, preferably not too far from Adelaide (whose location we’ll show in the next section). Although colours are not needed here, I’ll get a bit artistic and use the pretty “healthy reef” palette part of the <code>ochRe</code> package created during the rOpenSci Oz unconf this year, see <a rel="nofollow" href="https://ropensci.org/blog/2017/11/21/ochre/" target="_blank">this blog post</a>. This palette has 9 colours, so it was handy.</p>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;ochRe&quot;</span><span>)</span><span>
</span><span>ozmap</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>all_ozcurrences</span><span>,</span><span>
</span><span>aes</span><span>(</span><span>longitude</span><span>,</span><span> </span><span>latitude</span><span>,</span><span>
</span><span>col</span><span> </span><span>=</span><span> </span><span>name</span><span>))</span><span> </span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>name</span><span>)</span><span>+</span><span> </span><span>scale_colour_ochre</span><span>(</span><span>palette</span><span> </span><span>=</span><span> </span><span>&quot;healthy_reef&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>&quot;none&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img alt="plot of chunk unnamed-chunk-8" src="https://i1.wp.com/www.masalmon.eu/figure/source/2017-12-16-possummagic/unnamed-chunk-8-1.png?w=456" data-recalc-dims="1"></p>
<p>Ok, when you see where Adelaide is you’ll agree that it’s fine to assume Hush and Grandma Poss live in the bush a bit further North from Adelaide. By the way, the only map of the trip <a rel="nofollow" href="http://afieldtriplife.com/wp-content/uploads/2015/04/australian-map-e1427908892939.jpg" target="_blank">I found online</a> does not seem to show their home address. Maybe because they do not want the possum stars to have to deal with too many visitors?</p>
<p>I also notice I only get no occurrence from the <a rel="nofollow" href="https://en.wikipedia.org/wiki/Northern_hairy-nosed_wombat" target="_blank">Northern hairy-nosed wombat</a> but it seems to be rarer than the common wombat (ok, the name might have been a good clue for me before I got the data).</p>
<h1>Geocoding the cities</h1>
<p>The cities we need to geocode, and the food eaten by Hush and Grandma Poss while visiting them, are:</p>
<div>
<div>
<pre><code><span>cities</span><span> </span><span>&lt;-</span><span> </span><span>tibble</span><span>::</span><span>tibble</span><span>(</span><span>city</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;Adelaide&quot;</span><span>,</span><span> </span><span>&quot;Melbourne&quot;</span><span>,</span><span>
</span><span>&quot;Sydney&quot;</span><span>,</span><span> </span><span>&quot;Brisbane&quot;</span><span>,</span><span>
</span><span>&quot;Darwin&quot;</span><span>,</span><span> </span><span>&quot;Perth&quot;</span><span>,</span><span>
</span><span>&quot;Hobart&quot;</span><span>),</span><span>
</span><span>food</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;Anzac biscuit&quot;</span><span>,</span><span> </span><span>&quot;mornay and Minties&quot;</span><span>,</span><span>
</span><span>&quot;steak and salad&quot;</span><span>,</span><span> </span><span>&quot;pumpkin scones&quot;</span><span>,</span><span>
</span><span>&quot;vegemite&quot;</span><span>,</span><span> </span><span>&quot;pavlova&quot;</span><span>,</span><span> </span><span>&quot;lamington&quot;</span><span>))</span><span>
</span><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>cities</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<table>
<thead>
<tr>
<th>city</th>
<th>food</th>
</tr>
</thead>
<tbody>
<tr>
<td>Adelaide</td>
<td>Anzac biscuit</td>
</tr>
<tr>
<td>Melbourne</td>
<td>mornay and Minties</td>
</tr>
<tr>
<td>Sydney</td>
<td>steak and salad</td>
</tr>
<tr>
<td>Brisbane</td>
<td>pumpkin scones</td>
</tr>
<tr>
<td>Darwin</td>
<td>vegemite</td>
</tr>
<tr>
<td>Perth</td>
<td>pavlova</td>
</tr>
<tr>
<td>Hobart</td>
<td>lamington</td>
</tr>
</tbody>
</table>
<p>We shall perfom geocoding using my own package <a rel="nofollow" href="https://github.com/ropensci/opencage" target="_blank"><code>opencage</code></a> which is a wrapper for R of the <a rel="nofollow" href="https://geocoder.opencagedata.com/" target="_blank">OpenCage API</a>. This package was <a rel="nofollow" href="https://github.com/ropensci/onboarding/issues/36" target="_blank">reviewed by Julia Silge for rOpenSci</a>.</p>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;opencage&quot;</span><span>)</span><span>
</span><span>get_lozcation</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>city</span><span>){</span><span>
</span><span>opencage_results</span><span> </span><span>&lt;-</span><span> </span><span>opencage</span><span>::</span><span>opencage_forward</span><span>(</span><span>placename</span><span> </span><span>=</span><span> </span><span>city</span><span>,</span><span>
</span><span>countrycode</span><span> </span><span>=</span><span> </span><span>&quot;AU&quot;</span><span>)</span><span>
</span><span>output</span><span> </span><span>&lt;-</span><span> </span><span>opencage_results</span><span>$</span><span>results</span><span>
</span><span>output</span><span>$</span><span>city</span><span> </span><span>&lt;-</span><span> </span><span>city</span><span>
</span><span>output</span><span> </span><span>&lt;-</span><span> </span><span>output</span><span>[</span><span>!</span><span>is.na</span><span>(</span><span>output</span><span>$</span><span>components.city</span><span>),]</span><span>
</span><span>output</span><span> </span><span>&lt;-</span><span> </span><span>output</span><span>[</span><span>output</span><span>$</span><span>components.city</span><span> </span><span>==</span><span> </span><span>city</span><span>,]</span><span>
</span><span>if</span><span>(</span><span>nrow</span><span>(</span><span>output</span><span>)</span><span> </span><span>></span><span> </span><span>1</span><span>){</span><span>
</span><span>output</span><span> </span><span>&lt;-</span><span> </span><span>output</span><span>[</span><span>output</span><span>$</span><span>confidence</span><span> </span><span>==</span><span> </span><span>min</span><span>(</span><span>output</span><span>$</span><span>confidence</span><span>),]</span><span>
</span><span>}</span><span>
</span><span>output</span><span>
</span><span>}</span><span> </span></code></pre>
</div>
</div>
<p>A small technical note, depending on the font you use in RMarkdown and that sort of encoding joy sources, you now get a flag from the OpenCage API! In my blogging font, it is a bit boring, e.g.:</p>
<div>
<div>
<pre><code><span>adelaide</span><span> </span><span>&lt;-</span><span> </span><span>get_lozcation</span><span>(</span><span>city</span><span> </span><span>=</span><span> </span><span>&quot;Adelaide&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><code>adelaide$annotations.flag</code> gives me <img alt="🇦🇺" src="https://s.w.org/images/core/emoji/2.3/72x72/1f1e6-1f1fa.png" class="wp-smiley">. But still, a cool feature… among other tons of more useful features OpenCage has like the <a rel="nofollow" href="http://blog.opencagedata.com/post/160294347883/shrtr-pls" target="_blank"><code>abbr</code> parameter to get shorter names</a>.</p>
<p>Now let’s geocode all cities!</p>
<div>
<div>
<pre><code><span>geozcoded_cities</span><span> </span><span>&lt;-</span><span> </span><span>purrr</span><span>::</span><span>map_df</span><span>(</span><span>cities</span><span>$</span><span>city</span><span>,</span><span> </span><span>get_lozcation</span><span>)</span><span>
</span><span>geozcoded_cities</span><span> </span><span>&lt;-</span><span> </span><span>dplyr</span><span>::</span><span>left_join</span><span>(</span><span>geozcoded_cities</span><span>,</span><span> </span><span>cities</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>&quot;city&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p>Cool, now we can plot them!</p>
<div>
<div>
<pre><code><span>ozmap</span><span> </span><span>+</span><span>
</span><span>geom_label</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>geozcoded_cities</span><span>,</span><span>
</span><span>aes</span><span>(</span><span>geometry.lng</span><span>,</span><span> </span><span>geometry.lat</span><span>,</span><span>
</span><span>label</span><span> </span><span>=</span><span> </span><span>city</span><span>))</span><span>
</span></code></pre>
</div>
</div>
<p><img alt="plot of chunk unnamed-chunk-13" src="https://i0.wp.com/www.masalmon.eu/figure/source/2017-12-16-possummagic/unnamed-chunk-13-1.png?w=456" data-recalc-dims="1"></p>
<h1>Mapping the book!</h1>
<p>In this last section, I’ll invent a home address for Hush and Grandma Poss and produce an educative map containing both city names and city food specialties! Having 7 cities and one bush location, I’ll use an 8-colour <code>ochRe</code> palette, “namatjira_qual” derived from the <a rel="nofollow" href="http://www.menziesartbrands.com/items/twin-ghosts" target="_blank">beautiful watercolour painting “Twin Ghosts”</a>, by Aboriginal artist Albert Namatjira (again, I’m getting info from <a rel="nofollow" href="https://ropensci.org/blog/2017/11/21/ochre/" target="_blank">this blog post</a>). Here again, no information is conveyed by the color.</p>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;ggrepel&quot;</span><span>)</span><span>
</span><span>hush_home</span><span> </span><span>&lt;-</span><span> </span><span>tibble</span><span>::</span><span>tibble</span><span>(</span><span>geometry.lng</span><span> </span><span>=</span><span> </span><span>adelaide</span><span>$</span><span>geometry.lng</span><span>,</span><span>
</span><span>geometry.lat</span><span> </span><span>=</span><span> </span><span>adelaide</span><span>$</span><span>geometry.lat</span><span> </span><span>+</span><span> </span><span>0.01</span><span>,</span><span>
</span><span>city</span><span> </span><span>=</span><span> </span><span>&quot;the bush&quot;</span><span>,</span><span>
</span><span>food</span><span> </span><span>=</span><span> </span><span>&quot;Possum food&quot;</span><span>)</span><span>
</span><span>hush_places</span><span> </span><span>&lt;-</span><span> </span><span>dplyr</span><span>::</span><span>bind_rows</span><span>(</span><span>geozcoded_cities</span><span>,</span><span> </span><span>hush_home</span><span>)</span><span>
</span><span>ozmap</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>hush_places</span><span>,</span><span>
</span><span>aes</span><span>(</span><span>geometry.lng</span><span>,</span><span> </span><span>geometry.lat</span><span>),</span><span>
</span><span>col</span><span> </span><span>=</span><span> </span><span>&quot;grey20&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_label_repel</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>hush_places</span><span>,</span><span>
</span><span>aes</span><span>(</span><span>geometry.lng</span><span> </span><span>+</span><span> </span><span>0.3</span><span>,</span><span> </span><span>geometry.lat</span><span> </span><span>+</span><span> </span><span>0.3</span><span>,</span><span>
</span><span>label</span><span> </span><span>=</span><span> </span><span>paste</span><span>(</span><span>food</span><span>,</span><span> </span><span>&quot;in&quot;</span><span>,</span><span> </span><span>city</span><span>),</span><span>
</span><span>fill</span><span> </span><span>=</span><span> </span><span>city</span><span>))</span><span> </span><span>+</span><span> </span><span>scale_fill_ochre</span><span>(</span><span>palette</span><span> </span><span>=</span><span> </span><span>&quot;namatjira_qual&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>&quot;none&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Hush's culinary tour of Australia&quot;</span><span>,</span><span>
</span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Inspired by the children's book Possum magic by M. Fox and J. Vivas&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img alt="plot of chunk unnamed-chunk-14" src="https://i0.wp.com/www.masalmon.eu/figure/source/2017-12-16-possummagic/unnamed-chunk-14-1.png?w=456" data-recalc-dims="1"></p>
<p>Now, I’ll show this map to our baby as soon as he’s old enough to get it, and then we’ll plan a culinary tour of Australia together! Probably not on a bike like Hush and Grandma Poss, unless we can whip up some magic!</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.masalmon.eu/2017/12/16/possummagic/"> Maëlle</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/T9S8Grjg7hU" height="1"></a></div>