Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
gisma committed May 10, 2024
1 parent 1ae43ea commit 99612b2
Show file tree
Hide file tree
Showing 25 changed files with 78 additions and 187 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ src/*.o
src/*.so
src/*.dll
junk
inst/doc
16 changes: 2 additions & 14 deletions R/initProj.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ initProj <- function(root_folder = ".", folders = NULL, folder_names = NULL,
standard_setup = NULL
)
}



# create R project and scripts
brew::brew(system.file(sprintf("templates/%s.brew", "rstudio_proj"), package = "link2GI"), file.path(root_folder, paste0(basename(root_folder), ".Rproj")))
brew::brew(system.file(sprintf("templates/%s.brew", "script_control"), package = "link2GI"), file.path(dirs$src, "main-control.R"))
Expand Down Expand Up @@ -235,18 +234,7 @@ initProj <- function(root_folder = ".", folders = NULL, folder_names = NULL,

if (init_renv) renv::init(root_folder)

# dirs=yaml::as.yaml(dirs)
#yaml::write_yaml(dirs,file = file.path("pPath.yaml"))
#dirs = createFolders(root_folder = here::here(root_folder),folders = dirs,create_folders = FALSE)
# yaml::write_yaml(dirs,file.path(here::here(root_folder),"src/functions/dirs.yaml"))
# if (is.null(OpenFiles)) {
# rstudioapi::navigateToFile("src/pre-processing.R")
# rstudioapi::navigateToFile("src/post-processing.R")
# rstudioapi::navigateToFile("src/10-processing.R")
# rstudioapi::navigateToFile("src/functions/000_setup.R")
# rstudioapi::navigateToFile("src/main-control.R")
# }
#if (openproject) rstudioapi::openProject(file.path(root_folder, paste0(basename(root_folder), ".Rproj")),newSession = newsession)
if (openproject) rstudioapi::openProject(file.path(root_folder, paste0(basename(root_folder), ".Rproj")),newSession = newsession)
return(dirs)
}

Expand Down
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ articles:
link2GI5: link2GI5.html
link2GI6: link2GI6.html
link2GI7: link2GI7.html
last_built: 2024-05-10T11:54Z
last_built: 2024-05-10T13:48Z
urls:
reference: https://r-spatial.github.io/link2GI/reference
article: https://r-spatial.github.io/link2GI/articles
Expand Down
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
2 changes: 1 addition & 1 deletion vignettes/link2GI1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{Link GI to R}
%\VignetteIndexEntry{link2GI - Link GI to R}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
2 changes: 1 addition & 1 deletion vignettes/link2GI1.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<div class="frontmatter">
<div class="title"><h1>Link GI to R</h1></div>
<div class="author"><h2>Chris Reudenbach</h2></div>
<div class="date"><h3>2024-05-08</h3></div>
<div class="date"><h3>2024-05-10</h3></div>
</div>
<div class="body">
<h1 id="what-is-link2gi">What is link2GI?</h1>
Expand Down
4 changes: 2 additions & 2 deletions vignettes/link2GI1.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
author: "Chris Reudenbach"
title: "Link GI to R"
date: "2024-05-08"
date: "2024-05-10"
editor_options:
chunk_output_type: console
output:
Expand All @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{Link GI to R}
%\VignetteIndexEntry{link2GI - Link GI to R}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
2 changes: 1 addition & 1 deletion vignettes/link2GI2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{link2GI Basic Examples}
%\VignetteIndexEntry{link2GI - link2GI Basic Examples}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
2 changes: 1 addition & 1 deletion vignettes/link2GI2.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<div class="frontmatter">
<div class="title"><h1>link2GI Basic Examples</h1></div>
<div class="author"><h2>Chris Reudenbach</h2></div>
<div class="date"><h3>2024-05-08</h3></div>
<div class="date"><h3>2024-05-10</h3></div>
</div>
<div class="body">
<h1 id="using-the-link2gi-package-basic-examples">Using the link2GI package - Basic examples</h1>
Expand Down
4 changes: 2 additions & 2 deletions vignettes/link2GI2.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
author: "Chris Reudenbach"
title: "link2GI Basic Examples"
date: "2024-05-08"
date: "2024-05-10"
editor_options:
chunk_output_type: console
output:
Expand All @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{link2GI Basic Examples}
%\VignetteIndexEntry{link2GI - link2GI Basic Examples}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
2 changes: 1 addition & 1 deletion vignettes/link2GI3.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{linkGRASS real world data usecase}
%\VignetteIndexEntry{link2GI - linkGRASS real world data usecase}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
2 changes: 1 addition & 1 deletion vignettes/link2GI3.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<div class="frontmatter">
<div class="title"><h1>linkGRASS real world data usecase</h1></div>
<div class="author"><h2>Chris Reudenbach</h2></div>
<div class="date"><h3>2024-05-09</h3></div>
<div class="date"><h3>2024-05-10</h3></div>
</div>
<div class="body">
<h1 id="real-world-example">Real world example</h1>
Expand Down
4 changes: 2 additions & 2 deletions vignettes/link2GI3.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
author: "Chris Reudenbach"
title: "linkGRASS real world data usecase"
date: "2024-05-09"
date: "2024-05-10"
editor_options:
chunk_output_type: console
output:
Expand All @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{linkGRASS real world data usecase}
%\VignetteIndexEntry{link2GI - linkGRASS real world data usecase}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
2 changes: 1 addition & 1 deletion vignettes/link2GI4.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{OTB Wrapper}
%\VignetteIndexEntry{link2GI - OTB Wrapper}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
2 changes: 1 addition & 1 deletion vignettes/link2GI4.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<div class="frontmatter">
<div class="title"><h1>OTB Wrapper</h1></div>
<div class="author"><h2>Chris Reudenbach</h2></div>
<div class="date"><h3>2024-05-07</h3></div>
<div class="date"><h3>2024-05-10</h3></div>
</div>
<div class="body">
<h1 id="a-typical-use-case-for-the-orfeo-toolbox-wrapper">A typical use case for the Orfeo Toolbox wrapper</h1>
Expand Down
4 changes: 2 additions & 2 deletions vignettes/link2GI4.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
author: "Chris Reudenbach"
title: "OTB Wrapper"
date: "2024-05-07"
date: "2024-05-10"
editor_options:
chunk_output_type: console
output:
Expand All @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{OTB Wrapper}
%\VignetteIndexEntry{link2GI - OTB Wrapper}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
9 changes: 8 additions & 1 deletion vignettes/link2GI5.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{Reproducible projects}
%\VignetteIndexEntry{link2GI - Reproducible projects}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down Expand Up @@ -70,3 +70,10 @@ root_folder <- tempdir() # Mandatory, variable must be in the R environment.
dirs <- initProj(root_folder = root_folder, standard_setup = "baseSpatial",folders = c("data/rawdata/provider1/", "docs/quarto/"))
```

A more complex call will be:

```R
initProj(root_folder = tempdir(), folders = c("data/newdata/"),
init_git = TRUE, init_renv = TRUE, code_subfolder = c("src", "src/functions","src/deprec"),
standard_setup = "baseSpatial",loc_name = "oldplace", appendlibs = c("raster"),openproject=TRUE)
```
5 changes: 5 additions & 0 deletions vignettes/link2GI5.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ <h3 id="using-the-console">Using the Console</h3>
<pre><code class="language-R">root_folder &lt;- tempdir() # Mandatory, variable must be in the R environment.
dirs &lt;- initProj(root_folder = root_folder, standard_setup = &quot;baseSpatial&quot;,folders = c(&quot;data/rawdata/provider1/&quot;, &quot;docs/quarto/&quot;))
</code></pre>
<p>A more complex call will be:</p>
<pre><code class="language-R"> initProj(root_folder = tempdir(), folders = c(&quot;data/newdata/&quot;),
init_git = TRUE, init_renv = TRUE, code_subfolder = c(&quot;src&quot;, &quot;src/functions&quot;,&quot;src/deprec&quot;),
standard_setup = &quot;baseSpatial&quot;,loc_name = &quot;oldplace&quot;, appendlibs = c(&quot;raster&quot;),openproject=TRUE)
</code></pre>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-core.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/autoloader/prism-autoloader.min.js" defer></script>
Expand Down
9 changes: 8 additions & 1 deletion vignettes/link2GI5.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{Reproducible projects}
%\VignetteIndexEntry{link2GI - Reproducible projects}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down Expand Up @@ -70,3 +70,10 @@ root_folder <- tempdir() # Mandatory, variable must be in the R environment.
dirs <- initProj(root_folder = root_folder, standard_setup = "baseSpatial",folders = c("data/rawdata/provider1/", "docs/quarto/"))
```

A more complex call will be:

```R
initProj(root_folder = tempdir(), folders = c("data/newdata/"),
init_git = TRUE, init_renv = TRUE, code_subfolder = c("src", "src/functions","src/deprec"),
standard_setup = "baseSpatial",loc_name = "oldplace", appendlibs = c("raster"),openproject=TRUE)
```
2 changes: 1 addition & 1 deletion vignettes/link2GI6.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output:
toc: yes
urlcolor: blue
vignette: >
%\VignetteIndexEntry{Geostat 2018 Examples}
%\VignetteIndexEntry{link2GI - Geostat 2018 Examples}
%\VignetteEncoding{UTF-8}{inputenc}\
%\VignetteEngine{knitr::knitr}
---
Expand Down
119 changes: 17 additions & 102 deletions vignettes/link2GI6.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Reproducible projects</title>
<style type="text/css">
/**
* Prism.s theme ported from highlight.js's xcode style
*/
pre code {
padding: 1em;
}
.token.comment {
color: #007400;
}
.token.punctuation {
color: #999;
}
.token.tag,
.token.selector {
color: #aa0d91;
}
.token.boolean,
.token.number,
.token.constant,
.token.symbol {
color: #1c00cf;
}
.token.property,
.token.attr-name,
.token.string,
.token.char,
.token.builtin {
color: #c41a16;
}
.token.inserted {
background-color: #ccffd8;
}
.token.deleted {
background-color: #ffebe9;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #836c28;
}
.token.function,
.token.class-name {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #5c2699;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
</style>
<title>GEOSTAT 2018 Examples</title>
<style type="text/css">
body {
font-family: sans-serif;
Expand Down Expand Up @@ -140,45 +75,25 @@
</head>
<body>
<div class="frontmatter">
<div class="title"><h1>Reproducible projects</h1></div>
<div class="title"><h1>GEOSTAT 2018 Examples</h1></div>
<div class="author"><h2>Chris Reudenbach</h2></div>
<div class="date"><h3>2024-05-07</h3></div>
<div class="date"><h3>2024-05-10</h3></div>
</div>
<div class="body">
<h1 id="reproducible-project-structure">Reproducible Project Structure</h1>
<p>Reproducible projects in R emphasize streamlined project setup and efficient workflows. There are a number of very helpful tools in the R universe, such as <a href="https://cran.r-project.org/package=renv"><code>renv</code></a>, <a href="https://cran.r-project.org/package=usethis"><code>usethis</code></a>, or <a href="https://cran.r-project.org/package=here"><code>here</code></a>, that range from setting up a stable R environment to generating custom project structures to getting the necessary paths in an easy way. In addition, there are a number of project structure packages and templates for creating easy-to-use and transparent project structures. Namely, <a href="https://cran.r-project.org/package=tinyProject"><code>tinProjects</code></a>, <a href="https://cran.r-project.org/package=prodigenr"><code>prodigenr</code></a> or <a href="https://cran.r-project.org/package=workflowr"><code>workflowr</code></a> are R packages designed to facilitate reproducible research through automated project structuring and standardization. They all promote organized project directories, emphasize reproducibility by integrating with tools like <code>Git' and </code>renv’, and reduce manual setup efforts to ensure consistent and error-free project initialization. These packages help build a solid foundation for research and ensure that best practices include using separate scripts for data processing, analysis, and reporting, and combining code with narrative in R Markdown documents from the start. This organized setup improves reproducibility by making it easier to maintain, share, and replicate research. For a more comprehensive overview, have a look at the <a href="https://CRAN.R-project.org/view=ReproducibleResearch"> CRAN Task View Reproducible Research</a>.</p>
<h2 id="why-initproj-then">Why initProj then?</h2>
<p>In the context of link2GI, which relies heavily on third-party command-line APIs and requires complex and stable folder and file structures, a flexible, lightweight R project setup greatly improves the integration of OS command-line tools into spatial workflows by</p>
<ol>
<li>**Streamlining integration: Simplifies the integration of essential command-line tools such as <code>GDAL' or the sophisticated </code>Orfeo Toolbox’ (OTB) and the growing universe of r(-)spatial packages for advanced geospatial processing.</li>
<li><strong>Improve data exchange</strong>: Organized variable and metadata management ensures accurate and efficient data transfer between different and especially command-line based processes and APIs.</li>
<li>**Enhanced Cross-Platform Compatibility: Facilitates cross-platform adaptability, which is critical when using multiple spatial analysis tools, even more so when using different shells.</li>
<li>**Performance Optimization: Switching between generic R and command-line tools takes advantage of the speed and efficiency of command-line tools, which is especially beneficial when handling large spatial datasets.</li>
</ol>
<p>For this reason, the link2GI package includes a lean and lightweight but focused approach that integrates <code>git', </code>renv’, and a highly flexible folder and package setup process that is simpler than existing approaches, increasing efficiency, accuracy, and performance in geospatial workflows.</p>
<h3 id="using-the-rstudio-gui">Using the RStudio GUI</h3>
<p><img src="https://raw.githubusercontent.com/r-spatial/link2GI/master/figures/usegui.gif" alt="Use the RStudio Template Option" /></p>
<h3 id="using-the-console">Using the Console</h3>
<p>The basic setup of a default project, which initializes Git and renv, is done with the following call.</p>
<pre><code class="language-R">root_folder &lt;- tempdir() # Mandatory, variable must be in the R environment.
envrmt &lt;- initProj(root_folder = root_folder, standard_setup = &quot;baseSpatial&quot;)

</code></pre>
<p>It is easy to customize the folder structure. By default you will create</p>
<pre><code class="language-R">link2GI::setup_default()$baseSpatial$folders
</code></pre>
<p><code>[1] &quot;docs&quot; &quot;docs/figures&quot; &quot;tmp&quot; &quot;data/source&quot; &quot;data/results&quot; &quot;data/level0&quot; &quot;data/level1&quot; </code></p>
<pre><code class="language-R">
link2GI::setup_default()$baseSpatial$code_subfolders

</code></pre>
<p><code>[1] &quot;src&quot; &quot;src/functions&quot;</code></p>
<p>Use the <code>folders</code> argument to create a specific structure or subfolder structure of your project.</p>
<pre><code class="language-R">root_folder &lt;- tempdir() # Mandatory, variable must be in the R environment.
envrmt &lt;- initProj(root_folder = root_folder, standard_setup = &quot;baseSpatial&quot;,folders = c(&quot;data/rawdata/provider1/&quot;, &quot;docs/quarto/&quot;))
</code></pre>
<h3 id="usecases-presented-on-the-geostat-august-2018">Usecases presented on the GEOSTAT August 2018</h3>
<p>During the GEOSTAT 2018 (see <a href="https://opengeohub.org">https://opengeohub.org</a>) in Prague some more complex use cases have been presented.</p>
<h4 id="find-slides-and-materials">Find slides and materials</h4>
<ul>
<li><a href="https://gisma.github.io/link2gi2018/link2gi2018.html#1">Presentation slides</a></li>
<li><a href="https://github.com/gisma/link2gi2018">Github Repository</a></li>
</ul>
<h4 id="the-examples">The examples</h4>
<ul>
<li>Basic usage of <code>SAGA</code> and <code>OTB</code> calls - <a href="https://github.com/gisma/link2gi2018/blob/master/R/usecases/saga-otb/useCaseSAGA-OTB.R">SAGA &amp; OTB basic usecase</a></li>
<li>Wrapping a <a href="https://neteler.gitlab.io/grass-gis-analysis/02_grass-gis_ecad_analysis/">GRASS GIS example</a> of Markus Neteler as presented on GEOSTAT 2018 - <a href="https://github.com/gisma/link2gi2018/blob/master/R/usecases/grass/useCaseGRASS-Neteler2018.R">Analysing the ECA&amp;D climatic data - reloaded</a></li>
<li>Performing a <code>GRASS</code> based cost analysis on a huge cost raster - <a href="https://github.com/gisma/link2gi2018/blob/master/R/usecases/cost-analysis/useCaseBeetle.R">Beetle spread over high asia</a></li>
<li>Deriving a canopy height model using a mixed API approach - <a href="https://github.com/gisma/link2gi2018/blob/master/R/usecases/uav-pc/useCaseCHM.R">Canopy Height Model from UAV derived point clouds</a></li>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-core.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/autoloader/prism-autoloader.min.js" defer></script>
</body>
</html>
Loading

0 comments on commit 99612b2

Please sign in to comment.