Skip to content

Commit 910572e

Browse files
committed
Deploy commit: Merge pull request #1175 from geocompx/refactor_location
Refactor Chapter 14 to use z22 Census 2022 data 2cb2a1a
1 parent 7c37e65 commit 910572e

29 files changed

Lines changed: 313 additions & 241 deletions

14-location.md

Lines changed: 130 additions & 96 deletions
Large diffs are not rendered by default.

404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <h2>Second Edition</h2>
129129
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">
130130

131131
<div class="col-12 col-md-6 mt-3">
132-
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-28.</p>
132+
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-30.</p>
133133
</div>
134134

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

adv-map.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ <h2>Second Edition</h2>
13431343
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">
13441344

13451345
<div class="col-12 col-md-6 mt-3">
1346-
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-28.</p>
1346+
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-30.</p>
13471347
</div>
13481348

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

algorithms.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ <h2>Second Edition</h2>
529529
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">
530530

531531
<div class="col-12 col-md-6 mt-3">
532-
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-28.</p>
532+
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-30.</p>
533533
</div>
534534

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

attr.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ <h2>Second Edition</h2>
861861
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">
862862

863863
<div class="col-12 col-md-6 mt-3">
864-
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-28.</p>
864+
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-30.</p>
865865
</div>
866866

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

conclusion.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ <h2>
144144
<p>Although the classes, attributes and column names of the resulting objects <code>nz_u1</code> to <code>nz_u3</code> differ, their geometries are identical, as verified using the base R function <code><a href="https://rspatial.github.io/terra/reference/identical.html">identical()</a></code>.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;
145145
The first operation, undertaken by the function &lt;code&gt;st_union()&lt;/code&gt;, creates an object of class &lt;code&gt;sfc&lt;/code&gt; (a simple feature column).
146146
The latter two operations create &lt;code&gt;sf&lt;/code&gt; objects, each of which &lt;em&gt;contains&lt;/em&gt; a simple feature column.
147-
Therefore, it is the geometries contained in simple feature columns, not the objects themselves, that are identical.&lt;/p&gt;"><sup>104</sup></a>
147+
Therefore, it is the geometries contained in simple feature columns, not the objects themselves, that are identical.&lt;/p&gt;"><sup>103</sup></a>
148148
Which to use?
149149
It depends: the former only processes the geometry data contained in <code>nz</code> so is faster, while the other options performed attribute operations, which may be useful for subsequent steps.
150150
Whether to use the base R function <code><a href="https://rspatial.github.io/terra/reference/aggregate.html">aggregate()</a></code> or the <strong>dplyr</strong> function <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise()</a></code> is a matter of preference, with the latter being more readable for many.</p>
@@ -326,7 +326,7 @@ <h2>
326326
<p>Another software-related direction for future learning is <strong>discovering geocomputation with other languages</strong>.
327327
There are good reasons for learning R as a language for geocomputation, as described in Chapter <a href="intro.html#intro">1</a>, but it is not the only option.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;
328328
R’s strengths are particularly relevant to our definition of geocomputation due to its emphasis on scientific reproducibility, widespread use in academic research and unparalleled support for statistical modeling of geographic data.
329-
Furthermore, we advocate learning one language for geocomputation in depth before delving into other languages/frameworks because of the costs associated with context switching, and R is an excellent starting point on your geocomputational journey.&lt;/p&gt;"><sup>105</sup></a>
329+
Furthermore, we advocate learning one language for geocomputation in depth before delving into other languages/frameworks because of the costs associated with context switching, and R is an excellent starting point on your geocomputational journey.&lt;/p&gt;"><sup>104</sup></a>
330330
It would be possible to study <em>Geocomputation with: Python</em>, <em>C++</em>, <em>JavaScript</em>, <em>Scala</em> or <em>Rust</em> in equal depth.
331331
Each has evolving geospatial capabilities.
332332
<a href="https://github.com/rasterio/rasterio"><strong>rasterio</strong></a>, for example, is a Python package with similar functionality as the <strong>terra</strong> package used in this book.
@@ -444,7 +444,7 @@ <h2>Second Edition</h2>
444444
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">
445445

446446
<div class="col-12 col-md-6 mt-3">
447-
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-28.</p>
447+
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-30.</p>
448448
</div>
449449

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

eco.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ <h2>
172172
<span><span class="va">dem</span> <span class="op">=</span> <span class="fu"><a href="https://rspatial.github.io/terra/reference/rast.html">rast</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/system.file.html">system.file</a></span><span class="op">(</span><span class="st">"raster/dem.tif"</span>, package <span class="op">=</span> <span class="st">"spDataLarge"</span><span class="op">)</span><span class="op">)</span></span>
173173
<span><span class="va">ndvi</span> <span class="op">=</span> <span class="fu"><a href="https://rspatial.github.io/terra/reference/rast.html">rast</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/system.file.html">system.file</a></span><span class="op">(</span><span class="st">"raster/ndvi.tif"</span>, package <span class="op">=</span> <span class="st">"spDataLarge"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
174174
<p><code>study_area</code> is a polygon representing the outline of the study area, and <code>random_points</code> is an <code>sf</code> object containing the 100 randomly chosen sites.
175-
<code>comm</code> is a community matrix of the wide data format <span class="citation">(<a href="references.html#ref-wickham_tidy_2014">Wickham 2014</a>)</span> where the rows represent the visited sites in the field and the columns the observed species.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;In statistics, this is also called a contingency table or cross-table.&lt;/p&gt;"><sup>101</sup></a></p>
175+
<code>comm</code> is a community matrix of the wide data format <span class="citation">(<a href="references.html#ref-wickham_tidy_2014">Wickham 2014</a>)</span> where the rows represent the visited sites in the field and the columns the observed species.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;In statistics, this is also called a contingency table or cross-table.&lt;/p&gt;"><sup>100</sup></a></p>
176176
<div class="sourceCode" id="cb491"><pre class="downlit sourceCode r">
177177
<code class="sourceCode R"><span><span class="co"># sites 35 to 40 and corresponding occurrences of the first five species in the</span></span>
178178
<span><span class="co"># community matrix</span></span>
@@ -198,7 +198,7 @@ <h2>
198198
<p>The next step is to compute variables which are not only needed for the modeling and predictive mapping (see Section <a href="eco.html#predictive-mapping">15.4.2</a>) but also for aligning the non-metric multidimensional scaling (NMDS) axes with the main gradient in the study area, altitude and humidity, respectively (see Section <a href="eco.html#nmds">15.3</a>).</p>
199199
<p>Specifically, we compute catchment slope and catchment area from a digital elevation model using R-GIS bridges (see Chapter <a href="gis.html#gis">10</a>).
200200
Curvatures might also represent valuable predictors, and in the Exercise section you can find out how they would impact the modeling result.</p>
201-
<p>To compute catchment area and catchment slope, we can make use of the <code>sagang:sagawetnessindex</code> function.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;Admittedly, it is a bit unsatisfying that the only way of knowing that &lt;code&gt;sagawetnessindex&lt;/code&gt; computes the desired terrain attributes is to be familiar with SAGA.&lt;/p&gt;"><sup>102</sup></a>
201+
<p>To compute catchment area and catchment slope, we can make use of the <code>sagang:sagawetnessindex</code> function.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content="&lt;p&gt;Admittedly, it is a bit unsatisfying that the only way of knowing that &lt;code&gt;sagawetnessindex&lt;/code&gt; computes the desired terrain attributes is to be familiar with SAGA.&lt;/p&gt;"><sup>101</sup></a>
202202
<code><a href="https://r-spatial.github.io/qgisprocess/reference/qgis_show_help.html">qgis_show_help()</a></code> returns all function parameters and default values of a specific geoalgorithm.
203203
Here, we present only a selection of the complete output.</p>
204204
<div class="sourceCode" id="cb492"><pre class="downlit sourceCode r">
@@ -306,7 +306,7 @@ <h2>
306306
<span><span class="va">pa</span> <span class="op">=</span> <span class="va">pa</span><span class="op">[</span><span class="fu"><a href="https://rspatial.github.io/terra/reference/rowSums.html">rowSums</a></span><span class="op">(</span><span class="va">pa</span><span class="op">)</span> <span class="op">!=</span> <span class="fl">0</span>, <span class="op">]</span> <span class="co"># 84 rows, 69 columns</span></span></code></pre></div>
307307
<p>The resulting matrix serves as input for the NMDS.
308308
<code>k</code> specifies the number of output axes, here, set to 4.<a class="footnote-ref" tabindex="0" data-toggle="popover" data-content='&lt;p&gt;
309-
One way of choosing &lt;code&gt;k&lt;/code&gt; is to try &lt;code&gt;k&lt;/code&gt; values between 1 and 6 and then using the result which yields the best stress value &lt;span class="citation"&gt;(&lt;a href="references.html#ref-mccune_analysis_2002"&gt;McCune et al. 2002&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;'><sup>103</sup></a>
309+
One way of choosing &lt;code&gt;k&lt;/code&gt; is to try &lt;code&gt;k&lt;/code&gt; values between 1 and 6 and then using the result which yields the best stress value &lt;span class="citation"&gt;(&lt;a href="references.html#ref-mccune_analysis_2002"&gt;McCune et al. 2002&lt;/a&gt;)&lt;/span&gt;.&lt;/p&gt;'><sup>102</sup></a>
310310
NMDS is an iterative procedure trying to make the ordinated space more similar to the input matrix in each step.
311311
To make sure that the algorithm converges, we set the number of steps to 500 using the <code>try</code> parameter.</p>
312312
<div class="sourceCode" id="cb499"><pre class="downlit sourceCode r">
@@ -633,7 +633,7 @@ <h2>Second Edition</h2>
633633
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">
634634

635635
<div class="col-12 col-md-6 mt-3">
636-
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-28.</p>
636+
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-30.</p>
637637
</div>
638638

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

figures/circle-intersection-1.png

0 Bytes
Loading

figures/points-1.png

0 Bytes
Loading

foreword-1st-edition.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ <h2>Second Edition</h2>
157157
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">
158158

159159
<div class="col-12 col-md-6 mt-3">
160-
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-28.</p>
160+
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2026-01-30.</p>
161161
</div>
162162

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

0 commit comments

Comments
 (0)