Commit 44370a96 authored by jbferet's avatar jbferet
Browse files

- vignettes

parent 6c1c8a92
Meta
doc
.Rproj.user .Rproj.user
.Rbuildignore .Rbuildignore
.Rhistory .Rhistory
......
...@@ -7,9 +7,9 @@ knitr::opts_chunk$set( ...@@ -7,9 +7,9 @@ knitr::opts_chunk$set(
## ----Input / Output files------------------------------------------------ ## ----Input / Output files------------------------------------------------
# Input.Image.File = system.file('extdata', 'RASTER', 'S2A_T33NUD_20180104_Subset', package = 'biodivMapR') # Input.Image.File = system.file('extdata', 'RASTER', 'S2A_T33NUD_20180104_Subset', package = 'biodivMapR')
# Check.Data.Format(Input.Image.File) # check_data(Input.Image.File)
# #
# Input.Image.File = Convert.Raster2BIL(Raster.Path = Input.Image.File, # Input.Image.File = raster2BIL(Raster.Path = Input.Image.File,
# Sensor = 'SENTINEL_2A', # Sensor = 'SENTINEL_2A',
# Convert.Integer = TRUE, # Convert.Integer = TRUE,
# Output.Directory = '~/test') # Output.Directory = '~/test')
...@@ -52,11 +52,11 @@ knitr::opts_chunk$set( ...@@ -52,11 +52,11 @@ knitr::opts_chunk$set(
# print("MAP ALPHA DIVERSITY") # print("MAP ALPHA DIVERSITY")
# # Index.Alpha = c('Shannon','Simpson') # # Index.Alpha = c('Shannon','Simpson')
# Index.Alpha = c('Shannon') # Index.Alpha = c('Shannon')
# Map.Alpha.Diversity(Input.Image.File, Output.Dir, Spatial.Res, # map_alpha_div(Input.Image.File, Output.Dir, Spatial.Res,
# nbCPU = nbCPU, MaxRAM = MaxRAM, Index.Alpha = Index.Alpha) # nbCPU = nbCPU, MaxRAM = MaxRAM, Index.Alpha = Index.Alpha)
# #
# print("MAP BETA DIVERSITY") # print("MAP BETA DIVERSITY")
# Map.Beta.Diversity(Input.Image.File, Output.Dir, Spatial.Res, # map_beta_div(Input.Image.File, Output.Dir, Spatial.Res,
# nbCPU = nbCPU, MaxRAM = MaxRAM) # nbCPU = nbCPU, MaxRAM = MaxRAM)
## ----alpha and beta diversity indices from vector layer------------------ ## ----alpha and beta diversity indices from vector layer------------------
...@@ -71,15 +71,15 @@ knitr::opts_chunk$set( ...@@ -71,15 +71,15 @@ knitr::opts_chunk$set(
# Shannon.All = list() # ?? # Shannon.All = list() # ??
# #
# # list vector data # # list vector data
# Path.Vector = Get.List.Shp(vect) # Path.Vector = list.shp(vect)
# Name.Vector = tools::file_path_sans_ext(basename(Path.Vector)) # Name.Vector = tools::file_path_sans_ext(basename(Path.Vector))
# #
# # read raster data including projection # # read raster data including projection
# RasterStack = stack(Path.Raster) # RasterStack = stack(Path.Raster)
# Projection.Raster = Get.Projection(Path.Raster,'raster') # Projection.Raster = projection.file(Path.Raster,'raster')
# #
# # get alpha and beta diversity indicators corresponding to shapefiles # # get alpha and beta diversity indicators corresponding to shapefiles
# Biodiv.Indicators = Get.Diversity.From.Plots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters) # Biodiv.Indicators = diversity_from_plots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters)
# # if no name # # if no name
# Biodiv.Indicators$Name.Plot = seq(1,length(Biodiv.Indicators$Shannon[[1]]),by = 1) # Biodiv.Indicators$Name.Plot = seq(1,length(Biodiv.Indicators$Shannon[[1]]),by = 1)
# Shannon.RS = c(Biodiv.Indicators$Shannon)[[1]] # Shannon.RS = c(Biodiv.Indicators$Shannon)[[1]]
......
...@@ -49,9 +49,9 @@ The output directory defined with `Output.Dir` will contain all the results. For ...@@ -49,9 +49,9 @@ The output directory defined with `Output.Dir` will contain all the results. For
```{r Input / Output files} ```{r Input / Output files}
Input.Image.File = system.file('extdata', 'RASTER', 'S2A_T33NUD_20180104_Subset', package = 'biodivMapR') Input.Image.File = system.file('extdata', 'RASTER', 'S2A_T33NUD_20180104_Subset', package = 'biodivMapR')
Check.Data.Format(Input.Image.File) check_data(Input.Image.File)
Input.Image.File = Convert.Raster2BIL(Raster.Path = Input.Image.File, Input.Image.File = raster2BIL(Raster.Path = Input.Image.File,
Sensor = 'SENTINEL_2A', Sensor = 'SENTINEL_2A',
Convert.Integer = TRUE, Convert.Integer = TRUE,
Output.Directory = '~/test') Output.Directory = '~/test')
...@@ -136,11 +136,11 @@ Map.Spectral.Species(Input.Image.File, Output.Dir, PCA.Files, ...@@ -136,11 +136,11 @@ Map.Spectral.Species(Input.Image.File, Output.Dir, PCA.Files,
print("MAP ALPHA DIVERSITY") print("MAP ALPHA DIVERSITY")
# Index.Alpha = c('Shannon','Simpson') # Index.Alpha = c('Shannon','Simpson')
Index.Alpha = c('Shannon') Index.Alpha = c('Shannon')
Map.Alpha.Diversity(Input.Image.File, Output.Dir, Spatial.Res, map_alpha_div(Input.Image.File, Output.Dir, Spatial.Res,
nbCPU = nbCPU, MaxRAM = MaxRAM, Index.Alpha = Index.Alpha) nbCPU = nbCPU, MaxRAM = MaxRAM, Index.Alpha = Index.Alpha)
print("MAP BETA DIVERSITY") print("MAP BETA DIVERSITY")
Map.Beta.Diversity(Input.Image.File, Output.Dir, Spatial.Res, map_beta_div(Input.Image.File, Output.Dir, Spatial.Res,
nbCPU = nbCPU, MaxRAM = MaxRAM) nbCPU = nbCPU, MaxRAM = MaxRAM)
``` ```
...@@ -159,15 +159,15 @@ vect = system.file('extdata', 'VECTOR', package = 'biodivMapR') ...@@ -159,15 +159,15 @@ vect = system.file('extdata', 'VECTOR', package = 'biodivMapR')
Shannon.All = list() # ?? Shannon.All = list() # ??
# list vector data # list vector data
Path.Vector = Get.List.Shp(vect) Path.Vector = list.shp(vect)
Name.Vector = tools::file_path_sans_ext(basename(Path.Vector)) Name.Vector = tools::file_path_sans_ext(basename(Path.Vector))
# read raster data including projection # read raster data including projection
RasterStack = stack(Path.Raster) RasterStack = stack(Path.Raster)
Projection.Raster = Get.Projection(Path.Raster,'raster') Projection.Raster = projection.file(Path.Raster,'raster')
# get alpha and beta diversity indicators corresponding to shapefiles # get alpha and beta diversity indicators corresponding to shapefiles
Biodiv.Indicators = Get.Diversity.From.Plots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters) Biodiv.Indicators = diversity_from_plots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters)
# if no name # if no name
Biodiv.Indicators$Name.Plot = seq(1,length(Biodiv.Indicators$Shannon[[1]]),by = 1) Biodiv.Indicators$Name.Plot = seq(1,length(Biodiv.Indicators$Shannon[[1]]),by = 1)
Shannon.RS = c(Biodiv.Indicators$Shannon)[[1]] Shannon.RS = c(Biodiv.Indicators$Shannon)[[1]]
......
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
<meta name="author" content="Jean-Baptiste Féret, Florian de Boissieu" /> <meta name="author" content="Jean-Baptiste Féret, Florian de Boissieu" />
<meta name="date" content="2019-07-05" /> <meta name="date" content="2019-07-13" />
<title>Tutorial for biodivMapR</title> <title>Tutorial for biodivMapR</title>
<style type="text/css">code{white-space: pre;}</style> <style type="text/css">code{white-space: pre;}</style>
<style type="text/css"> <style type="text/css" data-origin="pandoc">
div.sourceCode { overflow-x: auto; } div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; } margin: 0; padding: 0; vertical-align: baseline; border: none; }
...@@ -55,7 +55,29 @@ code > span.do { color: #ba2121; font-style: italic; } /* Documentation */ ...@@ -55,7 +55,29 @@ code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style> </style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
for (var j = 0; j < rules.length; j++) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue;
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' || rule.style.backgroundColor === '') continue;
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
...@@ -70,7 +92,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf ...@@ -70,7 +92,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
<h1 class="title toc-ignore">Tutorial for biodivMapR</h1> <h1 class="title toc-ignore">Tutorial for biodivMapR</h1>
<h4 class="author"><em>Jean-Baptiste Féret, Florian de Boissieu</em></h4> <h4 class="author"><em>Jean-Baptiste Féret, Florian de Boissieu</em></h4>
<h4 class="date"><em>2019-07-05</em></h4> <h4 class="date"><em>2019-07-13</em></h4>
...@@ -97,9 +119,9 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf ...@@ -97,9 +119,9 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
<p>A mask can also be set to work on a selected part of the input image. The mask is expected to be a raster in the same format as the image (ENVI HDR), with values 0 = masked or 1 = selected. If no mask is to be used set <code>Input.Mask.File = FALSE</code>.</p> <p>A mask can also be set to work on a selected part of the input image. The mask is expected to be a raster in the same format as the image (ENVI HDR), with values 0 = masked or 1 = selected. If no mask is to be used set <code>Input.Mask.File = FALSE</code>.</p>
<p>The output directory defined with <code>Output.Dir</code> will contain all the results. For each image processed, a subdirectory will be automatically created after its name.</p> <p>The output directory defined with <code>Output.Dir</code> will contain all the results. For each image processed, a subdirectory will be automatically created after its name.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">Input.Image.File =<span class="st"> </span><span class="kw">system.file</span>(<span class="st">'extdata'</span>, <span class="st">'RASTER'</span>, <span class="st">'S2A_T33NUD_20180104_Subset'</span>, <span class="dt">package =</span> <span class="st">'biodivMapR'</span>) <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">Input.Image.File =<span class="st"> </span><span class="kw">system.file</span>(<span class="st">'extdata'</span>, <span class="st">'RASTER'</span>, <span class="st">'S2A_T33NUD_20180104_Subset'</span>, <span class="dt">package =</span> <span class="st">'biodivMapR'</span>)
<span class="kw">Check.Data.Format</span>(Input.Image.File) <span class="kw">check_data</span>(Input.Image.File)
Input.Image.File =<span class="st"> </span><span class="kw">Convert.Raster2BIL</span>(<span class="dt">Raster.Path =</span> Input.Image.File, Input.Image.File =<span class="st"> </span><span class="kw">raster2BIL</span>(<span class="dt">Raster.Path =</span> Input.Image.File,
<span class="dt">Sensor =</span> <span class="st">'SENTINEL_2A'</span>, <span class="dt">Sensor =</span> <span class="st">'SENTINEL_2A'</span>,
<span class="dt">Convert.Integer =</span> <span class="ot">TRUE</span>, <span class="dt">Convert.Integer =</span> <span class="ot">TRUE</span>,
<span class="dt">Output.Directory =</span> <span class="st">'~/test'</span>) <span class="dt">Output.Directory =</span> <span class="st">'~/test'</span>)
...@@ -167,11 +189,11 @@ PCA.Files =<span class="st"> </span><span class="kw">Perform.PCA.Image</span>(I ...@@ -167,11 +189,11 @@ PCA.Files =<span class="st"> </span><span class="kw">Perform.PCA.Image</span>(I
<span class="kw">print</span>(<span class="st">&quot;MAP ALPHA DIVERSITY&quot;</span>) <span class="kw">print</span>(<span class="st">&quot;MAP ALPHA DIVERSITY&quot;</span>)
<span class="co"># Index.Alpha = c('Shannon','Simpson')</span> <span class="co"># Index.Alpha = c('Shannon','Simpson')</span>
Index.Alpha =<span class="st"> </span><span class="kw">c</span>(<span class="st">'Shannon'</span>) Index.Alpha =<span class="st"> </span><span class="kw">c</span>(<span class="st">'Shannon'</span>)
<span class="kw">Map.Alpha.Diversity</span>(Input.Image.File, Output.Dir, Spatial.Res, <span class="kw">map_alpha_div</span>(Input.Image.File, Output.Dir, Spatial.Res,
<span class="dt">nbCPU =</span> nbCPU, <span class="dt">MaxRAM =</span> MaxRAM, <span class="dt">Index.Alpha =</span> Index.Alpha) <span class="dt">nbCPU =</span> nbCPU, <span class="dt">MaxRAM =</span> MaxRAM, <span class="dt">Index.Alpha =</span> Index.Alpha)
<span class="kw">print</span>(<span class="st">&quot;MAP BETA DIVERSITY&quot;</span>) <span class="kw">print</span>(<span class="st">&quot;MAP BETA DIVERSITY&quot;</span>)
<span class="kw">Map.Beta.Diversity</span>(Input.Image.File, Output.Dir, Spatial.Res, <span class="kw">map_beta_div</span>(Input.Image.File, Output.Dir, Spatial.Res,
<span class="dt">nbCPU =</span> nbCPU, <span class="dt">MaxRAM =</span> MaxRAM)</code></pre></div> <span class="dt">nbCPU =</span> nbCPU, <span class="dt">MaxRAM =</span> MaxRAM)</code></pre></div>
</div> </div>
</div> </div>
...@@ -189,15 +211,15 @@ vect =<span class="st"> </span><span class="kw">system.file</span>(<span ...@@ -189,15 +211,15 @@ vect =<span class="st"> </span><span class="kw">system.file</span>(<span
Shannon.All =<span class="st"> </span><span class="kw">list</span>() <span class="co"># ??</span> Shannon.All =<span class="st"> </span><span class="kw">list</span>() <span class="co"># ??</span>
<span class="co"># list vector data</span> <span class="co"># list vector data</span>
Path.Vector =<span class="st"> </span><span class="kw">Get.List.Shp</span>(vect) Path.Vector =<span class="st"> </span><span class="kw">list.shp</span>(vect)
Name.Vector =<span class="st"> </span>tools<span class="op">::</span><span class="kw">file_path_sans_ext</span>(<span class="kw">basename</span>(Path.Vector)) Name.Vector =<span class="st"> </span>tools<span class="op">::</span><span class="kw">file_path_sans_ext</span>(<span class="kw">basename</span>(Path.Vector))
<span class="co"># read raster data including projection</span> <span class="co"># read raster data including projection</span>
RasterStack =<span class="st"> </span><span class="kw">stack</span>(Path.Raster) RasterStack =<span class="st"> </span><span class="kw">stack</span>(Path.Raster)
Projection.Raster =<span class="st"> </span><span class="kw">Get.Projection</span>(Path.Raster,<span class="st">'raster'</span>) Projection.Raster =<span class="st"> </span><span class="kw">projection.file</span>(Path.Raster,<span class="st">'raster'</span>)
<span class="co"># get alpha and beta diversity indicators corresponding to shapefiles</span> <span class="co"># get alpha and beta diversity indicators corresponding to shapefiles</span>
Biodiv.Indicators =<span class="st"> </span><span class="kw">Get.Diversity.From.Plots</span>(<span class="dt">Raster =</span> Path.Raster, <span class="dt">Plots =</span> Path.Vector,<span class="dt">NbClusters =</span> nbclusters) Biodiv.Indicators =<span class="st"> </span><span class="kw">diversity_from_plots</span>(<span class="dt">Raster =</span> Path.Raster, <span class="dt">Plots =</span> Path.Vector,<span class="dt">NbClusters =</span> nbclusters)
<span class="co"># if no name</span> <span class="co"># if no name</span>
Biodiv.Indicators<span class="op">$</span>Name.Plot =<span class="st"> </span><span class="kw">seq</span>(<span class="dv">1</span>,<span class="kw">length</span>(Biodiv.Indicators<span class="op">$</span>Shannon[[<span class="dv">1</span>]]),<span class="dt">by =</span> <span class="dv">1</span>) Biodiv.Indicators<span class="op">$</span>Name.Plot =<span class="st"> </span><span class="kw">seq</span>(<span class="dv">1</span>,<span class="kw">length</span>(Biodiv.Indicators<span class="op">$</span>Shannon[[<span class="dv">1</span>]]),<span class="dt">by =</span> <span class="dv">1</span>)
Shannon.RS =<span class="st"> </span><span class="kw">c</span>(Biodiv.Indicators<span class="op">$</span>Shannon)[[<span class="dv">1</span>]]</code></pre></div> Shannon.RS =<span class="st"> </span><span class="kw">c</span>(Biodiv.Indicators<span class="op">$</span>Shannon)[[<span class="dv">1</span>]]</code></pre></div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment