Skip to content
Snippets Groups Projects
01-introduction.html 47.8 KiB
Newer Older
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<!DOCTYPE html>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<head>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<meta charset="utf-8" />
<meta name="generator" content="quarto-1.1.189" />
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed

<title>Mapping and spatial analyses in R for One Health studies – 1  Introduction</title>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
ul.task-list li input[type="checkbox"] {
  width: 0.8em;
  margin: 0 0.8em 0.2em -1.6em;
  vertical-align: middle;
}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
    color: #aaaaaa;
  }
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
div.csl-bib-body { }
div.csl-entry {
  clear: both;
}
.hanging div.csl-entry {
  margin-left:2em;
  text-indent:-2em;
}
div.csl-left-margin {
  min-width:2em;
  float:left;
}
div.csl-right-inline {
  margin-left:2em;
  padding-left:1em;
}
div.csl-indent {
  margin-left: 2em;
}
</style>

lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<!-- htmldependencies:E3FAD763 -->
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<script id="quarto-search-options" type="application/json">{
  "location": "sidebar",
  "copy-button": false,
  "collapse-after": 3,
  "panel-placement": "start",
  "type": "textbox",
  "limit": 20,
  "language": {
    "search-no-results-text": "No results",
    "search-matching-documents-text": "matching documents",
    "search-copy-link-title": "Copy link to search",
    "search-hide-matches-text": "Hide additional matches",
    "search-more-match-text": "more match in this document",
    "search-more-matches-text": "more matches in this document",
    "search-clear-button-title": "Clear",
    "search-detached-cancel-button-title": "Cancel",
    "search-submit-button-title": "Submit"
  }
}</script>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<style>html{ scroll-behavior: smooth; }</style>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<link rel="stylesheet" href="styles.css" />
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</head>

lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<body>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed

<div id="quarto-search-results"></div>
  <header id="quarto-header" class="headroom fixed-top">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <nav class="quarto-secondary-nav" 
        data-bs-toggle="collapse" data-bs-target="#quarto-sidebar" 
        aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation"
        onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"
  >
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
    <div class="container-fluid d-flex justify-content-between">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
      <h1 class="quarto-secondary-nav-title"></h1>
      <button type="button" 
        class="quarto-btn-toggle btn" aria-label="Show secondary navigation">
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
        <i class="bi bi-chevron-right"></i>
      </button>
    </div>
  </nav>
</header>
<!-- content -->
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
<!-- sidebar -->
  <nav id="quarto-sidebar" class="sidebar collapse sidebar-navigation floating overflow-auto">
    <div class="pt-lg-2 mt-2 text-left sidebar-header">
    <div class="sidebar-title mb-0 py-0">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
      <a href="/">
      Mapping and spatial analyses in R for One Health studies
      </a> 
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
        <div class="sidebar-tools-main">
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
    <a href="https://forge.ird.fr/espace-dev/personnels/longour/geohealth/documentation/rspatial-for-onehealth" title="Source Code" class="sidebar-tool px-1"><i class="bi bi-git"></i></a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
    </div>
      </div>
      <div class="mt-2 flex-shrink-0 align-items-center">
        <div class="sidebar-search">
        <div id="quarto-search" class="" title="Search"></div>
        </div>
      </div>
    <div class="sidebar-menu-container"> 
    <ul class="list-unstyled mt-1">
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <a href="/index.html" class="sidebar-item-text sidebar-link">Preface</a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <a href="/01-introduction.html" class="sidebar-item-text sidebar-link active"><span class='chapter-number'>1</span>  <span class='chapter-title'>Introduction</span></a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <a href="/02-data_acquisition.html" class="sidebar-item-text sidebar-link"><span class='chapter-number'>2</span>  <span class='chapter-title'>Data Acquisition</span></a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <a href="/03-vector_data.html" class="sidebar-item-text sidebar-link"><span class='chapter-number'>3</span>  <span class='chapter-title'>Using vector data</span></a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <a href="/04-raster_data.html" class="sidebar-item-text sidebar-link"><span class='chapter-number'>4</span>  <span class='chapter-title'>Using raster data</span></a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <a href="/05-mapping_with_r.html" class="sidebar-item-text sidebar-link"><span class='chapter-number'>5</span>  <span class='chapter-title'>Mapping With R</span></a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <a href="/07-basic_statistics.html" class="sidebar-item-text sidebar-link"><span class='chapter-number'>6</span>  <span class='chapter-title'>Basic statistics for spatial analysis</span></a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
  <a href="/references.html" class="sidebar-item-text sidebar-link">References</a>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
</li>
    </ul>
    </div>
</nav>
<!-- margin-sidebar -->
    <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
        <div id="quarto-toc-target"></div>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
    </div>
<!-- main -->
<main class="content" id="quarto-document-content">

<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h1 class="title"><span id="introductionx" class="quarto-section-identifier"><span class="chapter-number">1</span>  <span class="chapter-title">Introduction</span></span></h1>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>



<div class="quarto-title-meta">

    
    
  </div>
  

</header>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<nav id="TOC" role="doc-toc">
    <h2 id="toc-title">Table of contents</h2>
   
  <ul>
  <li><a href="#use-of-r" id="toc-use-of-r"><span class="toc-section-number">1.1</span> <span class="header-section-number">1.1</span> Use of R</a>
  <ul>
  <li><a href="#installation" id="toc-installation"><span class="toc-section-number">1.1.1</span> <span class="header-section-number">1.1.1</span> Installation</a>
  <ul>
  <li><a href="#r" id="toc-r"><span class="toc-section-number">1.1.1.1</span> <span class="header-section-number">1.1.1.1</span> R</a></li>
  <li><a href="#rstudio" id="toc-rstudio"><span class="toc-section-number">1.1.1.2</span> <span class="header-section-number">1.1.1.2</span> RStudio</a></li>
  </ul></li>
  <li><a href="#help" id="toc-help"><span class="toc-section-number">1.1.2</span> <span class="header-section-number">1.1.2</span> Help</a></li>
  <li><a href="#functions" id="toc-functions"><span class="toc-section-number">1.1.3</span> <span class="header-section-number">1.1.3</span> Functions</a></li>
  </ul></li>
  <li><a href="#spatial-in-r-history-and-evolutions" id="toc-spatial-in-r-history-and-evolutions"><span class="toc-section-number">1.2</span> <span class="header-section-number">1.2</span> Spatial in R : History and evolutions</a></li>
  <li><a href="#the-package-sf" id="toc-the-package-sf"><span class="toc-section-number">1.3</span> <span class="header-section-number">1.3</span> The package <code>sf</code></a>
  <ul>
  <li><a href="#format-of-spatial-objects-sf" id="toc-format-of-spatial-objects-sf"><span class="toc-section-number">1.3.1</span> <span class="header-section-number">1.3.1</span> Format of spatial objects <code>sf</code></a></li>
  </ul></li>
  <li><a href="#package-mapsf" id="toc-package-mapsf"><span class="toc-section-number">1.4</span> <span class="header-section-number">1.4</span> Package <code>mapsf</code></a></li>
  <li><a href="#the-package-terra" id="toc-the-package-terra"><span class="toc-section-number">1.5</span> <span class="header-section-number">1.5</span> The package <code>terra</code></a></li>
  </ul>
</nav>
<section id="use-of-r" class="level2" data-number="1.1">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h2 data-number="1.1"><span class="header-section-number">1.1</span> Use of R</h2>
<div class="callout-importan callout callout-style-default no-icon callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class='callout-icon no-icon'></i>
</div>
<div class="callout-caption-container flex-fill">
REMINDER : R TIPS
</div>
</div>
<div class="callout-body-container callout-body">
<ol type="1">
<li><p>Comment your code ! (<code># important informations on the code</code>)</p></li>
<li><p>Check your R objects ! (<code>plot()</code>, <code>print()</code>, <code>View()</code> , …)</p></li>
<li><p>Listen to R outputs ! (Errors AND Warnings)</p></li>
<li><p>Get help ! (<code>?name_of_function</code>, internet, others users)</p></li>
<li><p>Keep calm and take a break !</p></li>
</ol>
</div>
</div>
<section id="installation" class="level3" data-number="1.1.1">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h3 data-number="1.1.1"><span class="header-section-number">1.1.1</span> Installation</h3>
<div class="callout-note callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<i class='callout-icon'></i>
</div>
<div class="callout-caption-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>The installation part is based on “<a href="https://intro2r.com/">An Introduction to R</a>” book writed by <em>Alex Douglas, Deon Roos, Francesca Mancini, Ana Couto &amp; David Lusseau</em></p>
</div>
</div>
<section id="r" class="level4" data-number="1.1.1.1">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h4 data-number="1.1.1.1"><span class="header-section-number">1.1.1.1</span> R</h4>
<section id="windows-users" class="level5" data-number="1.1.1.1.1">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h5 data-number="1.1.1.1.1"><span class="header-section-number">1.1.1.1.1</span> Windows users</h5>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<p>For Windows users select the ‘<a href="(https://cran.r-project.org/bin/windows/)">Download R for Windows</a>’ link and then click on the ‘base’ link and finally the download link ‘Download R 4.2.1 for Windows’. This will begin the download of the ‘.exe’ installation file. When the download has completed double click on the R executable file and follow the on-screen instructions. Full installation instructions can be found at the <a href="https://cran.r-project.org/bin/windows/">CRAN website</a>.</p>
</section>
<section id="mac-users" class="level5" data-number="1.1.1.1.2">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h5 data-number="1.1.1.1.2"><span class="header-section-number">1.1.1.1.2</span> Mac users</h5>
<p>For Mac users select the ‘<a href="https://cran.r-project.org/bin/macosx/">Download R for (Mac) OS X</a>’ link. The binary can be downloaded by selecting the ‘R-4.2.1.pkg’. Once downloaded, double click on the file icon and follow the on-screen instructions to guide you through the necessary steps. See the ‘<a href="https://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html">R for Mac OS X FAQ</a>’ for further information on installation.</p>
</section>
<section id="linux-users" class="level5" data-number="1.1.1.1.3">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h5 data-number="1.1.1.1.3"><span class="header-section-number">1.1.1.1.3</span> Linux users</h5>
<p>For Linux users, the installation method will depend on which flavour of Linux you are using. There are reasonably comprehensive instruction <a href="https://cran.r-project.org/bin/linux/">here</a> for Debian, Redhat, Suse and Ubuntu. In most cases you can just use your OS package manager to install R from the official repository. On Ubuntu fire up a shell (Terminal) and use (you will need root permission to do this):</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb1"><pre class="sourceCode bash cell-code"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> apt update</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> apt install r-base r-base-dev</span></code></pre></div>
</div>
<p>which will install base R and also the development version of base R (you only need this if you want to compile R packages from source but it doesn’t hurt to have it).</p>
<p>If you receive an error after running the code above you may need to add a ‘source.list’ entry to your etc/apt/sources.list file. To do this open the terminal and enter this:</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb2"><pre class="sourceCode bash cell-code"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> apt install <span class="at">-y</span> <span class="at">--no-install-recommends</span> software-properties-common dirmngr</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Add keys</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="fu">wget</span> <span class="at">-qO-</span> https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc <span class="kw">|</span> <span class="fu">sudo</span> tee <span class="at">-a</span> /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a></span>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> add-apt-repository <span class="st">&quot;deb https://cloud.r-project.org/bin/linux/ubuntu </span><span class="va">$(</span><span class="ex">lsb_release</span> <span class="at">-cs</span><span class="va">)</span><span class="st">-cran40/&quot;</span></span></code></pre></div>
</div>
<p>Once you have done this then re-run the apt commands above and you should be good to go.</p>
<p>Install the following packages to allow for future spatial data analysis:</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb3"><pre class="sourceCode bash cell-code"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> apt install <span class="at">-y</span> libgdal-dev libproj-dev libgeos-dev libudunits2-dev libv8-dev libnode-dev libcairo2-dev libnetcdf-dev</span></code></pre></div>
</div>
</section>
</section>
<section id="rstudio" class="level4" data-number="1.1.1.2">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h4 data-number="1.1.1.2"><span class="header-section-number">1.1.1.2</span> RStudio</h4>
<p>Whilst its eminently possible to just use the base installation of R (many people do), we will be using a popular Integrated Development Environment (IDE) called RStudio. RStudio can be thought of as an add-on to R which provides a more user-friendly interface, incorporating the R Console, a script editor and other useful functionality (like R markdown and Git Hub integration). You can find more information about RStudio <a href="https://rstudio.com/">here</a>.</p>
<p>RStudio is freely available for Windows, Mac and Linux operating systems and can be downloaded from the <a href="https://rstudio.com/products/rstudio/download">RStudio site</a>. You should select the ‘RStudio Desktop’ version. Note: you must install R before you install RStudio.</p>
<section id="windows-and-mac-users" class="level5" data-number="1.1.1.2.1">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h5 data-number="1.1.1.2.1"><span class="header-section-number">1.1.1.2.1</span> Windows and Mac users</h5>
<p>For Windows and Mac users you should be presented with the appropriate link for downloading. Click on this link and once downloaded run the installer and follow the instructions. If you don’t see the link then scroll down to the ‘All Installers’ section and choose the link manually.</p>
</section>
<section id="linux-users-1" class="level5" data-number="1.1.1.2.2">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h5 data-number="1.1.1.2.2"><span class="header-section-number">1.1.1.2.2</span> Linux users</h5>
<p>For Linux users scroll down to the ‘All Installers’ section and choose the appropriate link to download the binary for your Linux operating system. RStudio for Ubuntu (and Debian) is available as a <code>*.deb</code> package.</p>
<p>To install the <code>*.deb</code> file navigate to where you downloaded the file and then enter the following command with root permission</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb4"><pre class="sourceCode bash cell-code"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> apt install ./rstudio-2022.07.2-576-amd64.deb</span></code></pre></div>
</div>
<p>You can then start RStudio from the Console by simply typing</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb5"><pre class="sourceCode bash cell-code"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">rstudio</span></span></code></pre></div>
</div>
<p>or you can create a shortcut on you Desktop for easy startup.</p>
</section>
</section>
</section>
<section id="help" class="level3" data-number="1.1.2">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h3 data-number="1.1.2"><span class="header-section-number">1.1.2</span> Help</h3>
<p>The R help is very useful for the use of functions.</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb6"><pre class="sourceCode r cell-code"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>?plot <span class="co">#displays the help page for the plot function</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">help</span>(<span class="st">&quot;*&quot;</span>) <span class="co">#for unconventional characters</span></span></code></pre></div>
</div>
<p>Calling the help opens a page (the exact behavior depends on the operating system) with information and usage examples about the documented function(s) or operators.</p>
</section>
<section id="functions" class="level3" data-number="1.1.3">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h3 data-number="1.1.3"><span class="header-section-number">1.1.3</span> Functions</h3>
<p>The basic syntax is:</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb7"><pre class="sourceCode r cell-code"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>afunction <span class="ot">&lt;-</span> <span class="cf">function</span>(arg1, arg2){</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>  arg1 <span class="sc">+</span> arg2</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a>}</span>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="fu">afunction</span>(<span class="dv">10</span>, <span class="dv">5</span>)</span></code></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 15</code></pre>
</div>
</div>
</section>
</section>
<section id="spatial-in-r-history-and-evolutions" class="level2" data-number="1.2">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h2 data-number="1.2"><span class="header-section-number">1.2</span> Spatial in R : History and evolutions</h2>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<p>Historically, 4 packages make it possible to import, manipulate and transform spatial data:</p>
<ul>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<li>The package <code>rgdal</code> <span class="citation" data-cites="rgdal">(<a href="#ref-rgdal" role="doc-biblioref">Bivand, Keitt, and Rowlingson 2022</a>)</span> which is an interface between R and the <a href="http://www.gdal.org/">GDAL</a> <span class="citation" data-cites="GDAL">(<a href="#ref-GDAL" role="doc-biblioref">GDAL/OGR contributors, n.d.</a>)</span> and <a href="https://proj.org/">PROJ</a> <span class="citation" data-cites="PROJ">(<a href="#ref-PROJ" role="doc-biblioref">PROJ contributors 2021</a>)</span> libraries allow you to import and export spatial data (shapefiles for example) and also to manage cartographic projections<br />
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</li>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<li>The package <code>sp</code> <span class="citation" data-cites="sp">(<a href="#ref-sp" role="doc-biblioref">E. J. Pebesma and Bivand 2005</a>)</span> provides class and methods for vector spatial data in R. It allows displaying background maps, inspectiong an attribute table etc.<br />
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</li>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<li>The package <code>rgeos</code> <span class="citation" data-cites="rgeos">(<a href="#ref-rgeos" role="doc-biblioref">Bivand and Rundel 2021</a>)</span> gives access to the <a href="http://trac.osgeo.org/geos/">GEOS</a> spatial operations library and therefore makes classic GIS operations available: calculation of surfaces or perimeters, calculation of distances, spatial aggregations, buffer zones, intersections, etc.<br />
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</li>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<li>The package <code>raster</code> <span class="citation" data-cites="raster">(<a href="#ref-raster" role="doc-biblioref">Hijmans 2022a</a>)</span> is dedicated to the import, manipulation and modeling of raster data.</li>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</ul>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<p>Today, the main developments concerning vector data have moved away from the old 3 (<code>sp</code>, <code>rgdal</code>, <code>rgeos</code>) to rely mainly on the package <code>sf</code> (<span class="citation" data-cites="sf">(<a href="#ref-sf" role="doc-biblioref">E. Pebesma 2018a</a>)</span>, <span class="citation" data-cites="pebesma2018">(<a href="#ref-pebesma2018" role="doc-biblioref">E. Pebesma 2018b</a>)</span>). In this manual we will rely exclusively on this package to manipulate vector data.</p>
<p>The packages <code>stars</code> <span class="citation" data-cites="stars">(<a href="#ref-stars" role="doc-biblioref">E. Pebesma 2021</a>)</span> and <code>terra</code> <span class="citation" data-cites="terra">(<a href="#ref-terra" role="doc-biblioref">Hijmans 2022b</a>)</span> come to replace the package <code>raster</code> for processing raster data. We have chosen to use the package here <code>terra</code> for its proximity to the <code>raster</code>.</p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</section>
<section id="the-package-sf" class="level2" data-number="1.3">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h2 data-number="1.3"><span class="header-section-number">1.3</span> The package <code>sf</code></h2>
<p><img src="img/sf.gif" align="right" width="150"/> The package <code>sf</code> was released in late 2016 by Edzer Pebesma (also author of <code>sp</code>). Its goal is to combine the feature of <code>sp</code>, <code>rgeos</code> and <code>rgdal</code> in a single, more ergonomic package. This package offers simple objects (following the <a href="https://en.wikipedia.org/wiki/Simple_Features"><em>simple feature</em></a> standard) which are easier to manipulate. Particular attention has been paid to the compatibility of the package with the <em>pipe</em> syntax and the operators of the <code>tidyverse</code>.</p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<p><code>sf</code> directly uses the GDAL, GEOS and PROJ libraries.</p>
<div class="quarto-figure quarto-figure-center">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<figure>
<p><img src="img/sf_deps.png" class="img-fluid" width="600" /></p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</figure>
</div>
<p><a href="https://r-spatial.org/r/2020/03/17/wkt.html">From r-spatial.org</a></p>
<div class="callout-note callout callout-style-simple no-icon">
<div class="callout-body d-flex">
<div class="callout-icon-container">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<i class='callout-icon no-icon'></i>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
<div class="callout-body-container">
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<p>Website of package <code>sf</code> : <a href="https://r-spatial.github.io/sf/">Simple Features for R</a></p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
</div>
</div>
<p>Many of the spatial data available on the internet are in shapefile format, which can be opened in the following way</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb9"><pre class="sourceCode r cell-code"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sf)</span></code></pre></div>
<div class="cell-output cell-output-stderr">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<pre><code>Linking to GEOS 3.9.3, GDAL 3.5.2, PROJ 8.2.1; sf_use_s2() is TRUE</code></pre>
</div>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb11"><pre class="sourceCode r cell-code"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>district <span class="ot">&lt;-</span> <span class="fu">st_read</span>(<span class="st">&quot;data_cambodia/district.shp&quot;</span>)</span></code></pre></div>
<div class="cell-output cell-output-stdout">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<pre class="code-out"><code>Reading layer `district&#39; from data source 
  `C:\Users\UNiK\Documents\R_works\IRD\Rspatial\rspatial-for-onehealth\data_cambodia\district.shp&#39; 
  using driver `ESRI Shapefile&#39;
Simple feature collection with 197 features and 10 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 211534.7 ymin: 1149105 xmax: 784612.1 ymax: 1625495
Projected CRS: WGS 84 / UTM zone 48N</code></pre>
</div>
</div>
<div class="callout-important callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<i class='callout-icon'></i>
</div>
<div class="callout-caption-container flex-fill">
Shapefile format limitations
</div>
</div>
<div class="callout-body-container callout-body">
<p>For the multiple limitations of this format (multi-file, limited number of records…) we advise you to prefer another format such as the geopackage <code>*.gpkg</code>. All the good reasons not to use the shapefile are <a href="http://switchfromshapefile.org/">here</a>.</p>
</div>
</div>
<p>A geopackage is a database, to load a layer, you must know its name</p>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb13"><pre class="sourceCode r cell-code"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="fu">st_layers</span>(<span class="st">&quot;data_cambodia/cambodia.gpkg&quot;</span>)</span></code></pre></div>
<div class="cell-output cell-output-stdout">
<pre class="code-out"><code>Driver: GPKG 
Available layers:
  layer_name     geometry_type features fields              crs_name
1    country     Multi Polygon        1     10 WGS 84 / UTM zone 48N
2   district     Multi Polygon      197     10 WGS 84 / UTM zone 48N
3  education     Multi Polygon       25     19 WGS 84 / UTM zone 48N
4   hospital             Point      956     13 WGS 84 / UTM zone 48N
5      cases       Multi Point      972      2 WGS 84 / UTM zone 48N
6       road Multi Line String        6      9 WGS 84 / UTM zone 48N</code></pre>
</div>
</div>
<div class="cell">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div class="sourceCode" id="cb15"><pre class="sourceCode r cell-code"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>road <span class="ot">&lt;-</span> <span class="fu">st_read</span>(<span class="st">&quot;data_cambodia/cambodia.gpkg&quot;</span>, <span class="at">layer =</span> <span class="st">&quot;road&quot;</span>)</span></code></pre></div>
<div class="cell-output cell-output-stdout">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<pre class="code-out"><code>Reading layer `road&#39; from data source 
  `C:\Users\UNiK\Documents\R_works\IRD\Rspatial\rspatial-for-onehealth\data_cambodia\cambodia.gpkg&#39; 
  using driver `GPKG&#39;
Simple feature collection with 6 features and 9 fields
Geometry type: MULTILINESTRING
Dimension:     XY
Bounding box:  xmin: 212377 ymin: 1152214 xmax: 784654.7 ymax: 1625281
Projected CRS: WGS 84 / UTM zone 48N</code></pre>
</div>
</div>
<section id="format-of-spatial-objects-sf" class="level3" data-number="1.3.1">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h3 data-number="1.3.1"><span class="header-section-number">1.3.1</span> Format of spatial objects <code>sf</code></h3>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<div class="quarto-figure quarto-figure-center">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<figure>
<p><img src="img/sf.png" class="img-fluid" width="600" /></p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</figure>
</div>
<p>Objects<code>sf</code> are objects in <code>data.frame</code> which one of the columns contains geometries. This column is the class of sfc (<em>simple feature column</em>) and each individual of the column is a sfg <em>(simple feature geometry)</em>. This format is very practical insofa as the data and the geometries are intrinsically linked in the same object.</p>
<div class="callout-note callout callout-style-simple no-icon">
<div class="callout-body d-flex">
<div class="callout-icon-container">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<i class='callout-icon no-icon'></i>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
<div class="callout-body-container">
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<p>Thumbnail describing the simple feature format: <a href="https://r-spatial.github.io/sf/articles/sf1.html">Simple Features for R</a></p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
</div>
</div>
<div class="callout-tip callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<i class='callout-icon'></i>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
<div class="callout-caption-container flex-fill">
Tip
</div>
</div>
<div class="callout-body-container callout-body">
<p>A benchmark of vector processing libraries is available <a href="https://github.com/kadyb/vector-benchmark">here</a>.</p>
</div>
</div>
</section>
</section>
<section id="package-mapsf" class="level2" data-number="1.4">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h2 data-number="1.4"><span class="header-section-number">1.4</span> Package <code>mapsf</code></h2>
<p>The free R software spatial ecosystem is rich, dynamic and mature and several packages allow to import, process and represent spatial data. The package <a href="https://CRAN.R-project.org/package=maps"><code>mapsf</code></a> <span class="citation" data-cites="mapsf">(<a href="#ref-mapsf" role="doc-biblioref">Giraud 2022</a>)</span> relies on this ecosystem to integrate the creation of quality thematic maps into processing chains with R.</p>
<p>Other packages can be used to make thematic maps. The package <code>ggplot2</code> <span class="citation" data-cites="ggplot2">(<a href="#ref-ggplot2" role="doc-biblioref">Wickham 2016</a>)</span>, in association with the package <code>ggspatial</code> <span class="citation" data-cites="ggspatial">(<a href="#ref-ggspatial" role="doc-biblioref">Dunnington 2021</a>)</span>, allows for example to display spatial objects and to make simple thematic maps. The package <code>tmap</code> <span class="citation" data-cites="tmap">(<a href="#ref-tmap" role="doc-biblioref">Tennekes 2018</a>)</span> is dedicated to the creation of thematic maps, it uses a syntax close to that of <code>ggplot2</code> (sequence of instructions combined with the ‘+’ sign). Documentation and tutorials for using these two packages are readily available on the web.</p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<p>Here, we will mainly use the package <code>mapsf</code> whose functionalities are quite complete and the handling rather simple. In addition, the package is relatively light.</p>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<p><img src="img/logo_mapsf.png" align="right" width="120"/></p>
<p><code>mapsf</code> allows you to create most of the types of map usually used in statistical cartography (choropleth maps, typologies, proportional or graduated symbols, etc.). For each type of map, several parameters are used to customize the cartographic representation. These parameters are the same as those found in the usual GIS or cartography software (for example, the choice of discretizations and color palettes, the modification of the size of the symbols or the customization of the legends). Associated with the data representation functions, other functions are dedicated to cartographic dressing (themes or graphic charters, legends, scales, orientation arrows, title, credits, annotations, etc.), the creation of boxes or the exporting maps.<br />
<code>mapsf</code> is the successor of <a href="http://riatelab.github.io/cartography/docs/"><code>cartography</code></a> <span class="citation" data-cites="cartography">(<a href="#ref-cartography" role="doc-biblioref">Giraud and Lambert 2016</a>)</span>, it offers the same main functionalities while being lighter and more ergonomic.</p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<p>To use this package several sources can be consulted:</p>
<ul>
<li><p>The package documentation accessible <a href="http://riatelab.github.io/mapsf/">on the internet</a> or directly in R (<code>?mapsf</code>),</p></li>
<li><p>A <a href="https://raw.githubusercontent.com/riatelab/mapsf/master/vignettes/web_only/img/mapsf_cheatsheet.pdf"><em>cheat sheet</em></a>,</p></li>
</ul>
<div class="quarto-figure quarto-figure-center">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<figure>
<p><img src="img/mapsf_cheatsheet.png" class="img-fluid" width="600" /></p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</figure>
</div>
<ul>
<li><p>The <a href="https://riatelab.github.io/mapsf/articles/">vignettes</a> associated with the package show sample scripts,</p></li>
<li><p>The <a href="https://rgeomatic.hypotheses.org/">R Geomatics</a> blog which provides resources and examples related to the package and more generally to the R spatial ecosystem.</p></li>
</ul>
</section>
<section id="the-package-terra" class="level2" data-number="1.5">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<h2 data-number="1.5"><span class="header-section-number">1.5</span> The package <code>terra</code></h2>
<p><img src="img/logo_terra.png" align="right" width="150"/> The package <code>terra</code> was release in early 2020 by Robert J. Hijmans (also author of <code>raster</code>). Its objective is to propose methods of treatment and analysis of raster data. This package is very similar to the package <code>raster</code>; but it has more features, it’s easier to use, and it’s faster.</p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<div class="callout-note callout callout-style-simple no-icon">
<div class="callout-body d-flex">
<div class="callout-icon-container">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<i class='callout-icon no-icon'></i>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
<div class="callout-body-container">
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<p>Website of package <code>terra</code> : <a href="https://rspatial.org/terra/">Spatial Data Science with R and “terra”</a></p>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
</div>
</div>
<div class="callout-tip callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<i class='callout-icon'></i>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
</div>
<div class="callout-caption-container flex-fill">
Tip
</div>
</div>
<div class="callout-body-container callout-body">
<p>A benchmark of raster processing libraries is available <a href="https://github.com/kadyb/raster-benchmark">here</a>.</p>
</div>
</div>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<div id="quarto-navigation-envelope" class="hidden">
<p><span class="hidden" data-render-id="quarto-int-sidebar-title">Mapping and spatial analyses in R for One Health studies</span> <span class="hidden" data-render-id="quarto-int-navbar-title">Mapping and spatial analyses in R for One Health studies</span> <span class="hidden" data-render-id="quarto-int-next"><span class="chapter-number">2</span>  <span class="chapter-title">Data Acquisition</span></span> <span class="hidden" data-render-id="quarto-int-prev">Preface</span> <span class="hidden" data-render-id="quarto-int-sidebar:/index.html">Preface</span> <span class="hidden" data-render-id="quarto-int-sidebar:/01-introduction.html"><span class="chapter-number">1</span>  <span class="chapter-title">Introduction</span></span> <span class="hidden" data-render-id="quarto-int-sidebar:/02-data_acquisition.html"><span class="chapter-number">2</span>  <span class="chapter-title">Data Acquisition</span></span> <span class="hidden" data-render-id="quarto-int-sidebar:/03-vector_data.html"><span class="chapter-number">3</span>  <span class="chapter-title">Using vector data</span></span> <span class="hidden" data-render-id="quarto-int-sidebar:/04-raster_data.html"><span class="chapter-number">4</span>  <span class="chapter-title">Using raster data</span></span> <span class="hidden" data-render-id="quarto-int-sidebar:/05-mapping_with_r.html"><span class="chapter-number">5</span>  <span class="chapter-title">Mapping With R</span></span> <span class="hidden" data-render-id="quarto-int-sidebar:/07-basic_statistics.html"><span class="chapter-number">6</span>  <span class="chapter-title">Basic statistics for spatial analysis</span></span> <span class="hidden" data-render-id="quarto-int-sidebar:/references.html">References</span> <span class="hidden" data-render-id="footer-left">UMR 228 ESPACE-DEV</span> <span class="hidden" data-render-id="footer-right"><img src="img/ird_footer.png" height="50" /></span></p>
</div>
<div id="quarto-meta-markdown" class="hidden">
<p><span class="hidden" data-render-id="quarto-metatitle">Mapping and spatial analyses in R for One Health studies - <span id="introductionx" class="quarto-section-identifier"><span class="chapter-number">1</span>  <span class="chapter-title">Introduction</span></span></span> <span class="hidden" data-render-id="quarto-twittercardtitle">Mapping and spatial analyses in R for One Health studies - <span id="introductionx" class="quarto-section-identifier"><span class="chapter-number">1</span>  <span class="chapter-title">Introduction</span></span></span> <span class="hidden" data-render-id="quarto-ogcardtitle">Mapping and spatial analyses in R for One Health studies - <span id="introductionx" class="quarto-section-identifier"><span class="chapter-number">1</span>  <span class="chapter-title">Introduction</span></span></span> <span class="hidden" data-render-id="quarto-metasitename">Mapping and spatial analyses in R for One Health studies</span></p>
</div>
<div id="refs" class="references csl-bib-body hanging-indent" role="doc-bibliography">
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
<div id="ref-rgdal" class="csl-entry" role="doc-biblioentry">
Bivand, Roger, Tim Keitt, and Barry Rowlingson. 2022. <span>“Rgdal: Bindings for the ’Geospatial’ Data Abstraction Library.”</span> <a href="https://CRAN.R-project.org/package=rgdal">https://CRAN.R-project.org/package=rgdal</a>.
</div>
<div id="ref-rgeos" class="csl-entry" role="doc-biblioentry">
Bivand, Roger, and Colin Rundel. 2021. <span>“Rgeos: Interface to Geometry Engine - Open Source (’GEOS’).”</span> <a href="https://CRAN.R-project.org/package=rgeos">https://CRAN.R-project.org/package=rgeos</a>.
</div>
<div id="ref-ggspatial" class="csl-entry" role="doc-biblioentry">
Dunnington, Dewey. 2021. <span>“Ggspatial: Spatial Data Framework for Ggplot2.”</span> <a href="https://CRAN.R-project.org/package=ggspatial">https://CRAN.R-project.org/package=ggspatial</a>.
</div>
<div id="ref-GDAL" class="csl-entry" role="doc-biblioentry">
GDAL/OGR contributors. n.d. <em><span>GDAL/OGR</span> Geospatial Data Abstraction Software Library</em>. Open Source Geospatial Foundation. <a href="https://gdal.org">https://gdal.org</a>.
</div>
<div id="ref-mapsf" class="csl-entry" role="doc-biblioentry">
Giraud, Timothée. 2022. <span>“Mapsf: Thematic Cartography.”</span> <a href="https://CRAN.R-project.org/package=mapsf">https://CRAN.R-project.org/package=mapsf</a>.
</div>
<div id="ref-cartography" class="csl-entry" role="doc-biblioentry">
Giraud, Timothée, and Nicolas Lambert. 2016. <span>“Cartography: Create and Integrate Maps in Your r Workflow”</span> 1. <a href="https://doi.org/10.21105/joss.00054">https://doi.org/10.21105/joss.00054</a>.
</div>
<div id="ref-raster" class="csl-entry" role="doc-biblioentry">
Hijmans, Robert J. 2022a. <span>“Raster: Geographic Data Analysis and Modeling.”</span> <a href="https://CRAN.R-project.org/package=raster">https://CRAN.R-project.org/package=raster</a>.
</div>
<div id="ref-terra" class="csl-entry" role="doc-biblioentry">
———. 2022b. <span>“Terra: Spatial Data Analysis.”</span> <a href="https://CRAN.R-project.org/package=terra">https://CRAN.R-project.org/package=terra</a>.
</div>
<div id="ref-sf" class="csl-entry" role="doc-biblioentry">
Pebesma, Edzer. 2018a. <span><span></span>Simple Features for r: Standardized Support for Spatial Vector Data<span></span></span> 10. <a href="https://doi.org/10.32614/RJ-2018-009">https://doi.org/10.32614/RJ-2018-009</a>.
</div>
<div id="ref-pebesma2018" class="csl-entry" role="doc-biblioentry">
———. 2018b. <span>“Simple Features for R: Standardized Support for Spatial Vector Data.”</span> <em>The R Journal</em> 10 (1): 439. <a href="https://doi.org/10.32614/rj-2018-009">https://doi.org/10.32614/rj-2018-009</a>.
</div>
<div id="ref-stars" class="csl-entry" role="doc-biblioentry">
———. 2021. <span>“Stars: Spatiotemporal Arrays, Raster and Vector Data Cubes.”</span> <a href="https://CRAN.R-project.org/package=stars">https://CRAN.R-project.org/package=stars</a>.
</div>
<div id="ref-sp" class="csl-entry" role="doc-biblioentry">
Pebesma, Edzer J., and Roger S. Bivand. 2005. <span>“Classes and Methods for Spatial Data in <span></span>r<span></span></span> 5. <a href="https://CRAN.R-project.org/doc/Rnews/">https://CRAN.R-project.org/doc/Rnews/</a>.
</div>
<div id="ref-PROJ" class="csl-entry" role="doc-biblioentry">
PROJ contributors. 2021. <em><span>PROJ</span> Coordinate Transformation Software Library</em>. Open Source Geospatial Foundation. <a href="https://proj.org/">https://proj.org/</a>.
</div>
<div id="ref-tmap" class="csl-entry" role="doc-biblioentry">
Tennekes, Martijn. 2018. <span><span></span>Tmap<span></span>: Thematic Maps in <span></span>r<span></span></span> 84. <a href="https://doi.org/10.18637/jss.v084.i06">https://doi.org/10.18637/jss.v084.i06</a>.
</div>
<div id="ref-ggplot2" class="csl-entry" role="doc-biblioentry">
Wickham, Hadley. 2016. <span>“Ggplot2: Elegant Graphics for Data Analysis.”</span> <a href="https://ggplot2.tidyverse.org">https://ggplot2.tidyverse.org</a>.
</div>
</div>
</section>

</main> <!-- /main -->
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
<script id = "quarto-html-after-body" type="application/javascript">
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
window.document.addEventListener("DOMContentLoaded", function (event) {
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  const toggleBodyColorMode = (bsSheetEl) => {
    const mode = bsSheetEl.getAttribute("data-mode");
    const bodyEl = window.document.querySelector("body");
    if (mode === "dark") {
      bodyEl.classList.add("quarto-dark");
      bodyEl.classList.remove("quarto-light");
    } else {
      bodyEl.classList.add("quarto-light");
      bodyEl.classList.remove("quarto-dark");
    }
  }
  const toggleBodyColorPrimary = () => {
    const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
    if (bsSheetEl) {
      toggleBodyColorMode(bsSheetEl);
    }
  }
  toggleBodyColorPrimary();  
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  const icon = "";
  const anchorJS = new window.AnchorJS();
  anchorJS.options = {
    placement: 'right',
    icon: icon
  };
  anchorJS.add('.anchored');
  const clipboard = new window.ClipboardJS('.code-copy-button', {
    target: function(trigger) {
      return trigger.previousElementSibling;
    }
  });
  clipboard.on('success', function(e) {
    // button target
    const button = e.trigger;
    // don't keep focus
    button.blur();
    // flash "checked"
    button.classList.add('code-copy-button-checked');
    var currentTitle = button.getAttribute("title");
    button.setAttribute("title", "Copied!");
    setTimeout(function() {
      button.setAttribute("title", currentTitle);
      button.classList.remove('code-copy-button-checked');
    }, 1000);
    // clear code selection
    e.clearSelection();
  });
  function tippyHover(el, contentFn) {
    const config = {
      allowHTML: true,
      content: contentFn,
      maxWidth: 500,
      delay: 100,
      arrow: false,
      appendTo: function(el) {
          return el.parentElement;
      },
      interactive: true,
      interactiveBorder: 10,
      theme: 'quarto',
      placement: 'bottom-start'
    };
    window.tippy(el, config); 
  }
  const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
  for (var i=0; i<noterefs.length; i++) {
    const ref = noterefs[i];
    tippyHover(ref, function() {
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
      // use id or data attribute instead here
      let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
      try { href = new URL(href).hash; } catch {}
      const id = href.replace(/^#\/?/, "");
      const note = window.document.getElementById(id);
      return note.innerHTML;
    });
  }
  var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
  for (var i=0; i<bibliorefs.length; i++) {
    const ref = bibliorefs[i];
    const cites = ref.parentNode.getAttribute('data-cites').split(' ');
    tippyHover(ref, function() {
      var popup = window.document.createElement('div');
      cites.forEach(function(cite) {
        var citeDiv = window.document.createElement('div');
        citeDiv.classList.add('hanging-indent');
        citeDiv.classList.add('csl-entry');
        var biblioDiv = window.document.getElementById('ref-' + cite);
        if (biblioDiv) {
          citeDiv.innerHTML = biblioDiv.innerHTML;
        }
        popup.appendChild(citeDiv);
      });
      return popup.innerHTML;
    });
  }
    var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
      var filterRegex = new RegExp('/' + window.location.host + '/');
    var isInternal = (href) => {
        return filterRegex.test(href) || localhostRegex.test(href);
    }
    // Inspect non-navigation links and adorn them if external
    var links = window.document.querySelectorAll('a:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external)');
    for (var i=0; i<links.length; i++) {
      const link = links[i];
      if (!isInternal(link.href)) {
          // target, if specified
          link.setAttribute("target", "_blank");
      }
    }
});
</script>
<nav class="page-navigation">
  <div class="nav-page nav-page-previous">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
      <a  href="/index.html" class="pagination-link">
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
        <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text">Preface</span>
      </a>          
  </div>
  <div class="nav-page nav-page-next">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
      <a  href="/02-data_acquisition.html" class="pagination-link">
        <span class="nav-page-text"><span class='chapter-number'>2</span>  <span class='chapter-title'>Data Acquisition</span></span> <i class="bi bi-arrow-right-short"></i>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
      </a>
  </div>
</nav>
</div> <!-- /content -->
<footer class="footer">
  <div class="nav-footer">
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
    <div class="nav-footer-left">
      <div class='footer-contents'>UMR 228 ESPACE-DEV</div>  
    </div>   
    <div class="nav-footer-right">
      <div class='footer-contents'>![](img/ird_footer.png){height="50"}
</div>  
    </div>
lucas.longour_ird.fr's avatar
lucas.longour_ird.fr committed
  </div>
</footer>

lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
</body>
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
</html>