Skip to content

Commit

Permalink
image sizes, links, image aligns
Browse files Browse the repository at this point in the history
never say last
  • Loading branch information
midraed committed Feb 20, 2018
1 parent b46feb0 commit e2987bc
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 72 deletions.
18 changes: 9 additions & 9 deletions 062-mapping-RK.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,23 @@ The purpose of a regression analysis, of course, is to develop a model that can
**Requirements**
The following are required to implement Regression Kriging in R

* [Setting-up the Software Environment](Latest version of R software, network connection and sufficient RAM, storage capacity)
* Setting-up the Software Environment

* [Obtaining and Installing R Studio](Latest version of RStudio)
* Obtaining and Installing R Studio

* [R Packages](R packages)
* R Packages

* [Preparation of local soil property data](Point Dataset)
* Preparation of local soil property data

* [Preparation of spatial covariates](Environmental predictors)
* Preparation of spatial covariates

+ [DEM-derived covariates](Relief (e.g. DEM, Slope, TWI))
+ DEM-derived covariates

+ [Land cover/Land use](Organism map (e.g. land use, NDVI, land cover))
+ Land cover/Land use

+ [Climate](Climate Data (e.g. mean precipitation, mean temperature))
+ Climate

+ [Parent material](Parent material (parent material, geology))
+ Parent material


#### Setting Working Space and Initial Steps
Expand Down
10 changes: 5 additions & 5 deletions 07-Validation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ We should warn here that the calculation of the $CI$ is based on the assumption
**Estimation of qualitative map quality measures:** For validation of qualitative soil maps, a sample error matrix is constructed from the validation data (Figure \@ref(fig:errormatrix)). $n$ is the total number of validation locations in the sample. Element $n_{ij}$ of the matrix corresponds to the number of validation locations that have been predicted as class $i$, $i = 1, 2, \dots U$ and belong to class $j$, $j = 1, 2, \dots U$ [@lark1995components]. The matrix summarizes correct predictions and incorrect predictions within the validation data.


```{r errormatrix, fig.cap="Sample error matrix" , out.width='80%', echo=FALSE}
```{r errormatrix, fig.cap="Sample error matrix" , out.width='80%', echo=FALSE, fig.align='center'}
knitr::include_graphics("images/Validation_error_matrix.png")
```

Expand Down Expand Up @@ -477,19 +477,19 @@ abline(lm(dat$OCSKGM ~ dat$MKD_OCSKGM_svm), col = 'blue', lty=2)
par(mfrow=c(1,1))
```

```{r, fig.cap='Spatial bubble of the prediction errors for RK'}
```{r, fig.cap='Spatial bubble of the prediction errors for RK', out.width='60%'}
# spatial bubbles for prediction errors
bubble(dat[!is.na(dat$PE_RK),], "PE_RK", pch = 21,
col=c('red', 'green'))
```

```{r, fig.cap='Spatial bubble of the prediction errors for rf'}
```{r, fig.cap='Spatial bubble of the prediction errors for rf', out.width='60%'}
# spatial bubbles for prediction errors
bubble(dat[!is.na(dat$PE_rf),], "PE_rf", pch = 21,
col=c('red', 'green'))
```

```{r, fig.cap='Spatial bubble of the prediction errors for svm'}
```{r, fig.cap='Spatial bubble of the prediction errors for svm', out.width='60%'}
# spatial bubbles for prediction errors
bubble(dat[!is.na(dat$PE_svm),], "PE_svm", pch = 21,
col=c('red', 'green'))
Expand Down Expand Up @@ -517,7 +517,7 @@ train.ind <- createDataPartition(1:nrow(dat), p = .75, list = FALSE)
train <- dat[ train.ind,]
test <- dat[-train.ind,]
plot(density (log(train$OCSKGM)), col='red')
plot(density (log(train$OCSKGM)), col='red', main="")
lines(density(log(test$OCSKGM)), col='blue')
legend('topright', legend=c("train", "test"),
col=c("red", "blue"), lty=1, cex=1.5)
Expand Down
2 changes: 1 addition & 1 deletion 08-model-evaluation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ We found in this package a very useful set of functions for model evaluation met

We will import the predicted maps and harmonize them in to the same regular grid (~1x1km of spatial resolution). Then we will plot the statistical distribution and the correlation between the three different methods (RK, RF, SVM).

```{r}
```{r, out.width='70%'}
library(raster)
RF<-raster('results/MKD_OCSKGM_rf.tif')
RK<-raster('results/MKD_OCSKGM_RK.tif')
Expand Down
2 changes: 1 addition & 1 deletion 09-uncertainty.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ In the example above we had chosen the normal distribution because it is the mos
There are many different soil properties that in addition vary in space and possibly time. Thus, the characterization of uncertainty about soil properties needs to be extended and include cross- and space-time correlations. It is beyond the scope of this chapter to explain this in detail, for this we refer to standard textbooks such as \cite{goovaerts1997geostatistics} and \cite{webster_2007}. If we assume a joint normal distribution, then a vector of soil properties (be it different soil properties or the same soil property at multiple locations, depths or times) $Z$ is fully characterized by the vector of means $m$ and variance-covariance matrix $C$. Figure \@ref(fig:pairedsoils) shows three examples of 500 paired soil property values that were simulated from different bivariate normal distributions. The left panel shows an uncorrelated case with equal standard deviations for both properties. The centre and right panels show a case where soil property 2 has a greater standard deviation than soil property 1. The difference between these two cases is that the centre panel has a zero correlation between the two soil properties while it is positive in the right panel.


```{r pairedsoils, fig.cap="Scatter plots of 500 paired soil property values drawn from a two-dimensional normal distribution" , out.width='80%', echo=FALSE}
```{r pairedsoils, fig.cap="Scatter plots of 500 paired soil property values drawn from a two-dimensional normal distribution" , out.width='80%', echo=FALSE, fig.align='center'}
knitr::include_graphics("images/pairedsoilpropierties.png")
```

Expand Down
Binary file modified docs/SOCMapping.epub
Binary file not shown.
Binary file modified docs/SOCMapping.pdf
Binary file not shown.
72 changes: 36 additions & 36 deletions docs/SOCMapping.tex
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ \chapter*{Copyright and disclaimer}\label{copyright-and-disclaimer}}
www.fao.org/contact-us/licence-request or addressed to
\href{mailto:copyright@fao.org}{\nolinkurl{copyright@fao.org}}.

FAO information products are available on the FAO website
(www.fao.org/publications) and can be purchased through
FAO information products are available on the
\href{www.fao.org/publications}{FAO website} and can be purchased
through
\href{mailto:publications-sales@fao.org}{\nolinkurl{publications-sales@fao.org}}.

\hypertarget{foreword}{%
Expand Down Expand Up @@ -3261,28 +3262,26 @@ \subsection{Technical Steps - Regression

\begin{itemize}
\item
\href{Latest\%20version\%20of\%20R\%20software,\%20network\%20connection\%20and\%20sufficient\%20RAM,\%20storage\%20capacity}{Setting-up
the Software Environment}
Setting-up the Software Environment
\item
\href{Latest\%20version\%20of\%20RStudio}{Obtaining and Installing R
Studio}
Obtaining and Installing R Studio
\item
\href{R\%20packages}{R Packages}
R Packages
\item
\href{Point\%20Dataset}{Preparation of local soil property data}
Preparation of local soil property data
\item
\href{Environmental\%20predictors}{Preparation of spatial covariates}
\item
\href{Relief\%20(e.g.\%20DEM,\%20Slope,\%20TWI)}{DEM-derived
covariates}
\item
\href{Organism\%20map\%20(e.g.\%20land\%20use,\%20NDVI,\%20land\%20cover)}{Land
cover/Land use}
\item
\href{Climate\%20Data\%20(e.g.\%20mean\%20precipitation,\%20mean\%20temperature)}{Climate}
\item
\href{Parent\%20material\%20(parent\%20material,\%20geology)}{Parent
material}
Preparation of spatial covariates

\begin{itemize}
\item
DEM-derived covariates
\item
Land cover/Land use
\item
Climate
\item
Parent material
\end{itemize}
\end{itemize}

\hypertarget{setting-working-space-and-initial-steps}{%
Expand Down Expand Up @@ -5886,7 +5885,12 @@ \subsection{Additional Probability
validation data.

\begin{figure}
\includegraphics[width=0.8\linewidth]{images/Validation_error_matrix} \caption{Sample error matrix}\label{fig:errormatrix}

{\centering \includegraphics[width=0.8\linewidth]{images/Validation_error_matrix}

}

\caption{Sample error matrix}\label{fig:errormatrix}
\end{figure}

From the sample error matrix the overall purity, map unit purity and
Expand Down Expand Up @@ -6311,10 +6315,7 @@ \subsection{Graphical Map Quality
\end{Shaded}

\begin{figure}
\centering
\includegraphics{SOCMapping_files/figure-latex/unnamed-chunk-89-1.pdf}
\caption{\label{fig:unnamed-chunk-89}Spatial bubble of the prediction errors
for RK}
\includegraphics[width=0.6\linewidth]{SOCMapping_files/figure-latex/unnamed-chunk-89-1} \caption{Spatial bubble of the prediction errors for RK}\label{fig:unnamed-chunk-89}
\end{figure}

\begin{Shaded}
Expand All @@ -6326,10 +6327,7 @@ \subsection{Graphical Map Quality
\end{Shaded}

\begin{figure}
\centering
\includegraphics{SOCMapping_files/figure-latex/unnamed-chunk-90-1.pdf}
\caption{\label{fig:unnamed-chunk-90}Spatial bubble of the prediction errors
for rf}
\includegraphics[width=0.6\linewidth]{SOCMapping_files/figure-latex/unnamed-chunk-90-1} \caption{Spatial bubble of the prediction errors for rf}\label{fig:unnamed-chunk-90}
\end{figure}

\begin{Shaded}
Expand All @@ -6341,10 +6339,7 @@ \subsection{Graphical Map Quality
\end{Shaded}

\begin{figure}
\centering
\includegraphics{SOCMapping_files/figure-latex/unnamed-chunk-91-1.pdf}
\caption{\label{fig:unnamed-chunk-91}Spatial bubble of the prediction errors
for svm}
\includegraphics[width=0.6\linewidth]{SOCMapping_files/figure-latex/unnamed-chunk-91-1} \caption{Spatial bubble of the prediction errors for svm}\label{fig:unnamed-chunk-91}
\end{figure}

\hypertarget{dataSplit}{%
Expand All @@ -6364,7 +6359,7 @@ \subsection{Data-Splitting}\label{dataSplit}}
\NormalTok{train <-}\StringTok{ }\NormalTok{dat[ train.ind,]}
\NormalTok{test <-}\StringTok{ }\NormalTok{dat[}\OperatorTok{-}\NormalTok{train.ind,]}

\KeywordTok{plot}\NormalTok{(}\KeywordTok{density}\NormalTok{ (}\KeywordTok{log}\NormalTok{(train}\OperatorTok{$}\NormalTok{OCSKGM)), }\DataTypeTok{col=}\StringTok{'red'}\NormalTok{)}
\KeywordTok{plot}\NormalTok{(}\KeywordTok{density}\NormalTok{ (}\KeywordTok{log}\NormalTok{(train}\OperatorTok{$}\NormalTok{OCSKGM)), }\DataTypeTok{col=}\StringTok{'red'}\NormalTok{, }\DataTypeTok{main=}\StringTok{""}\NormalTok{)}
\KeywordTok{lines}\NormalTok{(}\KeywordTok{density}\NormalTok{(}\KeywordTok{log}\NormalTok{(test}\OperatorTok{$}\NormalTok{OCSKGM)), }\DataTypeTok{col=}\StringTok{'blue'}\NormalTok{)}
\KeywordTok{legend}\NormalTok{(}\StringTok{'topright'}\NormalTok{, }\DataTypeTok{legend=}\KeywordTok{c}\NormalTok{(}\StringTok{"train"}\NormalTok{, }\StringTok{"test"}\NormalTok{),}
\DataTypeTok{col=}\KeywordTok{c}\NormalTok{(}\StringTok{"red"}\NormalTok{, }\StringTok{"blue"}\NormalTok{), }\DataTypeTok{lty=}\DecValTok{1}\NormalTok{, }\DataTypeTok{cex=}\FloatTok{1.5}\NormalTok{)}
Expand Down Expand Up @@ -6450,7 +6445,7 @@ \section{Technical steps - Model correlations and spatial
\end{Highlighting}
\end{Shaded}

\includegraphics{SOCMapping_files/figure-latex/unnamed-chunk-95-1.pdf}
\includegraphics[width=0.7\linewidth]{SOCMapping_files/figure-latex/unnamed-chunk-95-1}
Here we found that the higher correlation between predicted values was
between RK and SVM (0.86). We also found that the statistical
distribution of predicted values is quite similar between the three
Expand Down Expand Up @@ -7004,7 +6999,12 @@ \subsection{Uncertainty Characterised by Probability
while it is positive in the right panel.

\begin{figure}
\includegraphics[width=0.8\linewidth]{images/pairedsoilpropierties} \caption{Scatter plots of 500 paired soil property values drawn from a two-dimensional normal distribution}\label{fig:pairedsoils}

{\centering \includegraphics[width=0.8\linewidth]{images/pairedsoilpropierties}

}

\caption{Scatter plots of 500 paired soil property values drawn from a two-dimensional normal distribution}\label{fig:pairedsoils}
\end{figure}

\hypertarget{propagation-of-model-uncertainty}{%
Expand Down
Binary file modified docs/SOCMapping_files/figure-html4/unnamed-chunk-93-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/chvalidation.html
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ <h3><span class="header-section-number">7.4.1</span> Additional Probability Samp
\end{equation}\]</span>
<p>We should warn here that the calculation of the <span class="math inline">\(CI\)</span> is based on the assumption that the estimated map quality measure means have a normal distribution (the central limit theorem). For the squared errors this assumption can be unrealistic, especially for small sample sizes.</p>
<p><strong>Estimation of qualitative map quality measures:</strong> For validation of qualitative soil maps, a sample error matrix is constructed from the validation data (Figure <a href="chvalidation.html#fig:errormatrix">7.2</a>). <span class="math inline">\(n\)</span> is the total number of validation locations in the sample. Element <span class="math inline">\(n_{ij}\)</span> of the matrix corresponds to the number of validation locations that have been predicted as class <span class="math inline">\(i\)</span>, <span class="math inline">\(i = 1, 2, \dots U\)</span> and belong to class <span class="math inline">\(j\)</span>, <span class="math inline">\(j = 1, 2, \dots U\)</span> <span class="citation">(Lark <a href="#ref-lark1995components">1995</a>)</span>. The matrix summarizes correct predictions and incorrect predictions within the validation data.</p>
<div class="figure"><span id="fig:errormatrix"></span>
<div class="figure" style="text-align: center"><span id="fig:errormatrix"></span>
<img src="images/Validation_error_matrix.png" alt="Sample error matrix" width="80%" />
<p class="caption">
Figure 7.2: Sample error matrix
Expand Down Expand Up @@ -820,7 +820,7 @@ <h3><span class="header-section-number">7.5.3</span> Graphical Map Quality Measu
<a class="sourceLine" id="cb159-2" data-line-number="2"><span class="kw">bubble</span>(dat[<span class="op">!</span><span class="kw">is.na</span>(dat<span class="op">$</span>PE_RK),], <span class="st">&quot;PE_RK&quot;</span>, <span class="dt">pch =</span> <span class="dv">21</span>, </a>
<a class="sourceLine" id="cb159-3" data-line-number="3"> <span class="dt">col=</span><span class="kw">c</span>(<span class="st">&#39;red&#39;</span>, <span class="st">&#39;green&#39;</span>))</a></code></pre></div>
<div class="figure"><span id="fig:unnamed-chunk-89"></span>
<img src="SOCMapping_files/figure-html4/unnamed-chunk-89-1.png" alt="Spatial bubble of the prediction errors for RK" width="672" />
<img src="SOCMapping_files/figure-html4/unnamed-chunk-89-1.png" alt="Spatial bubble of the prediction errors for RK" width="60%" />
<p class="caption">
Figure 7.5: Spatial bubble of the prediction errors for RK
</p>
Expand All @@ -829,7 +829,7 @@ <h3><span class="header-section-number">7.5.3</span> Graphical Map Quality Measu
<a class="sourceLine" id="cb160-2" data-line-number="2"><span class="kw">bubble</span>(dat[<span class="op">!</span><span class="kw">is.na</span>(dat<span class="op">$</span>PE_rf),], <span class="st">&quot;PE_rf&quot;</span>, <span class="dt">pch =</span> <span class="dv">21</span>, </a>
<a class="sourceLine" id="cb160-3" data-line-number="3"> <span class="dt">col=</span><span class="kw">c</span>(<span class="st">&#39;red&#39;</span>, <span class="st">&#39;green&#39;</span>))</a></code></pre></div>
<div class="figure"><span id="fig:unnamed-chunk-90"></span>
<img src="SOCMapping_files/figure-html4/unnamed-chunk-90-1.png" alt="Spatial bubble of the prediction errors for rf" width="672" />
<img src="SOCMapping_files/figure-html4/unnamed-chunk-90-1.png" alt="Spatial bubble of the prediction errors for rf" width="60%" />
<p class="caption">
Figure 7.6: Spatial bubble of the prediction errors for rf
</p>
Expand All @@ -838,7 +838,7 @@ <h3><span class="header-section-number">7.5.3</span> Graphical Map Quality Measu
<a class="sourceLine" id="cb161-2" data-line-number="2"><span class="kw">bubble</span>(dat[<span class="op">!</span><span class="kw">is.na</span>(dat<span class="op">$</span>PE_svm),], <span class="st">&quot;PE_svm&quot;</span>, <span class="dt">pch =</span> <span class="dv">21</span>, </a>
<a class="sourceLine" id="cb161-3" data-line-number="3"> <span class="dt">col=</span><span class="kw">c</span>(<span class="st">&#39;red&#39;</span>, <span class="st">&#39;green&#39;</span>))</a></code></pre></div>
<div class="figure"><span id="fig:unnamed-chunk-91"></span>
<img src="SOCMapping_files/figure-html4/unnamed-chunk-91-1.png" alt="Spatial bubble of the prediction errors for svm" width="672" />
<img src="SOCMapping_files/figure-html4/unnamed-chunk-91-1.png" alt="Spatial bubble of the prediction errors for svm" width="60%" />
<p class="caption">
Figure 7.7: Spatial bubble of the prediction errors for svm
</p>
Expand All @@ -855,7 +855,7 @@ <h3><span class="header-section-number">7.5.4</span> Data-Splitting</h3>
<a class="sourceLine" id="cb162-6" data-line-number="6">train &lt;-<span class="st"> </span>dat[ train.ind,]</a>
<a class="sourceLine" id="cb162-7" data-line-number="7">test &lt;-<span class="st"> </span>dat[<span class="op">-</span>train.ind,]</a>
<a class="sourceLine" id="cb162-8" data-line-number="8"></a>
<a class="sourceLine" id="cb162-9" data-line-number="9"><span class="kw">plot</span>(<span class="kw">density</span> (<span class="kw">log</span>(train<span class="op">$</span>OCSKGM)), <span class="dt">col=</span><span class="st">&#39;red&#39;</span>)</a>
<a class="sourceLine" id="cb162-9" data-line-number="9"><span class="kw">plot</span>(<span class="kw">density</span> (<span class="kw">log</span>(train<span class="op">$</span>OCSKGM)), <span class="dt">col=</span><span class="st">&#39;red&#39;</span>, <span class="dt">main=</span><span class="st">&quot;&quot;</span>)</a>
<a class="sourceLine" id="cb162-10" data-line-number="10"><span class="kw">lines</span>(<span class="kw">density</span>(<span class="kw">log</span>(test<span class="op">$</span>OCSKGM)), <span class="dt">col=</span><span class="st">&#39;blue&#39;</span>)</a>
<a class="sourceLine" id="cb162-11" data-line-number="11"><span class="kw">legend</span>(<span class="st">&#39;topright&#39;</span>, <span class="dt">legend=</span><span class="kw">c</span>(<span class="st">&quot;train&quot;</span>, <span class="st">&quot;test&quot;</span>),</a>
<a class="sourceLine" id="cb162-12" data-line-number="12"> <span class="dt">col=</span><span class="kw">c</span>(<span class="st">&quot;red&quot;</span>, <span class="st">&quot;blue&quot;</span>), <span class="dt">lty=</span><span class="dv">1</span>, <span class="dt">cex=</span><span class="fl">1.5</span>)</a></code></pre></div>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ <h1>Copyright and disclaimer</h1>
<p>FAO, 2018</p>
<p>FAO encourages the use, reproduction and dissemination of material in this information product. Except where otherwise indicated, material may be copied, downloaded and printed for private study, research and teaching purposes, or for use in non-commercial products or services, provided that appropriate acknowledgement of FAO as the source and copyright holder is given and that FAO’s endorsement of users’ views, products or services is not implied in any way.</p>
<p>All requests for translation and adaptation rights, and for resale and other commercial use rights should be made via www.fao.org/contact-us/licence-request or addressed to <a href="mailto:copyright@fao.org">copyright@fao.org</a>.</p>
<p>FAO information products are available on the FAO website (www.fao.org/publications) and can be purchased through <a href="mailto:publications-sales@fao.org">publications-sales@fao.org</a>.</p>
<p>FAO information products are available on the <a href="www.fao.org/publications">FAO website</a> and can be purchased through <a href="mailto:publications-sales@fao.org">publications-sales@fao.org</a>.</p>
</div>
</section>

Expand Down
Loading

0 comments on commit e2987bc

Please sign in to comment.