Skip to content
Snippets Groups Projects
01-introduction.html 48.1 KiB
Newer Older
lea.douchet_ird.fr's avatar
lea.douchet_ird.fr committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>

<meta charset="utf-8" />
<meta name="generator" content="quarto-1.1.189" />

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />


<title>Mapping and spatial analyses in R for One Health studies – 1  Introduction</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
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 */
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>

<!-- htmldependencies:E3FAD763 -->
<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>
<style>html{ scroll-behavior: smooth; }</style>


<link rel="stylesheet" href="styles.css" />
</head>

<body>

<div id="quarto-search-results"></div>
  <header id="quarto-header" class="headroom fixed-top">
  <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(); }"
  >
    <div class="container-fluid d-flex justify-content-between">
      <h1 class="quarto-secondary-nav-title"></h1>
      <button type="button" 
        class="quarto-btn-toggle btn" aria-label="Show secondary navigation">
        <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">
      <a href="/">
      Mapping and spatial analyses in R for One Health studies
      </a> 
        <div class="sidebar-tools-main">
    <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>
</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"> 
  <a href="/index.html" class="sidebar-item-text sidebar-link">Preface</a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <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>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <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>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <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>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <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>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <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>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <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>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="/08-exercices.html" class="sidebar-item-text sidebar-link">Exercice</a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="/references.html" class="sidebar-item-text sidebar-link">References</a>
  </div>
</li>
    </ul>
    </div>
</nav>
<!-- margin-sidebar -->
    <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
        <div id="quarto-toc-target"></div>
    </div>
<!-- main -->
<main class="content" id="quarto-document-content">

<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title"><span id="introductionx" class="quarto-section-identifier"><span class="chapter-number">1</span>  <span class="chapter-title">Introduction</span></span></h1>
</div>



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

    
    
  </div>
  

</header>
<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">
<h2 data-number="1.1"><span class="header-section-number">1.1</span> Use of R</h2>
<div class="callout-important callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class='callout-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, other 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">
<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">
<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">
<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">
<h5 data-number="1.1.1.1.1"><span class="header-section-number">1.1.1.1.1</span> Windows users</h5>
<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">
<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">
<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">
<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">
<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>
<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">
<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">
<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">
<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">
<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">
<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">
<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">
<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">
<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">
<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">
<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>
<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">
<h2 data-number="1.2"><span class="header-section-number">1.2</span> Spatial in R : History and evolutions</h2>
<p>Historically, 4 packages make it possible to import, manipulate and transform spatial data:</p>
<ul>
<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 />
</li>
<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 />
</li>
<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 />
</li>
<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>
</ul>
<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>
</section>
<section id="the-package-sf" class="level2" data-number="1.3">
<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>
<p><code>sf</code> directly uses the GDAL, GEOS and PROJ libraries.</p>
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img src="img/sf_deps.png" class="img-fluid" width="600" /></p>
</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">
<i class='callout-icon no-icon'></i>
</div>
<div class="callout-body-container">
<p>Website of package <code>sf</code> : <a href="https://r-spatial.github.io/sf/">Simple Features for R</a></p>
</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">
<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">
<pre><code>Linking to GEOS 3.9.3, GDAL 3.5.2, PROJ 8.2.1; sf_use_s2() is TRUE</code></pre>
</div>
<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">
<pre class="code-out"><code>Reading layer `district&#39; from data source 
  `C:\Users\UNiK\Documents\R_works\IRD\RGeoSpatial_Training\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">
<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">
<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">
<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">
<pre class="code-out"><code>Reading layer `road&#39; from data source 
  `C:\Users\UNiK\Documents\R_works\IRD\RGeoSpatial_Training\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">
<h3 data-number="1.3.1"><span class="header-section-number">1.3.1</span> Format of spatial objects <code>sf</code></h3>
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img src="img/sf.png" class="img-fluid" width="600" /></p>
</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">
<i class='callout-icon no-icon'></i>
</div>
<div class="callout-body-container">
<p>Thumbnail describing the simple feature format: <a href="https://r-spatial.github.io/sf/articles/sf1.html">Simple Features for R</a></p>
</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">
<i class='callout-icon'></i>
</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">
<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>
<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>
<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>
<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">
<figure>
<p><img src="img/mapsf_cheatsheet.png" class="img-fluid" width="600" /></p>
</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">
<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>
<div class="callout-note callout callout-style-simple no-icon">
<div class="callout-body d-flex">
<div class="callout-icon-container">
<i class='callout-icon no-icon'></i>
</div>
<div class="callout-body-container">
<p>Website of package <code>terra</code> : <a href="https://rspatial.org/terra/">Spatial Data Science with R and “terra”</a></p>
</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">
<i class='callout-icon'></i>
</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>
<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:/08-exercices.html">Exercice</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">
<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 -->
<script id = "quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
  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();  
  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() {
      // use id or data attribute instead here
      let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
      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">
      <a  href="/index.html" class="pagination-link">
        <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text">Preface</span>
      </a>          
  </div>
  <div class="nav-page nav-page-next">
      <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>
      </a>
  </div>
</nav>
</div> <!-- /content -->
<footer class="footer">
  <div class="nav-footer">
    <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>
  </div>
</footer>

</body>

</html>