Skip to content

Commit

Permalink
Deploy commit: adds area comment 6365834
Browse files Browse the repository at this point in the history
  • Loading branch information
Nowosad committed Nov 28, 2024
1 parent 761d953 commit fb14fb4
Show file tree
Hide file tree
Showing 33 changed files with 109 additions and 108 deletions.
2 changes: 1 addition & 1 deletion 07-reproj.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ st_is_longlat(london_geo)
## Geometry operations on projected and unprojected data {#geom-proj}

Since **sf** version 1.0.0, R's ability to work with geographic vector datasets that have lon/lat CRSs has improved substantially, thanks to its integration with the S2 *spherical geometry engine* introduced in Section \@ref(s2).
As shown in Figure \@ref(fig:s2geos), **sf** uses either GEOS\index{GEOS} or the S2\index{S2} depending on the type of CRS and whether S2 has been disabled (it is enabled by default).
As shown in Figure \@ref(fig:s2geos), **sf** uses either GEOS\index{GEOS} or the S2\index{S2} depending on the type of CRS and whether S2 has been disabled (it is enabled by default).^[The `st_area()` function is an exception, as it uses the **lwgeom**'s `st_geod_area()` function to calculate areas for data with geographic CRSs when `sf_use_s2()` is disabled.]
GEOS is always used for projected data and data with no CRS; for geographic data, S2 is used by default but can be disabled with `sf::sf_use_s2(FALSE)`.

<div class="figure" style="text-align: center">
Expand Down
2 changes: 1 addition & 1 deletion 13-transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ routes_short_scenario = routes_short |>
mutate(bicycle = bicycle + car_driver * uptake,
car_driver = car_driver * (1 - uptake))
sum(routes_short_scenario$bicycle) - sum(routes_short$bicycle)
#> [1] 3856
#> [1] 3845
```

Having created a scenario in which approximately 4000 trips have switched from driving to cycling, we can now model where this updated modeled cycling activity will take place.
Expand Down
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h2>Second Edition</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-11-20.</p>
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2024-11-28.</p>
</div>

<div class="col-12 col-md-6 mt-3">
Expand Down
18 changes: 9 additions & 9 deletions adv-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ <h3>
</ul>
<p>Additionally, we may customize the fill and border color transparency using <code>fill_alpha</code> and <code>col_alpha</code>.</p>
<p>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>48</sup></a>
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>49</sup></a>
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="cb307"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">ma1</span> <span class="op">=</span> <span class="fu"><a href="https://r-tmap.github.io/tmap/reference/tm_shape.html">tm_shape</a></span><span class="op">(</span><span class="va">nz</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://r-tmap.github.io/tmap/reference/tm_polygons.html">tm_polygons</a></span><span class="op">(</span>fill <span class="op">=</span> <span class="st">"red"</span><span class="op">)</span></span>
Expand Down Expand Up @@ -449,10 +449,10 @@ <h3>
<p>
There are three main groups of color palettes: categorical, sequential and diverging (Figure <a href="adv-map.html#fig:colpal">9.8</a>), and each of them serves a different purpose.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;
A fourth group of color palettes, called bivariate, also exists.
They are used when we want to represent relations between two variables on one map.&lt;/p&gt;"><sup>49</sup></a>
They are used when we want to represent relations between two variables on one map.&lt;/p&gt;"><sup>50</sup></a>
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 class="footnote-ref" tabindex="0" data-toggle="popover" data-content='&lt;p&gt;&lt;code&gt;fill = "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 fill colors for adjacent polygons.&lt;/p&gt;'><sup>50</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;fill = "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 fill colors for adjacent polygons.&lt;/p&gt;'><sup>51</sup></a></p>
<p>The second group is sequential palettes.
These follow a gradient, for example from light to dark colors (light colors often tend to represent lower values), and are appropriate for continuous (numeric) variables.
Sequential palettes can be single (<code>greens</code> goes from light to dark green, for example) or multi-color/hue (<code>yl_gn_bu</code> is gradient from light yellow to blue via green, for example), as demonstrated in the code chunk below — output not shown, run the code yourself to see the results!</p>
Expand Down Expand Up @@ -482,7 +482,7 @@ <h3>
Color palettes should also be easy to understand to effectively convey information.
It should be clear which values are lower and which are higher, and colors should change gradually.
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 class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;See the “Color vision” options and the “Color Blind Friendliness” panel in &lt;code&gt;cols4all::c4a_gui()&lt;/code&gt;.&lt;/p&gt;"><sup>51</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 vision” options and the “Color Blind Friendliness” panel in &lt;code&gt;cols4all::c4a_gui()&lt;/code&gt;.&lt;/p&gt;"><sup>52</sup></a></p>
</div>
<div id="legends" class="section level3" number="9.2.5">
<h3>
Expand Down Expand Up @@ -526,7 +526,7 @@ <h3>
The map layout refers to the combination of all map elements into a cohesive map.
Map elements include among others the objects to be mapped, the map grid, the scale bar, the title, and margins, while the color settings covered in the previous section relate to the palette and breakpoints used to affect how the map looks.
Both may result in subtle changes that can have an equally large impact on the impression left by your maps.</p>
<p>Additional map elements such as graticules , north arrows, scale bars and map titles have their own functions: <code><a href="https://r-tmap.github.io/tmap/reference/tm_graticules.html">tm_graticules()</a></code>, <code><a href="https://r-tmap.github.io/tmap/reference/tm_compass.html">tm_compass()</a></code>, <code><a href="https://r-tmap.github.io/tmap/reference/tm_scalebar.html">tm_scalebar()</a></code>, and <code><a href="https://r-tmap.github.io/tmap/reference/tm_title.html">tm_title()</a></code> (Figure <a href="adv-map.html#fig:na-sb">9.9</a>).<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;Another additional map elements include &lt;code&gt;tm_grid()&lt;/code&gt;, &lt;code&gt;tm_logo()&lt;/code&gt; and &lt;code&gt;tm_credits()&lt;/code&gt;.&lt;/p&gt;"><sup>52</sup></a></p>
<p>Additional map elements such as graticules , north arrows, scale bars and map titles have their own functions: <code><a href="https://r-tmap.github.io/tmap/reference/tm_graticules.html">tm_graticules()</a></code>, <code><a href="https://r-tmap.github.io/tmap/reference/tm_compass.html">tm_compass()</a></code>, <code><a href="https://r-tmap.github.io/tmap/reference/tm_scalebar.html">tm_scalebar()</a></code>, and <code><a href="https://r-tmap.github.io/tmap/reference/tm_title.html">tm_title()</a></code> (Figure <a href="adv-map.html#fig:na-sb">9.9</a>).<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;Another additional map elements include &lt;code&gt;tm_grid()&lt;/code&gt;, &lt;code&gt;tm_logo()&lt;/code&gt; and &lt;code&gt;tm_credits()&lt;/code&gt;.&lt;/p&gt;"><sup>53</sup></a></p>
<div class="sourceCode" id="cb315"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">map_nz</span> <span class="op">+</span> </span>
<span> <span class="fu"><a href="https://r-tmap.github.io/tmap/reference/tm_graticules.html">tm_graticules</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span>
Expand Down Expand Up @@ -741,7 +741,7 @@ <h2>
<li>
<code>free.coords = FALSE</code>, which maintains the map extent for each map iteration</li>
</ul>
<p>These additional arguments are demonstrated in the subsequent code chunk<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;There is also a shortcut for this approach: &lt;code&gt;tm_facets_pagewise()&lt;/code&gt;.&lt;/p&gt;"><sup>53</sup></a>:</p>
<p>These additional arguments are demonstrated in the subsequent code chunk<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;There is also a shortcut for this approach: &lt;code&gt;tm_facets_pagewise()&lt;/code&gt;.&lt;/p&gt;"><sup>54</sup></a>:</p>
<div class="sourceCode" id="cb328"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">urb_anim</span> <span class="op">=</span> <span class="fu"><a href="https://r-tmap.github.io/tmap/reference/tm_shape.html">tm_shape</a></span><span class="op">(</span><span class="va">world</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://r-tmap.github.io/tmap/reference/tm_polygons.html">tm_polygons</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span> </span>
<span> <span class="fu"><a href="https://r-tmap.github.io/tmap/reference/tm_shape.html">tm_shape</a></span><span class="op">(</span><span class="va">urban_agglomerations</span><span class="op">)</span> <span class="op">+</span> <span class="fu"><a href="https://r-tmap.github.io/tmap/reference/tm_symbols.html">tm_symbols</a></span><span class="op">(</span>size <span class="op">=</span> <span class="st">"population_millions"</span><span class="op">)</span> <span class="op">+</span></span>
Expand Down Expand Up @@ -845,7 +845,7 @@ <h2>
<p>One important thing to keep in mind is that <strong>mapview</strong> layers are added via the <code>+</code> operator (similar to <strong>ggplot2</strong> or <strong>tmap</strong>).
By default, <strong>mapview</strong> uses the leaflet JavaScript library to render the output maps, which is user-friendly and has a lot of features.
However, some alternative rendering libraries could be more performant (work more smoothly on larger datasets).
<strong>mapview</strong> allows to set alternative rendering libraries (<code>"leafgl"</code> and <code>"mapdeck"</code>) in the <code><a href="https://rdrr.io/pkg/mapview/man/mapviewOptions.html">mapviewOptions()</a></code>.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;You may also try to use &lt;code&gt;mapviewOptions(georaster = TRUE)&lt;/code&gt; for more performant visualizations of large raster data.&lt;/p&gt;"><sup>54</sup></a>
<strong>mapview</strong> allows to set alternative rendering libraries (<code>"leafgl"</code> and <code>"mapdeck"</code>) in the <code><a href="https://rdrr.io/pkg/mapview/man/mapviewOptions.html">mapviewOptions()</a></code>.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;You may also try to use &lt;code&gt;mapviewOptions(georaster = TRUE)&lt;/code&gt; for more performant visualizations of large raster data.&lt;/p&gt;"><sup>55</sup></a>
For further information on <strong>mapview</strong>, see the package’s website at: <a href="https://r-spatial.github.io/mapview/articles/">r-spatial.github.io/mapview/</a>.</p>
<p>There are other ways to create interactive maps with R.
The <strong>googleway</strong> package, for example, provides an interactive mapping interface that is flexible and extensible
Expand Down Expand Up @@ -930,7 +930,7 @@ <h2>
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 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>55</sup></a>
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>56</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.23</a>):</p>
<div class="sourceCode" id="cb338"><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://shiny.posit.co/">shiny</a></span><span class="op">)</span> <span class="co"># for shiny apps</span></span>
Expand Down Expand Up @@ -1343,7 +1343,7 @@ <h2>Second Edition</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-11-20.</p>
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2024-11-28.</p>
</div>

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

0 comments on commit fb14fb4

Please sign in to comment.