Skip to content
Snippets Groups Projects
Commit 1ccb8aac authored by lea.douchet_ird.fr's avatar lea.douchet_ird.fr
Browse files

shapefile issue

parent a24c90a5
No related branches found
No related tags found
No related merge requests found
Showing
with 2882 additions and 145 deletions
<!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>
\ No newline at end of file
......@@ -30,9 +30,10 @@ In R, it exist many differents implementation solution that lead to the same res
[Download example data](https://e1.pcloud.link/publink/show?code=XZjIQYZvgGOVnUBzVYonPJugrNDLfWSscXk){.btn .btn-primary .btn-sm role="button"}
3. Create a directory called "img" for image outputs
3. Create a directory called "img/" for image outputs
4. Download and unzip shapefile of Cambodian provinces in the 'data/' directory: [Province shapefile](https://data.humdata.org/dataset/wfp-geonode-cambodia-admin-boundaries-level-1-provinces)
A new province have been recently delimited in Cambodia (the 26th one). for this exercice you can use the old shapefile that contains 25 provinces in the data directory.
5. Check your working directory using `getwd()`
......
This diff is collapsed.
......@@ -292,8 +292,8 @@ R REMINDERS
</ol>
<p><a href="https://e1.pcloud.link/publink/show?code=XZjIQYZvgGOVnUBzVYonPJugrNDLfWSscXk" class="btn btn-primary btn-sm" role="button">Download example data</a></p>
<ol start="3" type="1">
<li><p>Create a directory called “img” for image outputs</p></li>
<li><p>Download and unzip shapefile of Cambodian provinces in the ‘data/’ directory: <a href="https://data.humdata.org/dataset/wfp-geonode-cambodia-admin-boundaries-level-1-provinces">Province shapefile</a></p></li>
<li><p>Create a directory called “img/” for image outputs</p></li>
<li><p>Download and unzip shapefile of Cambodian provinces in the ‘data/’ directory: <a href="https://data.humdata.org/dataset/wfp-geonode-cambodia-admin-boundaries-level-1-provinces">Province shapefile</a> A new province have been recently delimited in Cambodia (the 26th one). for this exercice you can use the old shapefile that contains 25 provinces in the data directory.</p></li>
<li><p>Check your working directory using <code>getwd()</code></p></li>
</ol>
</section>
......
......@@ -284,6 +284,6 @@
"href": "08-exercices.html#create-your-working-environment",
"title": "Exercice",
"section": "Create your working environment",
"text": "Create your working environment\n\nCreate a R project called “RGeotraining”\nDownload and unzip the training data into a directory called “data/”.\n\nDownload example data\n\nCreate a directory called “img” for image outputs\nDownload and unzip shapefile of Cambodian provinces in the ‘data/’ directory: Province shapefile\nCheck your working directory using getwd()"
"text": "Create your working environment\n\nCreate a R project called “RGeotraining”\nDownload and unzip the training data into a directory called “data/”.\n\nDownload example data\n\nCreate a directory called “img/” for image outputs\nDownload and unzip shapefile of Cambodian provinces in the ‘data/’ directory: Province shapefile A new province have been recently delimited in Cambodia (the 26th one). for this exercice you can use the old shapefile that contains 25 provinces in the data directory.\nCheck your working directory using getwd()"
}
]
\ No newline at end of file
Copyright (C) 2014 Daniel Montague
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
!function(){function a(a,c){this.title=a.title,this.stateName=a.stateName?a.stateName:"unnamed-state",this.icon=L.DomUtil.create("span",""),L.DomUtil.addClass(this.icon,"button-state state-"+this.stateName.replace(/(^\s*|\s*$)/g,"")),this.icon.innerHTML=b(a.icon),this.onClick=L.Util.bind(a.onClick?a.onClick:function(){},c)}function b(a){var b;return a.match(/[&;=<>"']/)?b=a:(a=a.replace(/(^\s*|\s*$)/g,""),b=L.DomUtil.create("span",""),0===a.indexOf("fa-")?L.DomUtil.addClass(b,"fa "+a):0===a.indexOf("glyphicon-")?L.DomUtil.addClass(b,"glyphicon "+a):L.DomUtil.addClass(b,a),b=b.outerHTML),b}L.Control.EasyBar=L.Control.extend({options:{position:"bottomright",id:null,leafletClasses:!0},initialize:function(a,b){b&&L.Util.setOptions(this,b),this._buildContainer(),this._buttons=[];for(var c=0;c<a.length;c++)a[c]._bar=this,a[c]._container=a[c].button,this._buttons.push(a[c]),this.container.appendChild(a[c].button)},_buildContainer:function(){this._container=this.container=L.DomUtil.create("div",""),this.options.leafletClasses&&L.DomUtil.addClass(this.container,"leaflet-bar easy-button-container leaflet-control"),this.options.id&&(this.container.id=this.options.id)},enable:function(){return L.DomUtil.addClass(this.container,"enabled"),L.DomUtil.removeClass(this.container,"disabled"),this.container.setAttribute("aria-hidden","false"),this},disable:function(){return L.DomUtil.addClass(this.container,"disabled"),L.DomUtil.removeClass(this.container,"enabled"),this.container.setAttribute("aria-hidden","true"),this},onAdd:function(){return this.container},addTo:function(a){this._map=a;for(var b=0;b<this._buttons.length;b++)this._buttons[b]._map=a;var c=this._container=this.onAdd(a),d=this.getPosition(),e=a._controlCorners[d];return L.DomUtil.addClass(c,"leaflet-control"),-1!==d.indexOf("bottom")?e.insertBefore(c,e.firstChild):e.appendChild(c),this}}),L.easyBar=function(){for(var a=[L.Control.EasyBar],b=0;b<arguments.length;b++)a.push(arguments[b]);return new(Function.prototype.bind.apply(L.Control.EasyBar,a))},L.Control.EasyButton=L.Control.extend({options:{position:"bottomright",id:null,type:"replace",states:[],leafletClasses:!0},initialize:function(b,c,d,e){this.options.states=[],null!=e&&(this.options.id=e),this.storage={},"object"==typeof arguments[arguments.length-1]&&L.Util.setOptions(this,arguments[arguments.length-1]),0===this.options.states.length&&"string"==typeof b&&"function"==typeof c&&this.options.states.push({icon:b,onClick:c,title:"string"==typeof d?d:""}),this._states=[];for(var f=0;f<this.options.states.length;f++)this._states.push(new a(this.options.states[f],this));this._buildButton(),this._activateState(this._states[0])},_buildButton:function(){if(this.button=L.DomUtil.create("button",""),this.options.id&&(this.button.id=this.options.id),this.options.leafletClasses&&L.DomUtil.addClass(this.button,"easy-button-button leaflet-bar-part"),L.DomEvent.addListener(this.button,"dblclick",L.DomEvent.stop),L.DomEvent.addListener(this.button,"click",function(a){L.DomEvent.stop(a),this._currentState.onClick(this,this._map?this._map:null),this._map.getContainer().focus()},this),"replace"==this.options.type)this.button.appendChild(this._currentState.icon);else for(var a=0;a<this._states.length;a++)this.button.appendChild(this._states[a].icon)},_currentState:{stateName:"unnamed",icon:function(){return document.createElement("span")}()},_states:null,state:function(a){return"string"==typeof a?this._activateStateNamed(a):"number"==typeof a&&this._activateState(this._states[a]),this},_activateStateNamed:function(a){for(var b=0;b<this._states.length;b++)this._states[b].stateName==a&&this._activateState(this._states[b])},_activateState:function(a){if(a!==this._currentState){"replace"==this.options.type&&(this.button.appendChild(a.icon),this.button.removeChild(this._currentState.icon)),a.title?this.button.title=a.title:this.button.removeAttribute("title");for(var b=0;b<this._states.length;b++)L.DomUtil.removeClass(this._states[b].icon,this._currentState.stateName+"-active"),L.DomUtil.addClass(this._states[b].icon,a.stateName+"-active");L.DomUtil.removeClass(this.button,this._currentState.stateName+"-active"),L.DomUtil.addClass(this.button,a.stateName+"-active"),this._currentState=a}},enable:function(){return L.DomUtil.addClass(this.button,"enabled"),L.DomUtil.removeClass(this.button,"disabled"),this.button.setAttribute("aria-hidden","false"),this},disable:function(){return L.DomUtil.addClass(this.button,"disabled"),L.DomUtil.removeClass(this.button,"enabled"),this.button.setAttribute("aria-hidden","true"),this},removeFrom:function(a){return this._container.parentNode.removeChild(this._container),this._map=null,this},onAdd:function(){var a=L.easyBar([this],{position:this.options.position,leafletClasses:this.options.leafletClasses});return this._container=a.container,this._container}}),L.easyButton=function(){var a=Array.prototype.concat.apply([L.Control.EasyButton],arguments);return new(Function.prototype.bind.apply(L.Control.EasyButton,a))}}();
public/site_libs/HomeButton-0.0.1/glyphicons-21-home.png

1.24 KiB

.leaflet-bar button/*,
.leaflet-bar button:hover*/ {
background-color: rgba(255,255,255, 0.95) /*#fff*/;
border: none;
width: 100%;
height: 20px;
line-height: 15px;
font-size: 85%;
/*display: block;*/
text-align: center;
text-decoration: none;
color: black;
cursor: pointer;
overflow-x: visible;
overflow-y: hidden;
opacity: 0.25;
filter: alpha(opacity = 25);
background-position: 50% 50%;
background-repeat: no-repeat;
display: inline-block;
}
.leaflet-bar button:hover {
background-color: #00ffff; /* #909090 */;
text-decoration: underline;
opacity: 0.9;
filter: alpha(opacity=90);
}
/* uncomment this to get rid of button borders, this also removes border from zoom buttons
.leaflet-touch .leaflet-bar {
border: none;
}
/*.leaflet-bar button:first-of-type {
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.leaflet-bar button:last-of-type {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
border-bottom: none;
}
.leaflet-bar.disabled,
.leaflet-bar button.disabled {
cursor: default;
pointer-events: none;
opacity: .4;
}
.easy-button-button .button-state{
display: block;
width: 100%;
height: 100%;
position: relative;
}
/*.leaflet-touch .leaflet-bar button {
width: 100%;
height: 20px;
line-height: 18px;
overflow-y: hidden;
opacity: .5;
filter: alpha(opacity=50);
white-space: nowrap;
}*/
LeafletWidget.methods.addHomeButton = function (xmin, ymin, xmax, ymax, useext,
group, label, icon, position) {
if (this.easyButton) {
this.easyButton.removeFrom(this);
}
var bx = [];
if (useext) {
bx = [[ymin, xmin], [ymax, xmax]];
} else {
bx = this.layerManager._groupContainers[group].getBounds();
}
var easyButton = new L.easyButton({
position: position,
states: [{
stateName: label, // name the state
icon: icon, // and define its properties
title: label, // like its title
onClick: function(btn, map){
map.fitBounds(bx, {maxZoom: 18});
btn.state(label);
}
}]
});
easyButton.addTo(this);
this.currentEasyButton = easyButton;
};
LeafletWidget.methods.removeHomeButton = function () {
if (this.currentEasyButton) {
this.currentEasyButton.removeFrom(this);
this.currentEasyButton = null;
}
};
(function (factory) {
var L, proj4;
if (typeof define === 'function' && define.amd) {
// AMD
define(['leaflet', 'proj4'], factory);
} else if (typeof module === 'object' && typeof module.exports === "object") {
// Node/CommonJS
L = require('leaflet');
proj4 = require('proj4');
module.exports = factory(L, proj4);
} else {
// Browser globals
if (typeof window.L === 'undefined' || typeof window.proj4 === 'undefined')
throw 'Leaflet and proj4 must be loaded first';
factory(window.L, window.proj4);
}
}(function (L, proj4) {
if (proj4.__esModule && proj4.default) {
// If proj4 was bundled as an ES6 module, unwrap it to get
// to the actual main proj4 object.
// See discussion in https://github.com/kartena/Proj4Leaflet/pull/147
proj4 = proj4.default;
}
L.Proj = {};
L.Proj._isProj4Obj = function(a) {
return (typeof a.inverse !== 'undefined' &&
typeof a.forward !== 'undefined');
};
L.Proj.Projection = L.Class.extend({
initialize: function(code, def, bounds) {
var isP4 = L.Proj._isProj4Obj(code);
this._proj = isP4 ? code : this._projFromCodeDef(code, def);
this.bounds = isP4 ? def : bounds;
},
project: function (latlng) {
var point = this._proj.forward([latlng.lng, latlng.lat]);
return new L.Point(point[0], point[1]);
},
unproject: function (point, unbounded) {
var point2 = this._proj.inverse([point.x, point.y]);
return new L.LatLng(point2[1], point2[0], unbounded);
},
_projFromCodeDef: function(code, def) {
if (def) {
proj4.defs(code, def);
} else if (proj4.defs[code] === undefined) {
var urn = code.split(':');
if (urn.length > 3) {
code = urn[urn.length - 3] + ':' + urn[urn.length - 1];
}
if (proj4.defs[code] === undefined) {
throw 'No projection definition for code ' + code;
}
}
return proj4(code);
}
});
L.Proj.CRS = L.Class.extend({
includes: L.CRS,
options: {
transformation: new L.Transformation(1, 0, -1, 0)
},
initialize: function(a, b, c) {
var code,
proj,
def,
options;
if (L.Proj._isProj4Obj(a)) {
proj = a;
code = proj.srsCode;
options = b || {};
this.projection = new L.Proj.Projection(proj, options.bounds);
} else {
code = a;
def = b;
options = c || {};
this.projection = new L.Proj.Projection(code, def, options.bounds);
}
L.Util.setOptions(this, options);
this.code = code;
this.transformation = this.options.transformation;
if (this.options.origin) {
this.transformation =
new L.Transformation(1, -this.options.origin[0],
-1, this.options.origin[1]);
}
if (this.options.scales) {
this._scales = this.options.scales;
} else if (this.options.resolutions) {
this._scales = [];
for (var i = this.options.resolutions.length - 1; i >= 0; i--) {
if (this.options.resolutions[i]) {
this._scales[i] = 1 / this.options.resolutions[i];
}
}
}
this.infinite = !this.options.bounds;
},
scale: function(zoom) {
var iZoom = Math.floor(zoom),
baseScale,
nextScale,
scaleDiff,
zDiff;
if (zoom === iZoom) {
return this._scales[zoom];
} else {
// Non-integer zoom, interpolate
baseScale = this._scales[iZoom];
nextScale = this._scales[iZoom + 1];
scaleDiff = nextScale - baseScale;
zDiff = (zoom - iZoom);
return baseScale + scaleDiff * zDiff;
}
},
zoom: function(scale) {
// Find closest number in this._scales, down
var downScale = this._closestElement(this._scales, scale),
downZoom = this._scales.indexOf(downScale),
nextScale,
nextZoom,
scaleDiff;
// Check if scale is downScale => return array index
if (scale === downScale) {
return downZoom;
}
if (downScale === undefined) {
return -Infinity;
}
// Interpolate
nextZoom = downZoom + 1;
nextScale = this._scales[nextZoom];
if (nextScale === undefined) {
return Infinity;
}
scaleDiff = nextScale - downScale;
return (scale - downScale) / scaleDiff + downZoom;
},
distance: L.CRS.Earth.distance,
R: L.CRS.Earth.R,
/* Get the closest lowest element in an array */
_closestElement: function(array, element) {
var low;
for (var i = array.length; i--;) {
if (array[i] <= element && (low === undefined || low < array[i])) {
low = array[i];
}
}
return low;
}
});
L.Proj.GeoJSON = L.GeoJSON.extend({
initialize: function(geojson, options) {
this._callLevel = 0;
L.GeoJSON.prototype.initialize.call(this, geojson, options);
},
addData: function(geojson) {
var crs;
if (geojson) {
if (geojson.crs && geojson.crs.type === 'name') {
crs = new L.Proj.CRS(geojson.crs.properties.name);
} else if (geojson.crs && geojson.crs.type) {
crs = new L.Proj.CRS(geojson.crs.type + ':' + geojson.crs.properties.code);
}
if (crs !== undefined) {
this.options.coordsToLatLng = function(coords) {
var point = L.point(coords[0], coords[1]);
return crs.projection.unproject(point);
};
}
}
// Base class' addData might call us recursively, but
// CRS shouldn't be cleared in that case, since CRS applies
// to the whole GeoJSON, inluding sub-features.
this._callLevel++;
try {
L.GeoJSON.prototype.addData.call(this, geojson);
} finally {
this._callLevel--;
if (this._callLevel === 0) {
delete this.options.coordsToLatLng;
}
}
}
});
L.Proj.geoJson = function(geojson, options) {
return new L.Proj.GeoJSON(geojson, options);
};
L.Proj.ImageOverlay = L.ImageOverlay.extend({
initialize: function (url, bounds, options) {
L.ImageOverlay.prototype.initialize.call(this, url, null, options);
this._projectedBounds = bounds;
},
// Danger ahead: Overriding internal methods in Leaflet.
// Decided to do this rather than making a copy of L.ImageOverlay
// and doing very tiny modifications to it.
// Future will tell if this was wise or not.
_animateZoom: function (event) {
var scale = this._map.getZoomScale(event.zoom);
var northWest = L.point(this._projectedBounds.min.x, this._projectedBounds.max.y);
var offset = this._projectedToNewLayerPoint(northWest, event.zoom, event.center);
L.DomUtil.setTransform(this._image, offset, scale);
},
_reset: function () {
var zoom = this._map.getZoom();
var pixelOrigin = this._map.getPixelOrigin();
var bounds = L.bounds(
this._transform(this._projectedBounds.min, zoom)._subtract(pixelOrigin),
this._transform(this._projectedBounds.max, zoom)._subtract(pixelOrigin)
);
var size = bounds.getSize();
L.DomUtil.setPosition(this._image, bounds.min);
this._image.style.width = size.x + 'px';
this._image.style.height = size.y + 'px';
},
_projectedToNewLayerPoint: function (point, zoom, center) {
var viewHalf = this._map.getSize()._divideBy(2);
var newTopLeft = this._map.project(center, zoom)._subtract(viewHalf)._round();
var topLeft = newTopLeft.add(this._map._getMapPanePos());
return this._transform(point, zoom)._subtract(topLeft);
},
_transform: function (point, zoom) {
var crs = this._map.options.crs;
var transformation = crs.transformation;
var scale = crs.scale(zoom);
return transformation.transform(point, scale);
}
});
L.Proj.imageOverlay = function (url, bounds, options) {
return new L.Proj.ImageOverlay(url, bounds, options);
};
return L.Proj;
}));
// taken from
// https://ourcodeworld.com/articles/read/143/how-to-copy-text-to-clipboard-with-javascript-easily
function setClipboardText(text) {
var id = 'mycustom-clipboard-textarea-hidden-id';
var existsTextarea = document.getElementById(id);
if (!existsTextarea) {
console.log('Creating textarea');
var textarea = document.createElement('textarea');
textarea.id = id;
// Place in top-left corner of screen regardless of scroll position.
textarea.style.position = 'fixed';
textarea.style.top = 0;
textarea.style.left = 0;
// Ensure it has a small width and height. Setting to 1px / 1em
// doesn't work as this gives a negative w/h on some browsers.
textarea.style.width = '1px';
textarea.style.height = '1px';
// We don't need padding, reducing the size if it does flash render.
textarea.style.padding = 0;
// Clean up any borders.
textarea.style.border = 'none';
textarea.style.outline = 'none';
textarea.style.boxShadow = 'none';
// Avoid flash of white box if rendered for any reason.
textarea.style.background = 'transparent';
document.querySelector('body').appendChild(textarea);
console.log('The textarea now exists :)');
existsTextarea = document.getElementById(id);
} else {
console.log('The textarea already exists :3');
}
existsTextarea.value = text;
existsTextarea.select();
try {
var status = document.execCommand('copy');
if (!status) {
console.error('Cannot copy text');
} else {
console.log('The text is now on the clipboard');
}
} catch (err) {
console.log('Unable to copy.');
}
}
This diff is collapsed.
This diff is collapsed.
public/site_libs/leaflet-1.3.1/images/layers-2x.png

1.23 KiB

public/site_libs/leaflet-1.3.1/images/layers.png

696 B

public/site_libs/leaflet-1.3.1/images/marker-icon-2x.png

2.41 KiB

public/site_libs/leaflet-1.3.1/images/marker-icon.png

1.43 KiB

public/site_libs/leaflet-1.3.1/images/marker-shadow.png

618 B

/* required styles */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
position: absolute;
left: 0;
top: 0;
}
.leaflet-container {
overflow: hidden;
}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-user-drag: none;
}
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
.leaflet-safari .leaflet-tile {
image-rendering: -webkit-optimize-contrast;
}
/* hack that prevents hw layers "stretching" when loading new tiles */
.leaflet-safari .leaflet-tile-container {
width: 1600px;
height: 1600px;
-webkit-transform-origin: 0 0;
}
.leaflet-marker-icon,
.leaflet-marker-shadow {
display: block;
}
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container .leaflet-overlay-pane svg,
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer {
max-width: none !important;
max-height: none !important;
}
.leaflet-container.leaflet-touch-zoom {
-ms-touch-action: pan-x pan-y;
touch-action: pan-x pan-y;
}
.leaflet-container.leaflet-touch-drag {
-ms-touch-action: pinch-zoom;
/* Fallback for FF which doesn't support pinch-zoom */
touch-action: none;
touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
-ms-touch-action: none;
touch-action: none;
}
.leaflet-container {
-webkit-tap-highlight-color: transparent;
}
.leaflet-container a {
-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
}
.leaflet-tile {
filter: inherit;
visibility: hidden;
}
.leaflet-tile-loaded {
visibility: inherit;
}
.leaflet-zoom-box {
width: 0;
height: 0;
-moz-box-sizing: border-box;
box-sizing: border-box;
z-index: 800;
}
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg {
-moz-user-select: none;
}
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-vml-shape {
width: 1px;
height: 1px;
}
.lvml {
behavior: url(#default#VML);
display: inline-block;
position: absolute;
}
/* control positioning */
.leaflet-control {
position: relative;
z-index: 800;
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
.leaflet-top,
.leaflet-bottom {
position: absolute;
z-index: 1000;
pointer-events: none;
}
.leaflet-top {
top: 0;
}
.leaflet-right {
right: 0;
}
.leaflet-bottom {
bottom: 0;
}
.leaflet-left {
left: 0;
}
.leaflet-control {
float: left;
clear: both;
}
.leaflet-right .leaflet-control {
float: right;
}
.leaflet-top .leaflet-control {
margin-top: 10px;
}
.leaflet-bottom .leaflet-control {
margin-bottom: 10px;
}
.leaflet-left .leaflet-control {
margin-left: 10px;
}
.leaflet-right .leaflet-control {
margin-right: 10px;
}
/* zoom and fade animations */
.leaflet-fade-anim .leaflet-tile {
will-change: opacity;
}
.leaflet-fade-anim .leaflet-popup {
opacity: 0;
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
opacity: 1;
}
.leaflet-zoom-animated {
-webkit-transform-origin: 0 0;
-ms-transform-origin: 0 0;
transform-origin: 0 0;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
will-change: transform;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
}
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
-webkit-transition: none;
-moz-transition: none;
-o-transition: none;
transition: none;
}
.leaflet-zoom-anim .leaflet-zoom-hide {
visibility: hidden;
}
/* cursors */
.leaflet-interactive {
cursor: pointer;
}
.leaflet-grab {
cursor: -webkit-grab;
cursor: -moz-grab;
}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
cursor: crosshair;
}
.leaflet-popup-pane,
.leaflet-control {
cursor: auto;
}
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable {
cursor: move;
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
}
/* marker & overlays interactivity */
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
pointer-events: none;
}
.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive {
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
/* visual tweaks */
.leaflet-container {
background: #ddd;
outline: 0;
}
.leaflet-container a {
color: #0078A8;
}
.leaflet-container a.leaflet-active {
outline: 2px solid orange;
}
.leaflet-zoom-box {
border: 2px dotted #38f;
background: rgba(255,255,255,0.5);
}
/* general typography */
.leaflet-container {
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
}
/* general toolbar styles */
.leaflet-bar {
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
border-radius: 4px;
}
.leaflet-bar a,
.leaflet-bar a:hover {
background-color: #fff;
border-bottom: 1px solid #ccc;
width: 26px;
height: 26px;
line-height: 26px;
display: block;
text-align: center;
text-decoration: none;
color: black;
}
.leaflet-bar a,
.leaflet-control-layers-toggle {
background-position: 50% 50%;
background-repeat: no-repeat;
display: block;
}
.leaflet-bar a:hover {
background-color: #f4f4f4;
}
.leaflet-bar a:first-child {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.leaflet-bar a:last-child {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom: none;
}
.leaflet-bar a.leaflet-disabled {
cursor: default;
background-color: #f4f4f4;
color: #bbb;
}
.leaflet-touch .leaflet-bar a {
width: 30px;
height: 30px;
line-height: 30px;
}
.leaflet-touch .leaflet-bar a:first-child {
border-top-left-radius: 2px;
border-top-right-radius: 2px;
}
.leaflet-touch .leaflet-bar a:last-child {
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
}
/* zoom control */
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px;
}
.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
font-size: 22px;
}
/* layers control */
.leaflet-control-layers {
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
background: #fff;
border-radius: 5px;
}
.leaflet-control-layers-toggle {
background-image: url(images/layers.png);
width: 36px;
height: 36px;
}
.leaflet-retina .leaflet-control-layers-toggle {
background-image: url(images/layers-2x.png);
background-size: 26px 26px;
}
.leaflet-touch .leaflet-control-layers-toggle {
width: 44px;
height: 44px;
}
.leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
display: none;
}
.leaflet-control-layers-expanded .leaflet-control-layers-list {
display: block;
position: relative;
}
.leaflet-control-layers-expanded {
padding: 6px 10px 6px 6px;
color: #333;
background: #fff;
}
.leaflet-control-layers-scrollbar {
overflow-y: scroll;
overflow-x: hidden;
padding-right: 5px;
}
.leaflet-control-layers-selector {
margin-top: 2px;
position: relative;
top: 1px;
}
.leaflet-control-layers label {
display: block;
}
.leaflet-control-layers-separator {
height: 0;
border-top: 1px solid #ddd;
margin: 5px -10px 5px -6px;
}
/* Default icon URLs */
.leaflet-default-icon-path {
background-image: url(images/marker-icon.png);
}
/* attribution and scale controls */
.leaflet-container .leaflet-control-attribution {
background: #fff;
background: rgba(255, 255, 255, 0.7);
margin: 0;
}
.leaflet-control-attribution,
.leaflet-control-scale-line {
padding: 0 5px;
color: #333;
}
.leaflet-control-attribution a {
text-decoration: none;
}
.leaflet-control-attribution a:hover {
text-decoration: underline;
}
.leaflet-container .leaflet-control-attribution,
.leaflet-container .leaflet-control-scale {
font-size: 11px;
}
.leaflet-left .leaflet-control-scale {
margin-left: 5px;
}
.leaflet-bottom .leaflet-control-scale {
margin-bottom: 5px;
}
.leaflet-control-scale-line {
border: 2px solid #777;
border-top: none;
line-height: 1.1;
padding: 2px 5px 1px;
font-size: 11px;
white-space: nowrap;
overflow: hidden;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #fff;
background: rgba(255, 255, 255, 0.5);
}
.leaflet-control-scale-line:not(:first-child) {
border-top: 2px solid #777;
border-bottom: none;
margin-top: -2px;
}
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
border-bottom: 2px solid #777;
}
.leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
box-shadow: none;
}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
border: 2px solid rgba(0,0,0,0.2);
background-clip: padding-box;
}
/* popup */
.leaflet-popup {
position: absolute;
text-align: center;
margin-bottom: 20px;
}
.leaflet-popup-content-wrapper {
padding: 1px;
text-align: left;
border-radius: 12px;
}
.leaflet-popup-content {
margin: 13px 19px;
line-height: 1.4;
}
.leaflet-popup-content p {
margin: 18px 0;
}
.leaflet-popup-tip-container {
width: 40px;
height: 20px;
position: absolute;
left: 50%;
margin-left: -20px;
overflow: hidden;
pointer-events: none;
}
.leaflet-popup-tip {
width: 17px;
height: 17px;
padding: 1px;
margin: -10px auto 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
background: white;
color: #333;
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
}
.leaflet-container a.leaflet-popup-close-button {
position: absolute;
top: 0;
right: 0;
padding: 4px 4px 0 0;
border: none;
text-align: center;
width: 18px;
height: 14px;
font: 16px/14px Tahoma, Verdana, sans-serif;
color: #c3c3c3;
text-decoration: none;
font-weight: bold;
background: transparent;
}
.leaflet-container a.leaflet-popup-close-button:hover {
color: #999;
}
.leaflet-popup-scrolled {
overflow: auto;
border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd;
}
.leaflet-oldie .leaflet-popup-content-wrapper {
zoom: 1;
}
.leaflet-oldie .leaflet-popup-tip {
width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
}
.leaflet-oldie .leaflet-popup-tip-container {
margin-top: -1px;
}
.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip {
border: 1px solid #999;
}
/* div icon */
.leaflet-div-icon {
background: #fff;
border: 1px solid #666;
}
/* Tooltip */
/* Base styles for the element that has a tooltip */
.leaflet-tooltip {
position: absolute;
padding: 6px;
background-color: #fff;
border: 1px solid #fff;
border-radius: 3px;
color: #222;
white-space: nowrap;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
pointer-events: none;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.leaflet-tooltip.leaflet-clickable {
cursor: pointer;
pointer-events: auto;
}
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
position: absolute;
pointer-events: none;
border: 6px solid transparent;
background: transparent;
content: "";
}
/* Directions */
.leaflet-tooltip-bottom {
margin-top: 6px;
}
.leaflet-tooltip-top {
margin-top: -6px;
}
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-top:before {
left: 50%;
margin-left: -6px;
}
.leaflet-tooltip-top:before {
bottom: 0;
margin-bottom: -12px;
border-top-color: #fff;
}
.leaflet-tooltip-bottom:before {
top: 0;
margin-top: -12px;
margin-left: -6px;
border-bottom-color: #fff;
}
.leaflet-tooltip-left {
margin-left: -6px;
}
.leaflet-tooltip-right {
margin-left: 6px;
}
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
top: 50%;
margin-top: -6px;
}
.leaflet-tooltip-left:before {
right: 0;
margin-right: -12px;
border-left-color: #fff;
}
.leaflet-tooltip-right:before {
left: 0;
margin-left: -12px;
border-right-color: #fff;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment