├── .Rbuildignore ├── .github ├── .gitignore ├── CONTRIBUTING.md └── workflows │ ├── R-CMD-check.yaml │ ├── check-releasebranch.yaml │ ├── pkgdown.yaml │ ├── rhub.yaml │ └── test-coverage.yaml ├── .gitignore ├── CRAN-SUBMISSION ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md ├── R ├── gdal_grass.R ├── gmeta.R ├── initGRASS.R ├── options.R ├── rast_link.R ├── read_helpers.R ├── rgrass-package.R ├── vect_link.R ├── vect_link_ng.R ├── xml1.R └── zzz.R ├── README.md ├── _pkgdown.yml ├── codecov.yml ├── cran-comments.md ├── docs ├── 404.html ├── CONTRIBUTING.html ├── articles │ ├── OSGeo4W_QGIS_Rgui.png │ ├── OSGeo4W_QGIS_navbar.png │ ├── OSGeo4W_QGIS_rstudio.png │ ├── OSGeo4W_Rgui.png │ ├── OSGeo4W_rstudio.png │ ├── coerce.html │ ├── fig1.png │ ├── fig2_p7_RRASTER_GRASS.png │ ├── index.html │ ├── rstudio_in_GRASS.png │ └── use.html ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── deps │ ├── bootstrap-5.3.1 │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ └── bootstrap.min.css │ ├── bootstrap-toc-1.0.1 │ │ └── bootstrap-toc.min.js │ ├── clipboard.js-2.0.11 │ │ └── clipboard.min.js │ ├── data-deps.txt │ ├── font-awesome-6.4.2 │ │ ├── css │ │ │ ├── all.css │ │ │ ├── all.min.css │ │ │ ├── v4-shims.css │ │ │ └── v4-shims.min.css │ │ └── webfonts │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-regular-400.woff2 │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-solid-900.woff2 │ │ │ ├── fa-v4compatibility.ttf │ │ │ └── fa-v4compatibility.woff2 │ ├── font-awesome-6.5.2 │ │ ├── css │ │ │ ├── all.css │ │ │ ├── all.min.css │ │ │ ├── v4-shims.css │ │ │ └── v4-shims.min.css │ │ └── webfonts │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-regular-400.woff2 │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-solid-900.woff2 │ │ │ ├── fa-v4compatibility.ttf │ │ │ └── fa-v4compatibility.woff2 │ ├── headroom-0.11.0 │ │ ├── headroom.min.js │ │ └── jQuery.headroom.min.js │ ├── jquery-3.6.0 │ │ ├── jquery-3.6.0.js │ │ ├── jquery-3.6.0.min.js │ │ └── jquery-3.6.0.min.map │ └── search-1.0.0 │ │ ├── autocomplete.jquery.min.js │ │ ├── fuse.min.js │ │ └── mark.min.js ├── docsearch.css ├── docsearch.js ├── index.html ├── katex-auto.js ├── lightswitch.js ├── link.svg ├── news │ └── index.html ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── doGRASS.html │ ├── execGRASS.html │ ├── get.GIS_LOCK.html │ ├── get.defaultFlagsOption.html │ ├── get.echoCmdOption.html │ ├── get.ignore.stderrOption.html │ ├── get.legacyExecOption.html │ ├── get.stop_on_no_flags_parasOption.html │ ├── get.suppressEchoCmdInFuncOption.html │ ├── get.useInternOption.html │ ├── getLocationProj.html │ ├── getXMLencoding.html │ ├── gmeta.html │ ├── gmeta2grd.html │ ├── index.html │ ├── initGRASS.html │ ├── parseGRASS.html │ ├── print.GRASS_interface_desc.html │ ├── print.gmeta.html │ ├── read_RAST-1.png │ ├── read_RAST.html │ ├── read_VECT.html │ ├── remove_GISRC.html │ ├── rgrass-package.html │ ├── rgrass.html │ ├── set.GIS_LOCK.html │ ├── set.defaultFlagsOption.html │ ├── set.echoCmdOption.html │ ├── set.ignore.stderrOption.html │ ├── set.legacyExecOption.html │ ├── set.stop_on_no_flags_parasOption.html │ ├── set.suppressEchoCmdInFuncOption.html │ ├── set.useInternOption.html │ ├── setXMLencoding.html │ ├── stringexecGRASS.html │ ├── unlink_.gislock.html │ ├── unset.GIS_LOCK.html │ ├── vColumns.html │ ├── vDataCount.html │ ├── vInfo.html │ ├── vect2neigh.html │ ├── write_RAST.html │ └── write_VECT.html ├── search.json └── sitemap.xml ├── inst ├── etc │ ├── XML.r.out.gdal.rds │ └── res_r.water.outlet.rds └── pre_git_ChangeLog ├── man ├── execGRASS.Rd ├── gmeta.Rd ├── initGRASS.Rd ├── read_RAST.Rd ├── read_VECT.Rd └── rgrass.Rd ├── tests ├── testthat.R └── testthat │ ├── helper.R │ ├── setup.R │ ├── test-execGRASS.R │ ├── test-gmeta.R │ ├── test-initGRASS.R │ ├── test-options.R │ ├── test-read_RAST.R │ └── test-read_VECT.R └── vignettes ├── OSGeo4W_QGIS_Rgui.png ├── OSGeo4W_QGIS_navbar.png ├── OSGeo4W_QGIS_rstudio.png ├── OSGeo4W_Rgui.png ├── OSGeo4W_rstudio.png ├── coerce.Rmd ├── fig1.png ├── fig2_p7_RRASTER_GRASS.png ├── refs.bib ├── rstudio_in_GRASS.png └── use.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | oChangeLog 2 | README.md 3 | docs 4 | _pkgdown.yml 5 | ^.*\.Rproj$ 6 | ^\.Rproj\.user$ 7 | ^\.github$ 8 | ^codecov\.yml$ 9 | ^_pkgdown\.yml$ 10 | ^docs$ 11 | ^pkgdown$ 12 | ^cran-comments\.md$ 13 | ^\.vscode$ 14 | ^CRAN-SUBMISSION$ 15 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Contributing to rgrass 2 | 3 | This outlines how to propose a change to **rgrass**. 4 | The package supports both GRASS GIS 7 and 8 and is available from CRAN. 5 | 6 | ### How to propose a change to rgrass 7 | 8 | The `main` branch is the development branch for **rgrass**. 9 | If you would like to contribute to **rgrass**, please target your PRs and contributions to this branch. 10 | 11 | ### Note 12 | 13 | The **rgrass** package is the successor to the **rgrass7** package. 14 | The `rgrass7` branch was the "target" maintenance source for the **rgrass7** package, at a time that both **rgrass7** and **rgrass** coexisted. 15 | **rgrass7** development is no longer continued; the package has been archived on CRAN. 16 | The `rgrass7` branch is kept for reference only. 17 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | 8 | name: R-CMD-check 9 | 10 | permissions: read-all 11 | 12 | jobs: 13 | R-CMD-check: 14 | strategy: 15 | matrix: 16 | os: [ubuntu-22.04, ubuntu-24.04] 17 | 18 | runs-on: ${{ matrix.os }} 19 | 20 | env: 21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 22 | R_KEEP_PKG_SOURCE: yes 23 | 24 | steps: 25 | - uses: actions/checkout@v4 26 | 27 | - uses: r-lib/actions/setup-pandoc@v2 28 | 29 | - uses: r-lib/actions/setup-r@v2 30 | with: 31 | use-public-rspm: true 32 | 33 | - name: Install common system dependencies 34 | run: | 35 | sudo apt-get update 36 | sudo apt-get install -y grass-dev libgdal-dev libudunits2-dev libharfbuzz-dev libfribidi-dev 37 | 38 | - uses: r-lib/actions/setup-r-dependencies@v2 39 | with: 40 | extra-packages: any::rcmdcheck, any::terra 41 | needs: check 42 | 43 | - uses: r-lib/actions/check-r-package@v2 44 | with: 45 | upload-snapshots: true 46 | build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' 47 | -------------------------------------------------------------------------------- /.github/workflows/check-releasebranch.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | 8 | name: releasebranch_8_4-ubuntu 9 | 10 | permissions: read-all 11 | 12 | jobs: 13 | R-CMD-check-releasebranch: 14 | runs-on: ubuntu-latest 15 | strategy: 16 | matrix: 17 | container: [ 18 | "osgeo/grass-gis:releasebranch_8_4-ubuntu", 19 | "osgeo/grass-gis:main-ubuntu" 20 | ] 21 | 22 | container: 23 | image: ${{ matrix.container }} 24 | options: --privileged 25 | 26 | steps: 27 | - uses: actions/checkout@v4 28 | 29 | - name: Install system deps 30 | run: | 31 | apt-get update 32 | apt-get install -y \ 33 | libudunits2-dev \ 34 | libharfbuzz-dev \ 35 | libfribidi-dev \ 36 | gdal-bin \ 37 | libmysqlclient-dev \ 38 | libfontconfig1-dev \ 39 | qpdf \ 40 | pandoc \ 41 | pandoc-citeproc 42 | 43 | - name: Install R 44 | run: | 45 | wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc 46 | echo "deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" | tee -a /etc/apt/sources.list 47 | apt-get update 48 | apt-get install -y r-base-dev 49 | 50 | - name: Configure RSPM in .Renviron 51 | run: | 52 | echo 'options(repos = c(CRAN = "https://packagemanager.posit.co/cran/__linux__/jammy/latest"))' >> ~/.Rprofile 53 | echo 'options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"])))' >> ~/.Rprofile 54 | echo 'options(Ncpus=parallel::detectCores())' >> ~/.Rprofile 55 | 56 | - name: Install R dependencies 57 | run: | 58 | R -e "install.packages(c('remotes', 'rcmdcheck'))" 59 | R -e "remotes::install_deps(dependencies = TRUE)" 60 | R -e "install.packages('terra', repos = 'https://cloud.r-project.org/', type = 'source')" 61 | 62 | - uses: r-lib/actions/check-r-package@v2 63 | with: 64 | upload-snapshots: true 65 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | release: 8 | types: [published] 9 | workflow_dispatch: 10 | 11 | name: pkgdown.yaml 12 | 13 | permissions: read-all 14 | 15 | jobs: 16 | pkgdown: 17 | runs-on: ubuntu-22.04 18 | # Only restrict concurrency for non-PR jobs 19 | concurrency: 20 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 21 | env: 22 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 23 | GRASS_INSTALLATION: /usr/lib/grass78 24 | permissions: 25 | contents: write 26 | steps: 27 | - uses: actions/checkout@v4 28 | 29 | - uses: r-lib/actions/setup-pandoc@v2 30 | 31 | - uses: r-lib/actions/setup-r@v2 32 | with: 33 | use-public-rspm: true 34 | 35 | - name: Install system dependencies 36 | run: | 37 | sudo apt-get update 38 | sudo apt-get install -y grass libgdal-dev libudunits2-dev libharfbuzz-dev libfribidi-dev 39 | 40 | - uses: r-lib/actions/setup-r-dependencies@v2 41 | with: 42 | extra-packages: any::pkgdown, local::. 43 | needs: website 44 | 45 | - name: Download test dataset 46 | run: | 47 | wget https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip -O /tmp/nc_basic_spm_grass7.zip 48 | unzip /tmp/nc_basic_spm_grass7.zip -d /tmp/grassdb 49 | rm /tmp/nc_basic_spm_grass7.zip 50 | 51 | - name: Build pkgdown site 52 | run: | 53 | grass /tmp/grassdb/nc_basic_spm_grass7/PERMANENT --exec sh -c "R -e 'pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, run_dont_run = TRUE)'" 54 | 55 | - name: Deploy to GitHub pages 🚀 56 | if: github.event_name != 'pull_request' 57 | uses: JamesIves/github-pages-deploy-action@v4.5.0 58 | with: 59 | clean: false 60 | branch: gh-pages 61 | folder: docs 62 | -------------------------------------------------------------------------------- /.github/workflows/rhub.yaml: -------------------------------------------------------------------------------- 1 | # R-hub's generic GitHub Actions workflow file. It's canonical location is at 2 | # https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml 3 | # You can update this file to a newer version using the rhub2 package: 4 | # 5 | # rhub::rhub_setup() 6 | # 7 | # It is unlikely that you need to modify this file manually. 8 | 9 | name: R-hub 10 | run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" 11 | 12 | on: 13 | workflow_dispatch: 14 | inputs: 15 | config: 16 | description: 'A comma separated list of R-hub platforms to use.' 17 | type: string 18 | default: 'linux,windows,macos' 19 | name: 20 | description: 'Run name. You can leave this empty now.' 21 | type: string 22 | id: 23 | description: 'Unique ID. You can leave this empty now.' 24 | type: string 25 | 26 | jobs: 27 | 28 | setup: 29 | runs-on: ubuntu-latest 30 | outputs: 31 | containers: ${{ steps.rhub-setup.outputs.containers }} 32 | platforms: ${{ steps.rhub-setup.outputs.platforms }} 33 | 34 | steps: 35 | # NO NEED TO CHECKOUT HERE 36 | - uses: r-hub/actions/setup@v1 37 | with: 38 | config: ${{ github.event.inputs.config }} 39 | id: rhub-setup 40 | 41 | linux-containers: 42 | needs: setup 43 | if: ${{ needs.setup.outputs.containers != '[]' }} 44 | runs-on: ubuntu-latest 45 | name: ${{ matrix.config.label }} 46 | strategy: 47 | fail-fast: false 48 | matrix: 49 | config: ${{ fromJson(needs.setup.outputs.containers) }} 50 | container: 51 | image: ${{ matrix.config.container }} 52 | 53 | steps: 54 | - uses: r-hub/actions/checkout@v1 55 | - uses: r-hub/actions/platform-info@v1 56 | with: 57 | token: ${{ secrets.RHUB_TOKEN }} 58 | job-config: ${{ matrix.config.job-config }} 59 | - uses: r-hub/actions/setup-deps@v1 60 | with: 61 | token: ${{ secrets.RHUB_TOKEN }} 62 | job-config: ${{ matrix.config.job-config }} 63 | - uses: r-hub/actions/run-check@v1 64 | with: 65 | token: ${{ secrets.RHUB_TOKEN }} 66 | job-config: ${{ matrix.config.job-config }} 67 | 68 | other-platforms: 69 | needs: setup 70 | if: ${{ needs.setup.outputs.platforms != '[]' }} 71 | runs-on: ${{ matrix.config.os }} 72 | name: ${{ matrix.config.label }} 73 | strategy: 74 | fail-fast: false 75 | matrix: 76 | config: ${{ fromJson(needs.setup.outputs.platforms) }} 77 | 78 | steps: 79 | - uses: r-hub/actions/checkout@v1 80 | - uses: r-hub/actions/setup-r@v1 81 | with: 82 | job-config: ${{ matrix.config.job-config }} 83 | token: ${{ secrets.RHUB_TOKEN }} 84 | - uses: r-hub/actions/platform-info@v1 85 | with: 86 | token: ${{ secrets.RHUB_TOKEN }} 87 | job-config: ${{ matrix.config.job-config }} 88 | - uses: r-hub/actions/setup-deps@v1 89 | with: 90 | job-config: ${{ matrix.config.job-config }} 91 | token: ${{ secrets.RHUB_TOKEN }} 92 | - uses: r-hub/actions/run-check@v1 93 | with: 94 | job-config: ${{ matrix.config.job-config }} 95 | token: ${{ secrets.RHUB_TOKEN }} 96 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | 8 | name: test-coverage.yaml 9 | 10 | permissions: read-all 11 | 12 | jobs: 13 | test-coverage: 14 | runs-on: ubuntu-latest 15 | env: 16 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - uses: r-lib/actions/setup-r@v2 22 | with: 23 | use-public-rspm: true 24 | 25 | - name: Install common system dependencies 26 | run: | 27 | sudo apt-get update 28 | sudo apt-get install -y grass-dev libgdal-dev libudunits2-dev libharfbuzz-dev libfribidi-dev 29 | 30 | - uses: r-lib/actions/setup-r-dependencies@v2 31 | with: 32 | extra-packages: any::covr, any::xml2, any::terra 33 | needs: coverage 34 | 35 | - name: Test coverage 36 | run: | 37 | cov <- covr::package_coverage( 38 | quiet = FALSE, 39 | clean = FALSE, 40 | install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") 41 | ) 42 | covr::to_cobertura(cov) 43 | shell: Rscript {0} 44 | 45 | - uses: codecov/codecov-action@v4 46 | with: 47 | # Fail if error if not on PR, or if on PR and token is given 48 | fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} 49 | file: ./cobertura.xml 50 | plugin: noop 51 | disable_search: true 52 | token: ${{ secrets.CODECOV_TOKEN }} 53 | 54 | - name: Show testthat output 55 | if: always() 56 | run: | 57 | ## -------------------------------------------------------------------- 58 | find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true 59 | shell: bash 60 | 61 | - name: Upload test results 62 | if: failure() 63 | uses: actions/upload-artifact@v4 64 | with: 65 | name: coverage-test-failures 66 | path: ${{ runner.temp }}/package 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .Rdata 4 | .httr-oauth 5 | .DS_Store 6 | *.Rproj 7 | docs 8 | .vscode/ 9 | -------------------------------------------------------------------------------- /CRAN-SUBMISSION: -------------------------------------------------------------------------------- 1 | Version: 0.5-2 2 | Date: 2025-02-14 04:11:14 UTC 3 | SHA: c754a7572afa7353fb1d473dfe3f85482042704f 4 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: rgrass 2 | Version: 0.5-2 3 | Date: 2025-02-13 4 | Title: Interface Between 'GRASS' Geographical Information System and 'R' 5 | Authors@R: c( 6 | person("Roger", "Bivand", role = c("aut"), email = "Roger.Bivand@nhh.no", comment=c(ORCID="0000-0003-2392-6140")), 7 | person("Sebastian", "Jeworutzki", role = "ctb", email="Sebastian.Jeworutzki@rub.de", comment=c(ORCID="0000-0002-2671-5253")), 8 | person("Rainer", "Krug", role = "ctb", email="Rainer@krugs.de", comment=c(ORCID="0000-0002-7490-0066")), 9 | person("Robin", "Lovelace", role = "ctb", comment=c(ORCID = "0000-0001-5679-6536")), 10 | person("Markus", "Neteler", role = "ctb", email="neteler@osgeo.org", comment=c(ORCID="0000-0003-1916-1966")), 11 | person("Steven", "Pawley", role = c("cre", "aut"), email="dr.stevenpawley@gmail.com", comment=c(ORCID="0000-0002-5524-3320")), 12 | person("Floris", "Vanderhaeghe", role = "ctb", email="floris.vanderhaeghe@inbo.be", comment=c(ORCID="0000-0002-6378-6229"))) 13 | Description: An interface between the 'GRASS' geographical information system ('GIS') and 'R', based on starting 'R' from within the 'GRASS' 'GIS' environment, or running a free-standing 'R' session in a temporary 'GRASS' location; the package provides facilities for using all 'GRASS' commands from the 'R' command line. The original interface package for 'GRASS 5' (2000-2010) is described in Bivand (2000) and Bivand (2001) . This was succeeded by 'spgrass6' for 'GRASS 6' (2006-2016) and 'rgrass7' for 'GRASS 7' (2015-present). The 'rgrass' package modernizes the interface for 'GRASS 8' while still permitting the use of 'GRASS 7'. 14 | Depends: R (>= 3.5.0) 15 | Imports: stats, utils, methods, xml2 16 | Suggests: 17 | terra (>= 1.6-16), 18 | sp (>= 0.9), 19 | knitr, 20 | rmarkdown, 21 | sf, 22 | stars, 23 | raster (>= 3.6-3), 24 | codetools, 25 | testthat (>= 3.0.0), 26 | withr, 27 | fs 28 | VignetteBuilder: knitr 29 | SystemRequirements: GRASS (>= 7) 30 | License: GPL (>= 2) 31 | URL: https://osgeo.github.io/rgrass/, https://grass.osgeo.org/, https://github.com/osgeo/rgrass, https://lists.osgeo.org/mailman/listinfo/grass-stats 32 | BugReports: https://github.com/osgeo/rgrass/issues/ 33 | RoxygenNote: 7.3.2 34 | Roxygen: list(markdown = TRUE) 35 | Encoding: UTF-8 36 | Config/testthat/edition: 3 37 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(print,GRASS_interface_desc) 4 | S3method(print,gmeta) 5 | export(doGRASS) 6 | export(execGRASS) 7 | export(get.GIS_LOCK) 8 | export(get.defaultFlagsOption) 9 | export(get.echoCmdOption) 10 | export(get.ignore.stderrOption) 11 | export(get.legacyExecOption) 12 | export(get.stop_on_no_flags_parasOption) 13 | export(get.suppressEchoCmdInFuncOption) 14 | export(get.useInternOption) 15 | export(getLocationProj) 16 | export(getXMLencoding) 17 | export(gmeta) 18 | export(gmeta2grd) 19 | export(initGRASS) 20 | export(parseGRASS) 21 | export(read_RAST) 22 | export(read_VECT) 23 | export(remove_GISRC) 24 | export(set.GIS_LOCK) 25 | export(set.defaultFlagsOption) 26 | export(set.echoCmdOption) 27 | export(set.ignore.stderrOption) 28 | export(set.legacyExecOption) 29 | export(set.stop_on_no_flags_parasOption) 30 | export(set.suppressEchoCmdInFuncOption) 31 | export(set.useInternOption) 32 | export(setXMLencoding) 33 | export(stringexecGRASS) 34 | export(unlink_.gislock) 35 | export(unset.GIS_LOCK) 36 | export(vColumns) 37 | export(vDataCount) 38 | export(vInfo) 39 | export(vect2neigh) 40 | export(write_RAST) 41 | export(write_VECT) 42 | importFrom(grDevices,rgb) 43 | importFrom(methods,as) 44 | importFrom(methods,getMethod) 45 | importFrom(methods,slot) 46 | importFrom(stats,na.omit) 47 | importFrom(stats,runif) 48 | importFrom(utils,read.table) 49 | importFrom(utils,write.table) 50 | importFrom(xml2,xml_name) 51 | importFrom(xml2,xml_text) 52 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # **rgrass** version 0.5-2 (2025-02-13) 2 | 3 | - minor change to testsuite to ensure that temporary directory is cleaned up after tests 4 | 5 | # **rgrass** version 0.5-1 (2025-02-02) 6 | 7 | - see #96, transfer maintainership to Steven Pawley 8 | 9 | - transfer repo to `osgeo/rgrass` - thanks to Markus Neteler 10 | 11 | - convert help pages to `roxygen2` - thanks to Steven Pawley 12 | 13 | - add and enable Github Actions CI/CD - thanks to Steven Pawley 14 | 15 | # **rgrass** version 0.4-4 (2024-09-03) 16 | 17 | - use `## IGNORE_RDIFF_BEGIN` and `## IGNORE_RDIFF_END` in regular test output 18 | 19 | # **rgrass** version 0.4-3 (2024-06-19) 20 | 21 | - see #87 - Windows QGIS standalone installations of GRASS GIS can be used only if R is started in the OSGeo4W shell bundled with the installation 22 | 23 | - `write_VECT()`: when the `SpatVector` object already refers to a source file, an intermediate temporary file is no longer written to get the data into the GRASS GIS database (#93). 24 | A similar shortcut was already in place for `write_RAST()`. 25 | 26 | - `read_VECT()`: provide access to the standalone GDAL-GRASS driver to read vector data, which skips the step of writing a intermediate file (#93). 27 | Note that this standalone driver needs to be set up separately. 28 | More information is in the [driver's README](https://github.com/OSGeo/gdal-grass/blob/main/README.md). 29 | 30 | - `read_VECT()`: support reading as `SpatVectorProxy` class of `{terra}`, by providing a `proxy` argument (#93). 31 | 32 | # **rgrass** version 0.4-2 (2024-03-17) 33 | 34 | - see #84 - handling fully-qualified map names 35 | 36 | # **rgrass** version 0.4-1 (2024-01-08) 37 | 38 | - replace `XML` with `xml2` see #72 39 | 40 | # **rgrass** version 0.3-9 (2023-09-10) 41 | 42 | - reinstate `grass-stable` https://github.com/OSGeo/grass-website/issues/357 43 | 44 | - fix #79 thanks to Adam B. Smith, use `terra::as.vector` method rather than internal slot name 45 | 46 | # **rgrass** version 0.3-8 (2023-03-17) 47 | 48 | - #73 guess `gisBase=` in `initGRASS()` 49 | 50 | - added _SP_EVOLUTION_STATUS_ 2 to examples 51 | 52 | - #66 re-examining to protect from UInt maxing out; add stop for required manual NODATA 53 | 54 | - #68, #69 improvements to vignettes, thanks to Floris Vanderhaeghe and Veronica Andreo 55 | 56 | # **rgrass** version 0.3-6 (2022-10-11) 57 | 58 | - macOS vignette issue 59 | 60 | # **rgrass** version 0.3-5 (2022-09-29) 61 | 62 | - #63 and #64, detection of GRASS path for `initGRASS()` semi-automated if `grass --config path` works or if environment variable `GRASS_INSTALLATION` set to path, thanks to Robin Lovelace 63 | 64 | - correct NODATA logic in `read_RAST()` for unsigned rasters #66 thanks to Laura Poggio 65 | 66 | # **rgrass** version 0.3-3 (2022-08-08) 67 | 68 | - correct vignette logic error triggered on M1 when **stars** not installed 69 | 70 | # **rgrass** version 0.3-2 (2022-07-21) 71 | 72 | - first release to replace deprecated **rgrass7** 73 | 74 | - remove suggested packages planned for retirement (**rgdal**) 75 | 76 | - add vignettes 77 | 78 | - remove old code working around earlier use by GRASS of DBF rather than SQLite for storing vector attributes 79 | 80 | - remove `use_sp()` and `use_sf()` for file transfer 81 | 82 | - remove code using GDAL GRASS plugin 83 | -------------------------------------------------------------------------------- /R/gdal_grass.R: -------------------------------------------------------------------------------- 1 | gdal_has_grassraster_driver <- function() { 2 | if (!(requireNamespace("terra", quietly = TRUE))) { 3 | stop("terra is required to get the GDAL drivers list") 4 | } 5 | drv <- terra::gdal(drivers = TRUE) 6 | "GRASS" %in% drv[drv$raster, ]$name 7 | } 8 | 9 | gdal_has_grassvector_driver <- function() { 10 | if (!(requireNamespace("terra", quietly = TRUE))) { 11 | stop("terra is required to get the GDAL drivers list") 12 | } 13 | drv <- terra::gdal(drivers = TRUE) 14 | "OGR_GRASS" %in% drv[drv$vector, ]$name 15 | } 16 | 17 | generate_header_path <- function(name, type, ...) { 18 | stopifnot( 19 | is.character(type), 20 | length(type) == 1L, 21 | type %in% c("raster", "vector") 22 | ) 23 | stopifnot( 24 | is.character(name), 25 | length(name) == 1L 26 | ) 27 | element <- ifelse(type == "vector", "vector", "cellhd") 28 | path <- execGRASS( 29 | "g.findfile", 30 | element = element, 31 | file = name, 32 | intern = TRUE, 33 | ... 34 | )[4] 35 | path <- regmatches( 36 | path, 37 | regexpr("(?<==['\"]).+(?=['\"]$)", path, perl = TRUE) 38 | ) 39 | if (type == "vector") { 40 | path <- file.path(path, "head") 41 | } 42 | path 43 | } 44 | -------------------------------------------------------------------------------- /R/options.R: -------------------------------------------------------------------------------- 1 | # Interpreted GRASS 7 interface functions 2 | # Copyright (c) 2015 Roger S. Bivand 3 | 4 | #' @rdname gmeta 5 | #' @order 12 6 | #' @param value logical value for setting options on `ignore.stderr` set by 7 | #' default on package load to FALSE, `stop_on_no_flags_params` set by default 8 | #' on package load to TRUE, `echoCmd` set by default on package load to FALSE. 9 | #' `useIntern` sets the intern argument globally; `legacyExec` sets the 10 | #' legacyExec option globally, but is initialized to FALSE on unix systems 11 | #' (all but Windows) and TRUE on Windows; `defaultFlags` is initialized to 12 | #' NULL, but may be a character vector with values from c("quiet", "verbose") 13 | #' `suppressEchoCmdInFunc` default TRUE suppresses the effect of echoCmd 14 | #' within package functions, maybe set FALSE for debugging. 15 | #' @export 16 | set.ignore.stderrOption <- function(value) { 17 | if (!is.logical(value)) stop("logical argument required") 18 | res <- get("ignore.stderr", envir = .GRASS_CACHE) 19 | assign("ignore.stderr", value, envir = .GRASS_CACHE) 20 | res 21 | } 22 | 23 | #' @rdname gmeta 24 | #' @order 5 25 | #' @export 26 | get.ignore.stderrOption <- function() { 27 | get("ignore.stderr", envir = .GRASS_CACHE) 28 | } 29 | 30 | #' @rdname gmeta 31 | #' @order 13 32 | #' @export 33 | set.stop_on_no_flags_parasOption <- function(value) { 34 | if (!is.logical(value)) stop("logical argument required") 35 | res <- get("stop_on_no_flags_paras", envir = .GRASS_CACHE) 36 | assign("stop_on_no_flags_paras", value, envir = .GRASS_CACHE) 37 | res 38 | } 39 | 40 | #' @rdname gmeta 41 | #' @order 6 42 | #' @export 43 | get.stop_on_no_flags_parasOption <- function() { 44 | get("stop_on_no_flags_paras", envir = .GRASS_CACHE) 45 | } 46 | 47 | #' @rdname gmeta 48 | #' @order 14 49 | #' @export 50 | set.echoCmdOption <- function(value) { 51 | if (!is.logical(value)) stop("logical argument required") 52 | res <- get("echoCmd", envir = .GRASS_CACHE) 53 | assign("echoCmd", value, envir = .GRASS_CACHE) 54 | res 55 | } 56 | 57 | #' @rdname gmeta 58 | #' @order 7 59 | #' @export 60 | get.echoCmdOption <- function() { 61 | get("echoCmd", envir = .GRASS_CACHE) 62 | } 63 | 64 | #' @rdname gmeta 65 | #' @order 15 66 | #' @export 67 | set.useInternOption <- function(value) { 68 | if (!is.logical(value)) stop("logical argument required") 69 | res <- get("useIntern", envir = .GRASS_CACHE) 70 | assign("useIntern", value, envir = .GRASS_CACHE) 71 | res 72 | } 73 | 74 | #' @rdname gmeta 75 | #' @order 8 76 | #' @export 77 | get.useInternOption <- function() { 78 | get("useIntern", envir = .GRASS_CACHE) 79 | } 80 | 81 | #' @rdname gmeta 82 | #' @order 16 83 | #' @export 84 | set.legacyExecOption <- function(value) { 85 | if (!is.logical(value)) stop("logical argument required") 86 | res <- get("legacyExec", envir = .GRASS_CACHE) 87 | assign("legacyExec", value, envir = .GRASS_CACHE) 88 | res 89 | } 90 | 91 | #' @rdname gmeta 92 | #' @order 9 93 | #' @export 94 | get.legacyExecOption <- function() { 95 | get("legacyExec", envir = .GRASS_CACHE) 96 | } 97 | 98 | #' @rdname gmeta 99 | #' @order 17 100 | #' @export 101 | set.defaultFlagsOption <- function(value) { 102 | res <- get("defaultFlags", envir = .GRASS_CACHE) 103 | if (is.null(value)) { 104 | assign("defaultFlags", value, envir = .GRASS_CACHE) 105 | } else { 106 | if (!is.character(value)) stop("character argument required") 107 | stopifnot(length(value) > 0) 108 | stopifnot(all(value %in% c("quiet", "verbose"))) 109 | assign("defaultFlags", value, envir = .GRASS_CACHE) 110 | } 111 | res 112 | } 113 | 114 | #' @rdname gmeta 115 | #' @order 10 116 | #' @export 117 | get.defaultFlagsOption <- function() { 118 | get("defaultFlags", envir = .GRASS_CACHE) 119 | } 120 | 121 | #' @rdname gmeta 122 | #' @order 18 123 | #' @export 124 | set.suppressEchoCmdInFuncOption <- function(value) { 125 | if (!is.logical(value)) stop("logical argument required") 126 | res <- get("suppressEchoCmdInFunc", envir = .GRASS_CACHE) 127 | assign("suppressEchoCmdInFunc", value, envir = .GRASS_CACHE) 128 | res 129 | } 130 | 131 | #' @rdname gmeta 132 | #' @order 11 133 | #' @export 134 | get.suppressEchoCmdInFuncOption <- function() { 135 | get("suppressEchoCmdInFunc", envir = .GRASS_CACHE) 136 | } 137 | -------------------------------------------------------------------------------- /R/read_helpers.R: -------------------------------------------------------------------------------- 1 | sanitize_layername <- function(name, type, mapsets, ignore.stderr) { 2 | stopifnot( 3 | is.character(type), 4 | length(type) == 1L, 5 | type %in% c("raster", "vector") 6 | ) 7 | stopifnot( 8 | is.character(name), 9 | length(name) == 1L 10 | ) 11 | vca <- unlist(strsplit(name, "@")) 12 | if (length(vca) == 1L) { 13 | exsts <- execGRASS("g.list", 14 | type = type, pattern = vca[1], 15 | intern = TRUE, ignore.stderr = ignore.stderr 16 | ) 17 | if (length(exsts) > 1L) { 18 | stop( 19 | "multiple layers named ", vca[1], 20 | " found in in mapsets in search path: ", 21 | paste(mapsets, collapse = ", "), 22 | " ; use full path with @ to choose the required raster" 23 | ) 24 | } 25 | if (length(exsts) == 0L || exsts != vca[1]) { 26 | stop( 27 | name, " not found in mapsets in search path: ", 28 | paste(mapsets, collapse = ", ") 29 | ) 30 | } 31 | } else if (length(vca) == 2L) { 32 | exsts <- execGRASS("g.list", 33 | type = type, pattern = vca[1], 34 | mapset = vca[2], intern = TRUE, ignore.stderr = ignore.stderr 35 | ) 36 | if (length(exsts) == 0L || exsts != vca[1]) { 37 | stop(name, " not found in mapset: ", vca[2]) 38 | } 39 | } else { 40 | stop(name, " incorrectly formatted") 41 | } 42 | vca 43 | } 44 | 45 | get_mapsets <- function() { 46 | unlist(strsplit( 47 | execGRASS("g.mapsets", flags = "p", intern = TRUE), 48 | " " 49 | )) 50 | } 51 | -------------------------------------------------------------------------------- /R/rgrass-package.R: -------------------------------------------------------------------------------- 1 | #' rgrass: Interface between GRASS geographical information system and R 2 | #' 3 | #' Interpreted interface between GRASS geographical information 4 | #' system, versions 7 and 8, and R, based on starting R from within the GRASS 5 | #' environment, or on running R stand-alone and creating a throw-away GRASS 6 | #' environment from within R. The interface uses classes defined in the sp 7 | #' package to hold spatial data. 8 | #' 9 | #' @details 10 | #' Index: 11 | #' 12 | #' \preformatted{ 13 | #' read_RAST read GRASS raster files 14 | #' write_RAST write GRASS raster files 15 | #' read_VECT read GRASS vector object files 16 | #' write_VECT write GRASS vector object files 17 | #' gmeta read GRASS metadata from the current LOCATION 18 | #' getLocationProj return a WKT2 string of projection information 19 | #' gmeta2grd create a GridTopology object from the GRASS region 20 | #' vInfo return vector geometry information 21 | #' vColumns return vector database columns information 22 | #' vDataCount return count of vector database rows 23 | #' vect2neigh return area neighbours with shared boundary length 24 | #' } 25 | #' 26 | #' Note that the examples now use the smaller subset North Carolina location: 27 | #' \url{https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.tar.gz} 28 | #' 29 | #' @name rgrass 30 | #' @keywords internal package spatial 31 | "_PACKAGE" 32 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .GRASS_CACHE <- new.env(FALSE, parent = globalenv()) 2 | 3 | .onLoad <- function(lib, pkg) { 4 | # backup original environment variables 5 | assign( 6 | ".GRASS_old.GRASS_PAGER", 7 | Sys.getenv("GRASS_PAGER"), 8 | envir = .GRASS_CACHE 9 | ) 10 | 11 | assign( 12 | ".GRASS_old.GRASS_MESSAGE_FORMAT", 13 | Sys.getenv("GRASS_MESSAGE_FORMAT"), 14 | envir = .GRASS_CACHE 15 | ) 16 | 17 | Sys.setenv("GRASS_PAGER" = "cat") 18 | Sys.setenv("GRASS_MESSAGE_FORMAT" = "text") 19 | 20 | # set up the GRASS_CACHE environment 21 | assign("INIT_USED", FALSE, envir = .GRASS_CACHE) 22 | assign("remove_GISRC", FALSE, envir = .GRASS_CACHE) 23 | assign("cmdCACHE", list(), envir = .GRASS_CACHE) 24 | assign("override_encoding", "", envir = .GRASS_CACHE) 25 | 26 | # add platform type to .GRASS_CACHE 27 | if (.Platform$OS.type == "windows") { 28 | platform <- "WinNat" 29 | } else if (.Platform$OS.type == "unix") { 30 | platform <- "unix" 31 | } else { 32 | platform <- "unknown" 33 | } 34 | assign("SYS", platform, envir = .GRASS_CACHE) 35 | 36 | # store the platform-specific executable extension 37 | res <- ifelse(platform == "WinNat", "exe", "") 38 | assign("addEXE", res, envir = .GRASS_CACHE) 39 | assign("WN_bat", "", envir = .GRASS_CACHE) 40 | 41 | # set up other GRASS_CACHE environment variables 42 | assign("ignore.stderr", FALSE, envir = .GRASS_CACHE) 43 | assign("stop_on_no_flags_paras", TRUE, envir = .GRASS_CACHE) 44 | assign("echoCmd", FALSE, envir = .GRASS_CACHE) 45 | assign("GV", "", envir = .GRASS_CACHE) 46 | assign("useIntern", FALSE, envir = .GRASS_CACHE) 47 | assign("legacyExec", .Platform$OS.type == "windows", envir = .GRASS_CACHE) 48 | assign("defaultFlags", NULL, envir = .GRASS_CACHE) 49 | assign("suppressEchoCmdInFunc", TRUE, envir = .GRASS_CACHE) 50 | assign("R_interface", NULL, envir = .GRASS_CACHE) 51 | } 52 | 53 | .onAttach <- function(lib, pkg) { 54 | # display the GRASS version and location when the package is attached 55 | gisrc <- Sys.getenv("GISRC") 56 | loc <- Sys.getenv("LOCATION_NAME") 57 | 58 | if (nchar(gisrc) == 0) { 59 | gv <- "(GRASS not running)" 60 | } else { 61 | gv <- .grassVersion() 62 | comp <- .compatibleGRASSVersion(gv) 63 | 64 | if (!is.na(comp) && !comp) { 65 | stop(attr(comp, "message")) 66 | } 67 | 68 | assign("GV", gv, envir = .GRASS_CACHE) 69 | if (nchar(loc) == 0) { 70 | loc <- read.dcf(gisrc)[1, "LOCATION_NAME"] 71 | } 72 | } 73 | 74 | startup_message <- paste0( 75 | "GRASS GIS interface loaded ", 76 | "with GRASS version: ", gv, "\n", 77 | ifelse(nchar(loc) == 0, "", paste0("and location: ", loc, "\n")) 78 | ) 79 | packageStartupMessage(startup_message, appendLF = FALSE) 80 | } 81 | 82 | .onUnload <- function(lib, pkg) { 83 | # unset the GISRC environment variable and remove gisrc file 84 | if (get("INIT_USED", envir = .GRASS_CACHE)) { 85 | if (get("remove_GISRC", envir = .GRASS_CACHE)) { 86 | gisrc <- Sys.getenv("GISRC") 87 | if (file.exists(gisrc)) unlink(gisrc) 88 | Sys.unsetenv("GISRC") 89 | } 90 | unlink_.gislock() 91 | unset.GIS_LOCK() 92 | } 93 | 94 | # restore original environment variables 95 | Sys.setenv( 96 | "GRASS_PAGER" = get(".GRASS_old.GRASS_PAGER", envir = .GRASS_CACHE) 97 | ) 98 | 99 | Sys.setenv( 100 | "GRASS_MESSAGE_FORMAT" = 101 | get(".GRASS_old.GRASS_MESSAGE_FORMAT", envir = .GRASS_CACHE) 102 | ) 103 | 104 | rm(.GRASS_CACHE) 105 | } 106 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rgrass 2 | 3 | [![CRAN status](https://www.r-pkg.org/badges/version/rgrass)](https://CRAN.R-project.org/package=rgrass) 4 | [![codecov](https://codecov.io/gh/OSGeo/rgrass/graph/badge.svg?token=IP7nhufbRQ)](https://codecov.io/gh/OSGeo/rgrass) 5 | 6 | ### Interface Between GRASS Geographical Information System and R 7 | 8 | Interpreted interface between GRASS geographical information system and R, based on starting R from within the GRASS GIS environment, or running free-standing R in a temporary or existing GRASS location; the package provides facilities for using all GRASS commands from the R command line, see https://osgeo.github.io/rgrass/articles/use.html. 9 | 10 | The original interface **GRASS** package for `GRASS 5` (2000-2010) is described in Bivand (2000) (https://doi.org/10.1016/S0098-3004(00)00057-1) and Bivand (2001) (https://www.r-project.org/conferences/DSC-2001/Proceedings/Bivand.pdf). This was succeeded by **spgrass6** for `GRASS 6` (2006-2016) and **rgrass7** for `GRASS 7` (2015-2023). 11 | The **rgrass** package modernizes the interface for `GRASS 8` while still permitting the use of `GRASS 7`. 12 | 13 | ### Installation 14 | 15 | This package depends on [GRASS GIS](https://grass.osgeo.org/) version 8 or above (later version 7 should also be OK). 16 | 17 | If you use OSGeo4W on Windows (recommended), remember that you must start RStudio, Rgui or console R from within the OSGeo4W shell. 18 | 19 | See the [workshop on **rgrass** at FOSS4G 2022](https://rsbivand.github.io/foss4g_2022/modernizing_220822.html) for a detailed introduction with reproducible examples. 20 | 21 | If you would like to contribute, please see the CONTRIBUTING file in the .github folder. 22 | 23 | For detailed notes, see https://rsbivand.github.io/foss4g_2022/modernizing_220822.html. 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://osgeo.github.io/rgrass/ 2 | template: 3 | bootstrap: 5 4 | 5 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | informational: true 10 | patch: 11 | default: 12 | target: auto 13 | threshold: 1% 14 | informational: true 15 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## R CMD check results 2 | 3 | rgrass 0.5-2 ──── 4 | 5 | Release to address issue of cleaning up /tmp when running test suite 6 | 7 | Found the following files/directories: 8 | ‘/tmp/grassdb’ ‘/tmp/nc_basic_spm_grass7.zip’ 9 | * DONE 10 | 11 | Status: 1 NOTE 12 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page not found (404) • rgrass 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Skip to contents 17 | 18 | 19 |
53 |
54 |
59 | 60 | Content not found. Please use links in the navbar. 61 | 62 |
63 |
64 | 65 | 66 |
69 | 70 | 73 | 74 |
75 |
76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /docs/CONTRIBUTING.html: -------------------------------------------------------------------------------- 1 | 2 | NA • rgrass 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
39 | 40 | 41 |
42 |

Contributing to rgrass

43 |

This outlines how to propose a change to rgrass. The package supports both GRASS GIS 7 and 8 and is available from CRAN.

44 |
45 |
46 |

How to propose a change to rgrass

47 |

The main branch is the development branch for rgrass. If you would like to contribute to rgrass, please target your PRs and contributions to this branch.

48 |
49 |
50 |

Note

51 |

The rgrass package is the successor to the rgrass7 package. The rgrass7 branch was the “target” maintenance source for the rgrass7 package, at a time that both rgrass7 and rgrass coexisted. rgrass7 development is no longer continued; the package has been archived on CRAN. The rgrass7 branch is kept for reference only.

52 |
53 | 54 | 55 |
57 | 58 | 59 |
62 | 63 | 66 | 67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /docs/articles/OSGeo4W_QGIS_Rgui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/articles/OSGeo4W_QGIS_Rgui.png -------------------------------------------------------------------------------- /docs/articles/OSGeo4W_QGIS_navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/articles/OSGeo4W_QGIS_navbar.png -------------------------------------------------------------------------------- /docs/articles/OSGeo4W_QGIS_rstudio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/articles/OSGeo4W_QGIS_rstudio.png -------------------------------------------------------------------------------- /docs/articles/OSGeo4W_Rgui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/articles/OSGeo4W_Rgui.png -------------------------------------------------------------------------------- /docs/articles/OSGeo4W_rstudio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/articles/OSGeo4W_rstudio.png -------------------------------------------------------------------------------- /docs/articles/fig1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/articles/fig1.png -------------------------------------------------------------------------------- /docs/articles/fig2_p7_RRASTER_GRASS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/articles/fig2_p7_RRASTER_GRASS.png -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | Articles • rgrass 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
38 | 39 |
40 |

All vignettes

41 |
42 | 43 |
Coercion between object formats
44 |
45 |
Use of GRASS interface
46 |
47 |
48 |
49 | 50 | 51 |
54 | 55 | 58 | 59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /docs/articles/rstudio_in_GRASS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/articles/rstudio_in_GRASS.png -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | Authors and Citation • rgrass 3 | Skip to contents 4 | 5 | 6 |
33 |
34 |
38 | 39 |
40 |

Authors

41 | 42 |
  • 43 |

    Roger Bivand. Author. 44 |

    45 |
  • 46 |
  • 47 |

    Sebastian Jeworutzki. Contributor. 48 |

    49 |
  • 50 |
  • 51 |

    Rainer Krug. Contributor. 52 |

    53 |
  • 54 |
  • 55 |

    Robin Lovelace. Contributor. 56 |

    57 |
  • 58 |
  • 59 |

    Markus Neteler. Contributor. 60 |

    61 |
  • 62 |
  • 63 |

    Steven Pawley. Maintainer, author. 64 |

    65 |
  • 66 |
  • 67 |

    Floris Vanderhaeghe. Contributor. 68 |

    69 |
  • 70 |
71 | 72 |
73 |

Citation

74 |

Source: DESCRIPTION

75 | 76 |

Bivand R, Pawley S (2025). 77 | rgrass: Interface Between 'GRASS' Geographical Information System and 'R'. 78 | R package version 0.5-1, https://grass.osgeo.org/, https://github.com/osgeo/rgrass, https://lists.osgeo.org/mailman/listinfo/grass-stats, https://osgeo.github.io/rgrass/. 79 |

80 |
@Manual{,
 81 |   title = {rgrass: Interface Between 'GRASS' Geographical Information System and 'R'},
 82 |   author = {Roger Bivand and Steven Pawley},
 83 |   year = {2025},
 84 |   note = {R package version 0.5-1, https://grass.osgeo.org/, https://github.com/osgeo/rgrass, https://lists.osgeo.org/mailman/listinfo/grass-stats},
 85 |   url = {https://osgeo.github.io/rgrass/},
 86 | }
87 |
88 | 89 |
91 | 92 | 93 |
96 | 97 | 100 | 101 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | (function() { 6 | 'use strict'; 7 | 8 | window.Toc = { 9 | helpers: { 10 | // return all matching elements in the set, or their descendants 11 | findOrFilter: function($el, selector) { 12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ 13 | // http://stackoverflow.com/a/12731439/358804 14 | var $descendants = $el.find(selector); 15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); 16 | }, 17 | 18 | generateUniqueIdBase: function(el) { 19 | var text = $(el).text(); 20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); 21 | return anchor || el.tagName.toLowerCase(); 22 | }, 23 | 24 | generateUniqueId: function(el) { 25 | var anchorBase = this.generateUniqueIdBase(el); 26 | for (var i = 0; ; i++) { 27 | var anchor = anchorBase; 28 | if (i > 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /docs/deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v1.0.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | !function(a){"use strict";window.Toc={helpers:{findOrFilter:function(e,t){var n=e.find(t);return e.filter(t).add(n).filter(":not([data-toc-skip])")},generateUniqueIdBase:function(e){return a(e).text().trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase()||e.tagName.toLowerCase()},generateUniqueId:function(e){for(var t=this.generateUniqueIdBase(e),n=0;;n++){var r=t;if(0')},createChildNavList:function(e){var t=this.createNavList();return e.append(t),t},generateNavEl:function(e,t){var n=a('');n.attr("href","#"+e),n.text(t);var r=a("
  • ");return r.append(n),r},generateNavItem:function(e){var t=this.generateAnchor(e),n=a(e),r=n.data("toc-text")||n.text();return this.generateNavEl(t,r)},getTopLevel:function(e){for(var t=1;t<=6;t++){if(1 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.4.2/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.4.2/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.4.2/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.4.2/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.4.2/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.4.2/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-v4compatibility.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.4.2/webfonts/fa-v4compatibility.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-v4compatibility.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.4.2/webfonts/fa-v4compatibility.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 -------------------------------------------------------------------------------- /docs/deps/headroom-0.11.0/headroom.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * headroom.js v0.11.0 - Give your page some headroom. Hide your header until you need it 3 | * Copyright (c) 2020 Nick Williams - http://wicky.nillia.ms/headroom.js 4 | * License: MIT 5 | */ 6 | 7 | !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).Headroom=n()}(this,function(){"use strict";function t(){return"undefined"!=typeof window}function d(t){return function(t){return t&&t.document&&function(t){return 9===t.nodeType}(t.document)}(t)?function(t){var n=t.document,o=n.body,s=n.documentElement;return{scrollHeight:function(){return Math.max(o.scrollHeight,s.scrollHeight,o.offsetHeight,s.offsetHeight,o.clientHeight,s.clientHeight)},height:function(){return t.innerHeight||s.clientHeight||o.clientHeight},scrollY:function(){return void 0!==t.pageYOffset?t.pageYOffset:(s||o.parentNode||o).scrollTop}}}(t):function(t){return{scrollHeight:function(){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},height:function(){return Math.max(t.offsetHeight,t.clientHeight)},scrollY:function(){return t.scrollTop}}}(t)}function n(t,s,e){var n,o=function(){var n=!1;try{var t={get passive(){n=!0}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){n=!1}return n}(),i=!1,r=d(t),l=r.scrollY(),a={};function c(){var t=Math.round(r.scrollY()),n=r.height(),o=r.scrollHeight();a.scrollY=t,a.lastScrollY=l,a.direction=ls.tolerance[a.direction],e(a),l=t,i=!1}function h(){i||(i=!0,n=requestAnimationFrame(c))}var u=!!o&&{passive:!0,capture:!1};return t.addEventListener("scroll",h,u),c(),{destroy:function(){cancelAnimationFrame(n),t.removeEventListener("scroll",h,u)}}}function o(t,n){n=n||{},Object.assign(this,o.options,n),this.classes=Object.assign({},o.options.classes,n.classes),this.elem=t,this.tolerance=function(t){return t===Object(t)?t:{down:t,up:t}}(this.tolerance),this.initialised=!1,this.frozen=!1}return o.prototype={constructor:o,init:function(){return o.cutsTheMustard&&!this.initialised&&(this.addClass("initial"),this.initialised=!0,setTimeout(function(t){t.scrollTracker=n(t.scroller,{offset:t.offset,tolerance:t.tolerance},t.update.bind(t))},100,this)),this},destroy:function(){this.initialised=!1,Object.keys(this.classes).forEach(this.removeClass,this),this.scrollTracker.destroy()},unpin:function(){!this.hasClass("pinned")&&this.hasClass("unpinned")||(this.addClass("unpinned"),this.removeClass("pinned"),this.onUnpin&&this.onUnpin.call(this))},pin:function(){this.hasClass("unpinned")&&(this.addClass("pinned"),this.removeClass("unpinned"),this.onPin&&this.onPin.call(this))},freeze:function(){this.frozen=!0,this.addClass("frozen")},unfreeze:function(){this.frozen=!1,this.removeClass("frozen")},top:function(){this.hasClass("top")||(this.addClass("top"),this.removeClass("notTop"),this.onTop&&this.onTop.call(this))},notTop:function(){this.hasClass("notTop")||(this.addClass("notTop"),this.removeClass("top"),this.onNotTop&&this.onNotTop.call(this))},bottom:function(){this.hasClass("bottom")||(this.addClass("bottom"),this.removeClass("notBottom"),this.onBottom&&this.onBottom.call(this))},notBottom:function(){this.hasClass("notBottom")||(this.addClass("notBottom"),this.removeClass("bottom"),this.onNotBottom&&this.onNotBottom.call(this))},shouldUnpin:function(t){return"down"===t.direction&&!t.top&&t.toleranceExceeded},shouldPin:function(t){return"up"===t.direction&&t.toleranceExceeded||t.top},addClass:function(t){this.elem.classList.add.apply(this.elem.classList,this.classes[t].split(" "))},removeClass:function(t){this.elem.classList.remove.apply(this.elem.classList,this.classes[t].split(" "))},hasClass:function(t){return this.classes[t].split(" ").every(function(t){return this.classList.contains(t)},this.elem)},update:function(t){t.isOutOfBounds||!0!==this.frozen&&(t.top?this.top():this.notTop(),t.bottom?this.bottom():this.notBottom(),this.shouldUnpin(t)?this.unpin():this.shouldPin(t)&&this.pin())}},o.options={tolerance:{up:0,down:0},offset:0,scroller:t()?window:null,classes:{frozen:"headroom--frozen",pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},o.cutsTheMustard=!!(t()&&function(){}.bind&&"classList"in document.documentElement&&Object.assign&&Object.keys&&requestAnimationFrame),o}); -------------------------------------------------------------------------------- /docs/deps/headroom-0.11.0/jQuery.headroom.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * headroom.js v0.9.4 - Give your page some headroom. Hide your header until you need it 3 | * Copyright (c) 2017 Nick Williams - http://wicky.nillia.ms/headroom.js 4 | * License: MIT 5 | */ 6 | 7 | !function(a){a&&(a.fn.headroom=function(b){return this.each(function(){var c=a(this),d=c.data("headroom"),e="object"==typeof b&&b;e=a.extend(!0,{},Headroom.options,e),d||(d=new Headroom(this,e),d.init(),c.data("headroom",d)),"string"==typeof b&&(d[b](),"destroy"===b&&c.removeData("headroom"))})},a("[data-headroom]").each(function(){var b=a(this);b.headroom(b.data())}))}(window.Zepto||window.jQuery); -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/katex-auto.js: -------------------------------------------------------------------------------- 1 | // https://github.com/jgm/pandoc/blob/29fa97ab96b8e2d62d48326e1b949a71dc41f47a/src/Text/Pandoc/Writers/HTML.hs#L332-L345 2 | document.addEventListener("DOMContentLoaded", function () { 3 | var mathElements = document.getElementsByClassName("math"); 4 | var macros = []; 5 | for (var i = 0; i < mathElements.length; i++) { 6 | var texText = mathElements[i].firstChild; 7 | if (mathElements[i].tagName == "SPAN") { 8 | katex.render(texText.data, mathElements[i], { 9 | displayMode: mathElements[i].classList.contains("display"), 10 | throwOnError: false, 11 | macros: macros, 12 | fleqn: false 13 | }); 14 | }}}); 15 | -------------------------------------------------------------------------------- /docs/lightswitch.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/) 4 | * Copyright 2011-2023 The Bootstrap Authors 5 | * Licensed under the Creative Commons Attribution 3.0 Unported License. 6 | * Updates for {pkgdown} by the {bslib} authors, also licensed under CC-BY-3.0. 7 | */ 8 | 9 | const getStoredTheme = () => localStorage.getItem('theme') 10 | const setStoredTheme = theme => localStorage.setItem('theme', theme) 11 | 12 | const getPreferredTheme = () => { 13 | const storedTheme = getStoredTheme() 14 | if (storedTheme) { 15 | return storedTheme 16 | } 17 | 18 | return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' 19 | } 20 | 21 | const setTheme = theme => { 22 | if (theme === 'auto') { 23 | document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) 24 | } else { 25 | document.documentElement.setAttribute('data-bs-theme', theme) 26 | } 27 | } 28 | 29 | function bsSetupThemeToggle () { 30 | 'use strict' 31 | 32 | const showActiveTheme = (theme, focus = false) => { 33 | var activeLabel, activeIcon; 34 | 35 | document.querySelectorAll('[data-bs-theme-value]').forEach(element => { 36 | const buttonTheme = element.getAttribute('data-bs-theme-value') 37 | const isActive = buttonTheme == theme 38 | 39 | element.classList.toggle('active', isActive) 40 | element.setAttribute('aria-pressed', isActive) 41 | 42 | if (isActive) { 43 | activeLabel = element.textContent; 44 | activeIcon = element.querySelector('span').classList.value; 45 | } 46 | }) 47 | 48 | const themeSwitcher = document.querySelector('#dropdown-lightswitch') 49 | if (!themeSwitcher) { 50 | return 51 | } 52 | 53 | themeSwitcher.setAttribute('aria-label', activeLabel) 54 | themeSwitcher.querySelector('span').classList.value = activeIcon; 55 | 56 | if (focus) { 57 | themeSwitcher.focus() 58 | } 59 | } 60 | 61 | window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { 62 | const storedTheme = getStoredTheme() 63 | if (storedTheme !== 'light' && storedTheme !== 'dark') { 64 | setTheme(getPreferredTheme()) 65 | } 66 | }) 67 | 68 | window.addEventListener('DOMContentLoaded', () => { 69 | showActiveTheme(getPreferredTheme()) 70 | 71 | document 72 | .querySelectorAll('[data-bs-theme-value]') 73 | .forEach(toggle => { 74 | toggle.addEventListener('click', () => { 75 | const theme = toggle.getAttribute('data-bs-theme-value') 76 | setTheme(theme) 77 | setStoredTheme(theme) 78 | showActiveTheme(theme, true) 79 | }) 80 | }) 81 | }) 82 | } 83 | 84 | setTheme(getPreferredTheme()); 85 | bsSetupThemeToggle(); 86 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/pkgdown.css: -------------------------------------------------------------------------------- 1 | /* Sticky footer */ 2 | 3 | /** 4 | * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ 5 | * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css 6 | * 7 | * .Site -> body > .container 8 | * .Site-content -> body > .container .row 9 | * .footer -> footer 10 | * 11 | * Key idea seems to be to ensure that .container and __all its parents__ 12 | * have height set to 100% 13 | * 14 | */ 15 | 16 | html, body { 17 | height: 100%; 18 | } 19 | 20 | body { 21 | position: relative; 22 | } 23 | 24 | body > .container { 25 | display: flex; 26 | height: 100%; 27 | flex-direction: column; 28 | } 29 | 30 | body > .container .row { 31 | flex: 1 0 auto; 32 | } 33 | 34 | footer { 35 | margin-top: 45px; 36 | padding: 35px 0 36px; 37 | border-top: 1px solid #e5e5e5; 38 | color: #666; 39 | display: flex; 40 | flex-shrink: 0; 41 | } 42 | footer p { 43 | margin-bottom: 0; 44 | } 45 | footer div { 46 | flex: 1; 47 | } 48 | footer .pkgdown { 49 | text-align: right; 50 | } 51 | footer p { 52 | margin-bottom: 0; 53 | } 54 | 55 | img.icon { 56 | float: right; 57 | } 58 | 59 | /* Ensure in-page images don't run outside their container */ 60 | .contents img { 61 | max-width: 100%; 62 | height: auto; 63 | } 64 | 65 | /* Fix bug in bootstrap (only seen in firefox) */ 66 | summary { 67 | display: list-item; 68 | } 69 | 70 | /* Typographic tweaking ---------------------------------*/ 71 | 72 | .contents .page-header { 73 | margin-top: calc(-60px + 1em); 74 | } 75 | 76 | dd { 77 | margin-left: 3em; 78 | } 79 | 80 | /* Section anchors ---------------------------------*/ 81 | 82 | a.anchor { 83 | display: none; 84 | margin-left: 5px; 85 | width: 20px; 86 | height: 20px; 87 | 88 | background-image: url(./link.svg); 89 | background-repeat: no-repeat; 90 | background-size: 20px 20px; 91 | background-position: center center; 92 | } 93 | 94 | h1:hover .anchor, 95 | h2:hover .anchor, 96 | h3:hover .anchor, 97 | h4:hover .anchor, 98 | h5:hover .anchor, 99 | h6:hover .anchor { 100 | display: inline-block; 101 | } 102 | 103 | /* Fixes for fixed navbar --------------------------*/ 104 | 105 | .contents h1, .contents h2, .contents h3, .contents h4 { 106 | padding-top: 60px; 107 | margin-top: -40px; 108 | } 109 | 110 | /* Navbar submenu --------------------------*/ 111 | 112 | .dropdown-submenu { 113 | position: relative; 114 | } 115 | 116 | .dropdown-submenu>.dropdown-menu { 117 | top: 0; 118 | left: 100%; 119 | margin-top: -6px; 120 | margin-left: -1px; 121 | border-radius: 0 6px 6px 6px; 122 | } 123 | 124 | .dropdown-submenu:hover>.dropdown-menu { 125 | display: block; 126 | } 127 | 128 | .dropdown-submenu>a:after { 129 | display: block; 130 | content: " "; 131 | float: right; 132 | width: 0; 133 | height: 0; 134 | border-color: transparent; 135 | border-style: solid; 136 | border-width: 5px 0 5px 5px; 137 | border-left-color: #cccccc; 138 | margin-top: 5px; 139 | margin-right: -10px; 140 | } 141 | 142 | .dropdown-submenu:hover>a:after { 143 | border-left-color: #ffffff; 144 | } 145 | 146 | .dropdown-submenu.pull-left { 147 | float: none; 148 | } 149 | 150 | .dropdown-submenu.pull-left>.dropdown-menu { 151 | left: -100%; 152 | margin-left: 10px; 153 | border-radius: 6px 0 6px 6px; 154 | } 155 | 156 | /* Sidebar --------------------------*/ 157 | 158 | #pkgdown-sidebar { 159 | margin-top: 30px; 160 | position: -webkit-sticky; 161 | position: sticky; 162 | top: 70px; 163 | } 164 | 165 | #pkgdown-sidebar h2 { 166 | font-size: 1.5em; 167 | margin-top: 1em; 168 | } 169 | 170 | #pkgdown-sidebar h2:first-child { 171 | margin-top: 0; 172 | } 173 | 174 | #pkgdown-sidebar .list-unstyled li { 175 | margin-bottom: 0.5em; 176 | } 177 | 178 | /* bootstrap-toc tweaks ------------------------------------------------------*/ 179 | 180 | /* All levels of nav */ 181 | 182 | nav[data-toggle='toc'] .nav > li > a { 183 | padding: 4px 20px 4px 6px; 184 | font-size: 1.5rem; 185 | font-weight: 400; 186 | color: inherit; 187 | } 188 | 189 | nav[data-toggle='toc'] .nav > li > a:hover, 190 | nav[data-toggle='toc'] .nav > li > a:focus { 191 | padding-left: 5px; 192 | color: inherit; 193 | border-left: 1px solid #878787; 194 | } 195 | 196 | nav[data-toggle='toc'] .nav > .active > a, 197 | nav[data-toggle='toc'] .nav > .active:hover > a, 198 | nav[data-toggle='toc'] .nav > .active:focus > a { 199 | padding-left: 5px; 200 | font-size: 1.5rem; 201 | font-weight: 400; 202 | color: inherit; 203 | border-left: 2px solid #878787; 204 | } 205 | 206 | /* Nav: second level (shown on .active) */ 207 | 208 | nav[data-toggle='toc'] .nav .nav { 209 | display: none; /* Hide by default, but at >768px, show it */ 210 | padding-bottom: 10px; 211 | } 212 | 213 | nav[data-toggle='toc'] .nav .nav > li > a { 214 | padding-left: 16px; 215 | font-size: 1.35rem; 216 | } 217 | 218 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 219 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 220 | padding-left: 15px; 221 | } 222 | 223 | nav[data-toggle='toc'] .nav .nav > .active > a, 224 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 225 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 226 | padding-left: 15px; 227 | font-weight: 500; 228 | font-size: 1.35rem; 229 | } 230 | 231 | /* orcid ------------------------------------------------------------------- */ 232 | 233 | .orcid { 234 | font-size: 16px; 235 | color: #A6CE39; 236 | /* margins are required by official ORCID trademark and display guidelines */ 237 | margin-left:4px; 238 | margin-right:4px; 239 | vertical-align: middle; 240 | } 241 | 242 | /* Reference index & topics ----------------------------------------------- */ 243 | 244 | .ref-index th {font-weight: normal;} 245 | 246 | .ref-index td {vertical-align: top; min-width: 100px} 247 | .ref-index .icon {width: 40px;} 248 | .ref-index .alias {width: 40%;} 249 | .ref-index-icons .alias {width: calc(40% - 40px);} 250 | .ref-index .title {width: 60%;} 251 | 252 | .ref-arguments th {text-align: right; padding-right: 10px;} 253 | .ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} 254 | .ref-arguments .name {width: 20%;} 255 | .ref-arguments .desc {width: 80%;} 256 | 257 | /* Nice scrolling for wide elements --------------------------------------- */ 258 | 259 | table { 260 | display: block; 261 | overflow: auto; 262 | } 263 | 264 | /* Syntax highlighting ---------------------------------------------------- */ 265 | 266 | pre, code, pre code { 267 | background-color: #f8f8f8; 268 | color: #333; 269 | } 270 | pre, pre code { 271 | white-space: pre-wrap; 272 | word-break: break-all; 273 | overflow-wrap: break-word; 274 | } 275 | 276 | pre { 277 | border: 1px solid #eee; 278 | } 279 | 280 | pre .img, pre .r-plt { 281 | margin: 5px 0; 282 | } 283 | 284 | pre .img img, pre .r-plt img { 285 | background-color: #fff; 286 | } 287 | 288 | code a, pre a { 289 | color: #375f84; 290 | } 291 | 292 | a.sourceLine:hover { 293 | text-decoration: none; 294 | } 295 | 296 | .fl {color: #1514b5;} 297 | .fu {color: #000000;} /* function */ 298 | .ch,.st {color: #036a07;} /* string */ 299 | .kw {color: #264D66;} /* keyword */ 300 | .co {color: #888888;} /* comment */ 301 | 302 | .error {font-weight: bolder;} 303 | .warning {font-weight: bolder;} 304 | 305 | /* Clipboard --------------------------*/ 306 | 307 | .hasCopyButton { 308 | position: relative; 309 | } 310 | 311 | .btn-copy-ex { 312 | position: absolute; 313 | right: 0; 314 | top: 0; 315 | visibility: hidden; 316 | } 317 | 318 | .hasCopyButton:hover button.btn-copy-ex { 319 | visibility: visible; 320 | } 321 | 322 | /* headroom.js ------------------------ */ 323 | 324 | .headroom { 325 | will-change: transform; 326 | transition: transform 200ms linear; 327 | } 328 | .headroom--pinned { 329 | transform: translateY(0%); 330 | } 331 | .headroom--unpinned { 332 | transform: translateY(-100%); 333 | } 334 | 335 | /* mark.js ----------------------------*/ 336 | 337 | mark { 338 | background-color: rgba(255, 255, 51, 0.5); 339 | border-bottom: 2px solid rgba(255, 153, 51, 0.3); 340 | padding: 1px; 341 | } 342 | 343 | /* vertical spacing after htmlwidgets */ 344 | .html-widget { 345 | margin-bottom: 10px; 346 | } 347 | 348 | /* fontawesome ------------------------ */ 349 | 350 | .fab { 351 | font-family: "Font Awesome 5 Brands" !important; 352 | } 353 | 354 | /* don't display links in code chunks when printing */ 355 | /* source: https://stackoverflow.com/a/10781533 */ 356 | @media print { 357 | code a:link:after, code a:visited:after { 358 | content: ""; 359 | } 360 | } 361 | 362 | /* Section anchors --------------------------------- 363 | Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 364 | */ 365 | 366 | div.csl-bib-body { } 367 | div.csl-entry { 368 | clear: both; 369 | } 370 | .hanging-indent div.csl-entry { 371 | margin-left:2em; 372 | text-indent:-2em; 373 | } 374 | div.csl-left-margin { 375 | min-width:2em; 376 | float:left; 377 | } 378 | div.csl-right-inline { 379 | margin-left:2em; 380 | padding-left:1em; 381 | } 382 | div.csl-indent { 383 | margin-left: 2em; 384 | } 385 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('nav.navbar').headroom(); 6 | 7 | Toc.init({ 8 | $nav: $("#toc"), 9 | $scope: $("main h2, main h3, main h4, main h5, main h6") 10 | }); 11 | 12 | if ($('#toc').length) { 13 | $('body').scrollspy({ 14 | target: '#toc', 15 | offset: $("nav.navbar").outerHeight() + 1 16 | }); 17 | } 18 | 19 | // Activate popovers 20 | $('[data-bs-toggle="popover"]').popover({ 21 | container: 'body', 22 | html: true, 23 | trigger: 'focus', 24 | placement: "top", 25 | sanitize: false, 26 | }); 27 | 28 | $('[data-bs-toggle="tooltip"]').tooltip(); 29 | 30 | /* Clipboard --------------------------*/ 31 | 32 | function changeTooltipMessage(element, msg) { 33 | var tooltipOriginalTitle=element.getAttribute('data-bs-original-title'); 34 | element.setAttribute('data-bs-original-title', msg); 35 | $(element).tooltip('show'); 36 | element.setAttribute('data-bs-original-title', tooltipOriginalTitle); 37 | } 38 | 39 | if(ClipboardJS.isSupported()) { 40 | $(document).ready(function() { 41 | var copyButton = ""; 42 | 43 | $("div.sourceCode").addClass("hasCopyButton"); 44 | 45 | // Insert copy buttons: 46 | $(copyButton).prependTo(".hasCopyButton"); 47 | 48 | // Initialize tooltips: 49 | $('.btn-copy-ex').tooltip({container: 'body'}); 50 | 51 | // Initialize clipboard: 52 | var clipboard = new ClipboardJS('[data-clipboard-copy]', { 53 | text: function(trigger) { 54 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 55 | } 56 | }); 57 | 58 | clipboard.on('success', function(e) { 59 | changeTooltipMessage(e.trigger, 'Copied!'); 60 | e.clearSelection(); 61 | }); 62 | 63 | clipboard.on('error', function(e) { 64 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 65 | }); 66 | 67 | }); 68 | } 69 | 70 | /* Search marking --------------------------*/ 71 | var url = new URL(window.location.href); 72 | var toMark = url.searchParams.get("q"); 73 | var mark = new Mark("main#main"); 74 | if (toMark) { 75 | mark.mark(toMark, { 76 | accuracy: { 77 | value: "complementary", 78 | limiters: [",", ".", ":", "/"], 79 | } 80 | }); 81 | } 82 | 83 | /* Search --------------------------*/ 84 | /* Adapted from https://github.com/rstudio/bookdown/blob/2d692ba4b61f1e466c92e78fd712b0ab08c11d31/inst/resources/bs4_book/bs4_book.js#L25 */ 85 | // Initialise search index on focus 86 | var fuse; 87 | $("#search-input").focus(async function(e) { 88 | if (fuse) { 89 | return; 90 | } 91 | 92 | $(e.target).addClass("loading"); 93 | var response = await fetch($("#search-input").data("search-index")); 94 | var data = await response.json(); 95 | 96 | var options = { 97 | keys: ["what", "text", "code"], 98 | ignoreLocation: true, 99 | threshold: 0.1, 100 | includeMatches: true, 101 | includeScore: true, 102 | }; 103 | fuse = new Fuse(data, options); 104 | 105 | $(e.target).removeClass("loading"); 106 | }); 107 | 108 | // Use algolia autocomplete 109 | var options = { 110 | autoselect: true, 111 | debug: true, 112 | hint: false, 113 | minLength: 2, 114 | }; 115 | var q; 116 | async function searchFuse(query, callback) { 117 | await fuse; 118 | 119 | var items; 120 | if (!fuse) { 121 | items = []; 122 | } else { 123 | q = query; 124 | var results = fuse.search(query, { limit: 20 }); 125 | items = results 126 | .filter((x) => x.score <= 0.75) 127 | .map((x) => x.item); 128 | if (items.length === 0) { 129 | items = [{dir:"Sorry 😿",previous_headings:"",title:"No results found.",what:"No results found.",path:window.location.href}]; 130 | } 131 | } 132 | callback(items); 133 | } 134 | $("#search-input").autocomplete(options, [ 135 | { 136 | name: "content", 137 | source: searchFuse, 138 | templates: { 139 | suggestion: (s) => { 140 | if (s.title == s.what) { 141 | return `${s.dir} >
    ${s.title}
    `; 142 | } else if (s.previous_headings == "") { 143 | return `${s.dir} >
    ${s.title}
    > ${s.what}`; 144 | } else { 145 | return `${s.dir} >
    ${s.title}
    > ${s.previous_headings} > ${s.what}`; 146 | } 147 | }, 148 | }, 149 | }, 150 | ]).on('autocomplete:selected', function(event, s) { 151 | window.location.href = s.path + "?q=" + q + "#" + s.id; 152 | }); 153 | }); 154 | })(window.jQuery || window.$) 155 | 156 | document.addEventListener('keydown', function(event) { 157 | // Check if the pressed key is '/' 158 | if (event.key === '/') { 159 | event.preventDefault(); // Prevent any default action associated with the '/' key 160 | document.getElementById('search-input').focus(); // Set focus to the search input 161 | } 162 | }); 163 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 3.1.11.1 2 | pkgdown: 2.1.1 3 | pkgdown_sha: ~ 4 | articles: 5 | coerce: coerce.html 6 | use: use.html 7 | last_built: 2025-01-03T14:04Z 8 | urls: 9 | reference: https://osgeo.github.io/rgrass/reference 10 | article: https://osgeo.github.io/rgrass/articles 11 | -------------------------------------------------------------------------------- /docs/reference/doGRASS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get.GIS_LOCK.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get.defaultFlagsOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get.echoCmdOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get.ignore.stderrOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get.legacyExecOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get.stop_on_no_flags_parasOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get.suppressEchoCmdInFuncOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get.useInternOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/getLocationProj.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/getXMLencoding.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/gmeta2grd.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | Package index • rgrass 3 | Skip to contents 4 | 5 | 6 |
    33 |
    34 |
    38 | 39 |
    40 |

    All functions

    41 | 42 | 43 | 44 | 45 |
    81 |
    82 | 83 | 84 |
    87 | 88 | 91 | 92 |
    93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /docs/reference/parseGRASS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/print.GRASS_interface_desc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/print.gmeta.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/read_RAST-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/docs/reference/read_RAST-1.png -------------------------------------------------------------------------------- /docs/reference/remove_GISRC.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/rgrass-package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/rgrass.html: -------------------------------------------------------------------------------- 1 | 2 | rgrass: Interface between GRASS geographical information system and R — rgrass • rgrass 11 | Skip to contents 12 | 13 | 14 |
    41 |
    42 |
    48 | 49 |
    50 |

    Interpreted interface between GRASS geographical information 51 | system, versions 7 and 8, and R, based on starting R from within the GRASS 52 | environment, or on running R stand-alone and creating a throw-away GRASS 53 | environment from within R. The interface uses classes defined in the sp 54 | package to hold spatial data.

    55 |
    56 | 57 | 58 |
    59 |

    Details

    60 |

    Index:

    61 |
    
     62 | read_RAST              read GRASS raster files
     63 | write_RAST             write GRASS raster files
     64 | read_VECT              read GRASS vector object files
     65 | write_VECT             write GRASS vector object files
     66 | gmeta                  read GRASS metadata from the current LOCATION
     67 | getLocationProj        return a WKT2 string of projection information
     68 | gmeta2grd              create a GridTopology object from the GRASS region
     69 | vInfo                  return vector geometry information
     70 | vColumns               return vector database columns information
     71 | vDataCount             return count of vector database rows
     72 | vect2neigh             return area neighbours with shared boundary length
     73 | 
    74 | 75 |

    Note that the examples now use the smaller subset North Carolina location: 76 | https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.tar.gz

    77 |
    78 | 87 |
    88 |

    Author

    89 |

    Maintainer: Steven Pawley dr.stevenpawley@gmail.com (ORCID)

    90 |

    Authors:

    Other contributors:

    97 | 98 |
    100 | 101 | 102 |
    105 | 106 | 109 | 110 |
    111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /docs/reference/set.GIS_LOCK.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/set.defaultFlagsOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/set.echoCmdOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/set.ignore.stderrOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/set.legacyExecOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/set.stop_on_no_flags_parasOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/set.suppressEchoCmdInFuncOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/set.useInternOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/setXMLencoding.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/stringexecGRASS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/unlink_.gislock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/unset.GIS_LOCK.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/vColumns.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/vDataCount.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/vInfo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/vect2neigh.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/write_RAST.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/write_VECT.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | https://osgeo.github.io/rgrass/404.html 3 | https://osgeo.github.io/rgrass/CONTRIBUTING.html 4 | https://osgeo.github.io/rgrass/articles/coerce.html 5 | https://osgeo.github.io/rgrass/articles/index.html 6 | https://osgeo.github.io/rgrass/articles/use.html 7 | https://osgeo.github.io/rgrass/authors.html 8 | https://osgeo.github.io/rgrass/index.html 9 | https://osgeo.github.io/rgrass/news/index.html 10 | https://osgeo.github.io/rgrass/reference/execGRASS.html 11 | https://osgeo.github.io/rgrass/reference/gmeta.html 12 | https://osgeo.github.io/rgrass/reference/index.html 13 | https://osgeo.github.io/rgrass/reference/initGRASS.html 14 | https://osgeo.github.io/rgrass/reference/read_RAST.html 15 | https://osgeo.github.io/rgrass/reference/read_VECT.html 16 | https://osgeo.github.io/rgrass/reference/rgrass.html 17 | 18 | 19 | -------------------------------------------------------------------------------- /inst/etc/XML.r.out.gdal.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/inst/etc/XML.r.out.gdal.rds -------------------------------------------------------------------------------- /inst/etc/res_r.water.outlet.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/inst/etc/res_r.water.outlet.rds -------------------------------------------------------------------------------- /inst/pre_git_ChangeLog: -------------------------------------------------------------------------------- 1 | 2018-11-23 08:42 rsbivand 2 | 3 | * DESCRIPTION, R/initGRASS.R, man/initGRASS.Rd: test gisBase for 4 | bin and scripts 5 | 6 | 2018-09-28 07:42 rsbivand 7 | 8 | * ChangeLog, inst/ChangeLog: tidy 9 | 10 | 2018-09-24 08:40 rsbivand 11 | 12 | * ChangeLog, inst/ChangeLog: trial updates for OSGEO4W 13 | 14 | 2018-09-24 08:39 rsbivand 15 | 16 | * DESCRIPTION, R/initGRASS.R, man/rgrass.Rd: trial updates for 17 | OSGEO4W 18 | 19 | 2017-10-20 19:02 rsbivand 20 | 21 | * DESCRIPTION, R/vect_link.R: fix SQLite writeVECT issue 22 | 23 | 2017-10-12 10:37 rsbivand 24 | 25 | * DESCRIPTION, R/vect_link.R: OGR drivers Markus Metz fix 26 | 27 | 2017-10-11 11:21 rsbivand 28 | 29 | * DESCRIPTION, R/vect_link.R: readVECT driver 7.3 bug resolved 30 | 31 | 2016-11-18 14:18 rsbivand 32 | 33 | * DESCRIPTION, R/xml1.R: tidy 34 | 35 | 2016-05-09 14:39 rsbivand 36 | 37 | * ChangeLog, inst/ChangeLog: tidy 38 | 39 | 2016-05-09 14:38 rsbivand 40 | 41 | * DESCRIPTION: tidy 42 | 43 | 2016-04-25 08:07 rsbivand 44 | 45 | * DESCRIPTION, NAMESPACE, R/AAA.R, R/initGRASS.R, R/vect_link.R, 46 | man/initGRASS.Rd: tidy 47 | 48 | 2016-04-11 12:13 rsbivand 49 | 50 | * ChangeLog, inst/ChangeLog: tidy 51 | 52 | 2016-04-11 12:12 rsbivand 53 | 54 | * DESCRIPTION, R/xml1.R: WinNat *.bat issue 55 | 56 | 2016-01-13 11:52 rsbivand 57 | 58 | * R/initGRASS.R, man/initGRASS.Rd: addon in initGRASS 59 | 60 | 2016-01-13 08:47 rsbivand 61 | 62 | * DESCRIPTION: fix addons in initGRASS 63 | 64 | 2016-01-12 19:17 rsbivand 65 | 66 | * ChangeLog, inst/ChangeLog: tidy 67 | 68 | 2016-01-12 19:10 rsbivand 69 | 70 | * R/vect_link.R: fix Windows file transfer issue 71 | 72 | 2016-01-12 14:09 rsbivand 73 | 74 | * R/xml1.R: addon bat files fix 75 | 76 | 2016-01-11 14:07 rsbivand 77 | 78 | * ChangeLog, R/vect_link.R: vector layer tidy 79 | 80 | 2016-01-11 13:51 rsbivand 81 | 82 | * DESCRIPTION, R/AAA.R, R/rgrass.R, R/xml1.R: attempt to make 83 | addons visible under Windows 84 | 85 | 2015-10-11 18:38 rsbivand 86 | 87 | * R/vect_link.R: Windows rgdal drivers issue 88 | 89 | 2015-10-11 18:32 rsbivand 90 | 91 | * R/vect_link.R: Windows rgdal drivers issue 92 | 93 | 2015-10-11 13:48 rsbivand 94 | 95 | * R/vect_link.R: Windows rgdal drivers issue 96 | 97 | 2015-10-08 21:27 rsbivand 98 | 99 | * DESCRIPTION, R/vect_link.R: Windows rgdal drivers issue 100 | 101 | 2015-09-25 09:02 rsbivand 102 | 103 | * NAMESPACE: importFrom(methods, slot, 'slot<-', as) 104 | 105 | 2015-08-23 18:39 rsbivand 106 | 107 | * inst, inst/ChangeLog: tidy 108 | 109 | 2015-08-23 18:38 rsbivand 110 | 111 | * ChangeLog: tidy 112 | 113 | 2015-08-23 18:36 rsbivand 114 | 115 | * DESCRIPTION, NAMESPACE, R/bin_link.R, R/vect_link.R, 116 | man/readVECT.Rd: adding long field names for vectors 117 | 118 | 2015-08-17 19:03 rsbivand 119 | 120 | * DESCRIPTION, R/vect_link.R, man/readVECT.Rd: fix to vect2neigh 121 | 122 | 2015-06-28 20:56 rsbivand 123 | 124 | * DESCRIPTION, NAMESPACE: CRAN 125 | _R_CHECK_CODE_USAGE_WITH_ONLY_BASE_ATTACHED_=true NAMESPACE tidy 126 | 127 | 2015-06-18 16:31 rkrug 128 | 129 | * R/bin_link.R, R/vect_link.R: Fixed missing mapset in 130 | .read_vect_plugin and .read_rast_plugin 131 | 132 | Thanks to Ahmadou H. DICKO 133 | 134 | 2015-06-18 10:28 neteler 135 | 136 | * ChangeLog, DESCRIPTION, R/vect_link.R: rgrass7: R/vect_link.R: 137 | fix for drivers other that ESRI Shapefile 138 | 139 | 2015-05-20 18:20 rsbivand 140 | 141 | * R/xml1.R: check all integer matches 142 | 143 | 2015-03-10 20:14 rsbivand 144 | 145 | * ChangeLog: tidy 146 | 147 | 2015-03-10 20:10 rsbivand 148 | 149 | * DESCRIPTION, inst: tidy 150 | 151 | 2015-03-10 20:02 rsbivand 152 | 153 | * man/readRAST.Rd: examples migrated to nc_basic 154 | 155 | 2015-03-10 19:50 rsbivand 156 | 157 | * man/execGRASS.Rd, man/gmeta.Rd, man/readRAST.Rd, man/readVECT.Rd, 158 | man/rgrass.Rd: examples migrated to nc_basic 159 | 160 | 2015-03-10 18:54 rsbivand 161 | 162 | * DESCRIPTION: tidy 163 | 164 | 2015-03-10 14:21 rsbivand 165 | 166 | * R/bin_link.R, man/execGRASS.Rd, man/initGRASS.Rd, 167 | man/readRAST.Rd, man/readVECT.Rd, man/rgrass.Rd: examples 168 | migrated to nc_basic 169 | 170 | 2015-02-19 20:16 rsbivand 171 | 172 | * ., DESCRIPTION, R/rgrass.R, R/spgrass.R, man/rgrass.Rd, 173 | man/spgrass.Rd: change name to rgrass7 174 | 175 | 2015-01-31 13:36 rsbivand 176 | 177 | * tidy 178 | 179 | 2015-01-29 18:18 rsbivand 180 | 181 | * tidy 182 | 183 | 2015-01-29 13:21 rkrug 184 | 185 | * Introduced several tryCatch() to delete files after error 186 | 187 | * based on 188 | http://permalink.gmane.org/gmane.comp.gis.grass.stats/26 189 | similar potential problems were identified and code encapsulated 190 | in 191 | tryCatch blocks. 192 | 193 | 2015-01-29 12:43 rkrug 194 | 195 | * Fixed Bug 196 | http://permalink.gmane.org/gmane.comp.gis.grass.stats/26 197 | 198 | * temporary files were not deleted upon error. 199 | Wrapped tryCatch block around code. 200 | 201 | 2015-01-28 14:16 rkrug 202 | 203 | * Added blocing for spgrass6 and spgrass7 unless correct GRASS GIS 204 | version used 205 | 206 | * spgrass6, spgrass: added two internal functions: 207 | .grassVersion(): returns GRASS GIS version used 208 | .compatibleGRASSVersion(gv=.grassVersion()): returns TRUE if 209 | GRASS GIS version 210 | is compatible, FALSE if not. As an attribute, it returns an error 211 | / status 212 | message which can be printed. 213 | 214 | * spgrass6/AAA.R, spgrass7/AAA.R: added check for 215 | .compatibleGRASSVersion() in .onAttach() 216 | which raises error if GRASS GIS version is not compatible. The 217 | result is that the 218 | package can not be loaded in R when running in an incompatible 219 | GRASS GIS version. 220 | 221 | * spgrass6/initGRASS.R, spgrass7/initGRASS.R: added check for 222 | .compatibleGRASSVersion() 223 | which raises error if GRASS GIS version is not compatible and 224 | aborts initGRASS(). 225 | 226 | 2015-01-27 13:05 rsbivand 227 | 228 | * update man pages arguments to match code (running R CMD check) 229 | 230 | 2015-01-27 12:21 rsbivand 231 | 232 | * change name from spgrass to spgrass7 233 | 234 | 2015-01-27 11:30 rkrug 235 | 236 | * Refactorng of code from readVect and writeVect 237 | 238 | * introduced internal functions .read_vect_plugin and 239 | .read_vect_non_plugin for actual reading and writing of vector 240 | * moved reading of options from code into default values 241 | (ignore.stderr, plugin, useGDAL) 242 | * wrapped code in tryCatch to reset echoCmdOption 243 | 244 | 2015-01-27 11:07 rkrug 245 | 246 | * Summary: Fixed renaming error and added . to internal functions 247 | 248 | * fixed renamin=g error of read_rast_... functions 249 | * added . to function names read_rast_plugin and 250 | .read_rast_non_plugin 251 | 252 | 2015-01-27 10:36 rkrug 253 | 254 | * Summary: Rename internal functions to implement 255 | 256 | * renamed 257 | read_plugin -->> read_rast_plugin 258 | read_bin -->> read_rast_nonplugin 259 | To have consistent naming scheme for reading vectors 260 | 261 | 2015-01-27 10:26 rkrug 262 | 263 | * Streamlining of code 264 | 265 | * readRAST, writeRAST: changed default values in function 266 | definitions 267 | of ignore.stderr, plugin and useGDAL from NULL to the values 268 | obtained by get....Option() 269 | 270 | * Moved closeAllConnections code outsude the try block to ensure 271 | that opened connections are closed 272 | 273 | 2015-01-27 10:00 rkrug 274 | 275 | * Summary: Setting of echoCmdOption fixed 276 | 277 | * readRAST: the resetting of echoCmdOption was only done if 278 | return_SGDF was TRUE. Moved resetting to end of function call and 279 | wrapped into tryCatch() block to reset echoCmdOOption even in 280 | case of error. 281 | 282 | * writeRAST: Wrapped into tryCatch() block to reset 283 | echoCmdOOption even in case of error. 284 | 285 | 2015-01-26 14:58 rkrug 286 | 287 | * Summary: Move reading of raster non-plugin into extra function 288 | 289 | * created new internal function read_bin() which reads the 290 | raster, equivalent to read_plugin() 291 | 292 | 2015-01-26 13:32 rkrug 293 | 294 | * Spring cleaning for GRASS GIS 7 295 | 296 | * remove references and code opnly used for grass 6 297 | * removed check for grass 7 298 | * changed name of .grassrc6 to .grassrc7 299 | 300 | 2015-01-20 11:50 neteler 301 | 302 | * manual update to G7 303 | 304 | 2015-01-18 20:04 rsbivand 305 | 306 | * adapt to G7 307 | 308 | 2015-01-15 18:12 rsbivand 309 | 310 | * adding development spgrass for 7 and future 311 | 312 | -------------------------------------------------------------------------------- /man/gmeta.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gmeta.R, R/options.R 3 | \name{gmeta} 4 | \alias{gmeta} 5 | \alias{getLocationProj} 6 | \alias{gmeta2grd} 7 | \alias{print.gmeta} 8 | \alias{get.ignore.stderrOption} 9 | \alias{get.stop_on_no_flags_parasOption} 10 | \alias{get.echoCmdOption} 11 | \alias{get.useInternOption} 12 | \alias{get.legacyExecOption} 13 | \alias{get.defaultFlagsOption} 14 | \alias{get.suppressEchoCmdInFuncOption} 15 | \alias{set.ignore.stderrOption} 16 | \alias{set.stop_on_no_flags_parasOption} 17 | \alias{set.echoCmdOption} 18 | \alias{set.useInternOption} 19 | \alias{set.legacyExecOption} 20 | \alias{set.defaultFlagsOption} 21 | \alias{set.suppressEchoCmdInFuncOption} 22 | \title{Reads GRASS metadata from the current LOCATION} 23 | \usage{ 24 | gmeta(ignore.stderr = FALSE, g.proj_WKT = NULL) 25 | 26 | getLocationProj(ignore.stderr = FALSE, g.proj_WKT = NULL) 27 | 28 | gmeta2grd(ignore.stderr = FALSE) 29 | 30 | \method{print}{gmeta}(x, ...) 31 | 32 | get.ignore.stderrOption() 33 | 34 | get.stop_on_no_flags_parasOption() 35 | 36 | get.echoCmdOption() 37 | 38 | get.useInternOption() 39 | 40 | get.legacyExecOption() 41 | 42 | get.defaultFlagsOption() 43 | 44 | get.suppressEchoCmdInFuncOption() 45 | 46 | set.ignore.stderrOption(value) 47 | 48 | set.stop_on_no_flags_parasOption(value) 49 | 50 | set.echoCmdOption(value) 51 | 52 | set.useInternOption(value) 53 | 54 | set.legacyExecOption(value) 55 | 56 | set.defaultFlagsOption(value) 57 | 58 | set.suppressEchoCmdInFuncOption(value) 59 | } 60 | \arguments{ 61 | \item{ignore.stderr}{default FALSE, can be set to TRUE to silence 62 | \code{system()} output to standard error; does not apply on Windows 63 | platforms.} 64 | 65 | \item{g.proj_WKT}{default NULL: return WKT2 representation in GRASS >= 7.6 66 | and Proj4 in GRASS < 7.6; may be set to FALSE to return Proj4 for GRASS >= 67 | 7.6.} 68 | 69 | \item{x}{S3 object returned by gmeta} 70 | 71 | \item{...}{arguments passed through print method} 72 | 73 | \item{value}{logical value for setting options on \code{ignore.stderr} set by 74 | default on package load to FALSE, \code{stop_on_no_flags_params} set by default 75 | on package load to TRUE, \code{echoCmd} set by default on package load to FALSE. 76 | \code{useIntern} sets the intern argument globally; \code{legacyExec} sets the 77 | legacyExec option globally, but is initialized to FALSE on unix systems 78 | (all but Windows) and TRUE on Windows; \code{defaultFlags} is initialized to 79 | NULL, but may be a character vector with values from c("quiet", "verbose") 80 | \code{suppressEchoCmdInFunc} default TRUE suppresses the effect of echoCmd 81 | within package functions, maybe set FALSE for debugging.} 82 | } 83 | \value{ 84 | Returns list of g.gisenv, g.region -g3, and g.proj values. 85 | } 86 | \description{ 87 | GRASS LOCATION metadata are read into a list in R; helper function 88 | getLocationProj returns a WKT2 string of projection information. The helper 89 | function \code{gmeta2grd} creates a GridTopology object from the current 90 | GRASS mapset region definitions. 91 | } 92 | \examples{ 93 | run <- FALSE 94 | if (nchar(Sys.getenv("GISRC")) > 0 && 95 | read.dcf(Sys.getenv("GISRC"))[1, "LOCATION_NAME"] == "nc_basic_spm_grass7") { 96 | run <- TRUE 97 | } 98 | 99 | if (run) { 100 | G <- gmeta() 101 | print(G) 102 | } 103 | 104 | if (run) { 105 | cat(getLocationProj(), "\n") 106 | cat(getLocationProj(g.proj_WKT = FALSE), "\n") 107 | } 108 | 109 | if (run) { 110 | grd <- gmeta2grd() 111 | print(grd) 112 | } 113 | 114 | if (run) { 115 | ncells <- prod(slot(grd, "cells.dim")) 116 | df <- data.frame(k = rep(1, ncells)) 117 | mask_SG <- sp::SpatialGridDataFrame(grd, data = df) 118 | print(summary(mask_SG)) 119 | } 120 | } 121 | \author{ 122 | Roger S. Bivand, e-mail: \href{mailto:Roger.Bivand@nhh.no}{Roger.Bivand@nhh.no} 123 | } 124 | \keyword{spatial} 125 | -------------------------------------------------------------------------------- /man/initGRASS.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/initGRASS.R 3 | \name{initGRASS} 4 | \alias{initGRASS} 5 | \alias{get.GIS_LOCK} 6 | \alias{set.GIS_LOCK} 7 | \alias{unset.GIS_LOCK} 8 | \alias{unlink_.gislock} 9 | \alias{remove_GISRC} 10 | \title{Initiate GRASS session} 11 | \usage{ 12 | initGRASS( 13 | gisBase = NULL, 14 | home, 15 | SG, 16 | gisDbase, 17 | addon_base, 18 | location, 19 | mapset, 20 | override = FALSE, 21 | use_g.dirseps.exe = TRUE, 22 | pid, 23 | remove_GISRC = FALSE, 24 | ignore.stderr = get.ignore.stderrOption() 25 | ) 26 | 27 | get.GIS_LOCK() 28 | 29 | set.GIS_LOCK(pid) 30 | 31 | unset.GIS_LOCK() 32 | 33 | unlink_.gislock() 34 | 35 | remove_GISRC() 36 | } 37 | \arguments{ 38 | \item{gisBase}{The directory path to GRASS binaries and libraries, containing 39 | bin and lib subdirectories among others; if NULL, set from environment 40 | variable GRASS_INSTALLATION if found, if not found, 41 | \code{system("grass --config path")} is tried.} 42 | 43 | \item{home}{The directory in which to create the .gisrc file; defaults to 44 | \verb{$HOME} on Unix systems and to \code{USERPROFILE} on Windows systems; 45 | can usually be set to \code{tempdir()}.} 46 | 47 | \item{SG}{An optional \code{SpatRaster} or \code{SpatialGrid} object to 48 | define the \code{DEFAULT_WIND} of the temporary location.} 49 | 50 | \item{gisDbase}{if missing, \code{tempdir()} will be used; GRASS GISDBASE 51 | directory for the working session.} 52 | 53 | \item{addon_base}{if missing, assumed to be "$HOME/.grass7/addons" on 54 | Unix-like platforms, on MS Windows "\\%APPDATA\\%\GRASS7\addons", 55 | and checked for existence.} 56 | 57 | \item{location}{if missing, \code{basename(tempfile())} will be used; GRASS 58 | location directory for the working session.} 59 | 60 | \item{mapset}{if missing, \code{basename(tempfile())} will be used; GRASS 61 | mapset directory for the working session.} 62 | 63 | \item{override}{default FALSE, set to TRUE if accidental trashing of GRASS 64 | .gisrc files and locations is not a problem.} 65 | 66 | \item{use_g.dirseps.exe}{default TRUE; when TRUE appears to work for WinGRASS 67 | Native binaries, when FALSE for QGIS GRASS binaries; ignored on other 68 | platforms.} 69 | 70 | \item{pid}{default \code{as.integer(round(runif(1, 1, 1000)))}, integer used 71 | to identify GIS_LOCK; the value here is arbitrary, but probably should be 72 | set correctly.} 73 | 74 | \item{remove_GISRC}{default FALSE; if TRUE, attempt to unlink the temporary 75 | file named in the "GISRC" environment variable when the R session 76 | terminates or when this package is unloaded.} 77 | 78 | \item{ignore.stderr}{default taking the value set by 79 | \code{set.ignore.stderrOption}; can be set to TRUE to silence 80 | \code{system()} output to standard error; does not apply on Windows 81 | platforms.} 82 | } 83 | \value{ 84 | The function runs \code{gmeta6} before returning the current values 85 | of the running GRASS session that it provides. 86 | } 87 | \description{ 88 | Run GRASS interface in an R session not started within GRASS. In general, 89 | most users will use \code{initGRASS} in throwaway locations, to use GRASS 90 | modules on R objects without the need to define and populate a location. The 91 | function initializes environment variables used by GRASS, the .gisrc used by 92 | GRASS for further environment variables, and a temporary location. 93 | 94 | On Windows, if OSGeo4W GRASS is being used, the R session must be started in 95 | the OSGeo4W shell. If not, the non-standard placing of files and of 96 | environment variables confuses the function. If \code{toupper(gisBase)} 97 | contains "OSGEO4W64/APPS/GRASS" or "OSGEO4W/APPS/GRASS" (and 98 | after converting "\\" to "/"), but the environment variable 99 | \code{OSGEO4W_ROOT} is not defined, \code{initGRASS()} will exit with an 100 | error before confusion leads to further errors. For further details, see 101 | \url{https://github.com/osgeo/rgrass/issues/16} and 102 | \url{https://github.com/osgeo/rgrass/issues/16}. 103 | 104 | The same restriction applies to use of GRASS with QGIS Windows standalone 105 | installations, which may be used with \code{initGRASS} only if the R session 106 | is started from the OSGeo4W shell shipped as part of the standalone installer 107 | (see \url{https://github.com/osgeo/rgrass/issues/87}). The function will 108 | exit with an error if R was not started from the QGIS OSGeo4W shell before 109 | confusion leads to further errors. 110 | 111 | The locking functions are used internally, but are exposed for experienced 112 | R/GRASS scripters needing to use the GRASS module "g.mapset" through 113 | \code{initGRASS} in an existing GRASS location. In particular, 114 | "g.mapset" may leave a \code{.gislock} file in the current MAPSET, so 115 | it may be important to call \code{unlink_.gislock} to clean up before 116 | quitting the R session. \code{remove_GISRC} may be used to try to remove the 117 | file given in the "GISRC" environment variable if created by 118 | \code{initGRASS} with argument \verb{remove_GISRC=} TRUE. 119 | } 120 | \details{ 121 | The function establishes an out-of-GRASS working environment providing GRASS 122 | commands with the environment variable support required, and may also provide 123 | a temporary location for use until the end of the running R session if the 124 | \code{home} argument is set to \code{tempdir()}, and the \code{gisDbase} 125 | argument is not given. Running \code{gmeta} shows where the location is, 126 | should it be desired to archive it before leaving R. 127 | } 128 | \note{ 129 | If any package command fails with a UTF-8 error from the XML package, try 130 | using \code{setXMLencoding} to work around the problem that GRASS modules 131 | declare --interface-description output as UTF-8 without ensuring that it is. 132 | } 133 | \examples{ 134 | # Run only if GRASS installation is found and 'terra' package is installed 135 | GRASS_INSTALLATION <- Sys.getenv("GRASS_INSTALLATION") 136 | run <- nzchar(GRASS_INSTALLATION) && 137 | file.exists(GRASS_INSTALLATION) && 138 | file.info(GRASS_INSTALLATION)$isdir && 139 | require(terra, quietly = TRUE) 140 | 141 | if (run) { 142 | # Get the terra example dataset 143 | f <- system.file("ex/elev.tif", package="terra") 144 | r <- rast(f) 145 | } 146 | 147 | # Check for existing GRASS session running 148 | if (run) { 149 | loc_existing <- try(gmeta(), silent = TRUE) 150 | } 151 | 152 | if (run) { 153 | # Initialize a temporary GRASS project using the example data 154 | loc <- initGRASS( 155 | gisBase = GRASS_INSTALLATION, 156 | home = tempdir(), 157 | SG = r, 158 | override = TRUE 159 | ) 160 | } 161 | 162 | if (run) { 163 | # Write the example data to the GRASS database 164 | write_RAST(r, "elev", flags = "overwrite") 165 | execGRASS("r.info", map = "elev") 166 | } 167 | 168 | if (run) { 169 | # Calculate slope and aspect raster 170 | execGRASS( 171 | "r.slope.aspect", 172 | flags = "overwrite", 173 | elevation = "elev", 174 | slope = "slope", 175 | aspect = "aspect" 176 | ) 177 | } 178 | 179 | if (run) { 180 | # Read the results back into R and plot 181 | u1 <- read_RAST(c("elev", "slope", "aspect"), return_format = "terra") 182 | plot(u1[["elev"]], col = terrain.colors(50)) 183 | } 184 | 185 | # Restore the original GRASS session 186 | if (run) { 187 | if (!inherits(loc_existing, "try-error")) { 188 | loc <- initGRASS( 189 | home = tempdir(), 190 | gisBase = GRASS_INSTALLATION, 191 | gisDbase = loc_existing$GISDBASE, 192 | location = loc_existing$LOCATION_NAME, 193 | mapset = loc_existing$MAPSET, 194 | override = TRUE 195 | ) 196 | } 197 | } 198 | } 199 | \seealso{ 200 | \code{\link[=gmeta]{gmeta()}} 201 | } 202 | \author{ 203 | Roger S. Bivand, e-mail: \href{mailto:Roger.Bivand@nhh.no}{Roger.Bivand@nhh.no} 204 | } 205 | \keyword{spatial} 206 | -------------------------------------------------------------------------------- /man/read_RAST.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rast_link.R 3 | \name{read_RAST} 4 | \alias{read_RAST} 5 | \alias{write_RAST} 6 | \title{Read and write GRASS raster files} 7 | \usage{ 8 | read_RAST( 9 | vname, 10 | cat = NULL, 11 | NODATA = NULL, 12 | return_format = "terra", 13 | close_OK = return_format == "SGDF", 14 | flags = NULL, 15 | Sys_ignore.stdout = FALSE, 16 | ignore.stderr = get.ignore.stderrOption() 17 | ) 18 | 19 | write_RAST( 20 | x, 21 | vname, 22 | zcol = 1, 23 | NODATA = NULL, 24 | flags = NULL, 25 | ignore.stderr = get.ignore.stderrOption(), 26 | overwrite = FALSE, 27 | verbose = TRUE 28 | ) 29 | } 30 | \arguments{ 31 | \item{vname}{A vector of GRASS raster file names in mapsets in the current 32 | search path, as set by "g.mapsets"; the file names may be given as 33 | fully-qualified map names using "name@mapset", in which case only 34 | the mapset given in the full path will be searched for the existence of the 35 | raster; if more than one raster with the same name is found in mapsets in 36 | the current search path, an error will occur, in which case the user should 37 | give the fully-qualified map name. If the fully-qualified name is used, 38 | \code{@} will be replaced by underscore in the output object.} 39 | 40 | \item{cat}{default NULL; if not NULL, must be a logical vector matching 41 | vname, stating which (CELL) rasters to return as factor.} 42 | 43 | \item{NODATA}{by default NULL, in which case it is set to one less than 44 | \code{floor()} of the data values for FCELL rasters or the range maximum 45 | for CELL Byte, UInt16 and Uint32 rasters (with no negative values), and an 46 | attempt is made to set NODATA to the upper Int16 and Int32 range if the 47 | lower range is occupied; otherwise an integer NODATA value (required to be 48 | integer by GRASS r.out.bin).} 49 | 50 | \item{return_format}{default \code{terra}, optionally \code{SGDF}.} 51 | 52 | \item{close_OK}{default TRUE - clean up possible open connections used for 53 | reading metadata; may be set to FALSE to avoid the side-effect of other 54 | user-opened connections being broken.} 55 | 56 | \item{flags}{default NULL, character vector, for example \code{overwrite}.} 57 | 58 | \item{Sys_ignore.stdout}{Passed to \code{system}.} 59 | 60 | \item{ignore.stderr}{default taking the value set by 61 | \code{set.ignore.stderrOption}; can be set to TRUE to silence 62 | \code{system()} output to standard error; does not apply on Windows 63 | platforms.} 64 | 65 | \item{x}{A terra \code{\link[terra:SpatRaster-class]{terra::SpatRaster}} or sp \code{\link[sp:SpatialGridDataFrame]{sp::SpatialGridDataFrame}} 66 | object,} 67 | 68 | \item{zcol}{Attribute column number or name,} 69 | 70 | \item{overwrite}{default FALSE, if TRUE inserts "overwrite" into the value of 71 | the flags argument if not already there to allow existing GRASS rasters to 72 | be overwritten,} 73 | 74 | \item{verbose}{default TRUE, report how writing to GRASS is specified,} 75 | } 76 | \value{ 77 | by default returns a SpatRaster object, but may return a legacy 78 | SpatialGridDataFrame object if \code{return_format="SGDF"}. 79 | \code{write_RAST} silently returns the object being written to GRASS. 80 | } 81 | \description{ 82 | Read GRASS raster files from GRASS into R \code{\link[terra:SpatRaster-class]{terra::SpatRaster}} or 83 | \code{\link[sp:SpatialGridDataFrame]{sp::SpatialGridDataFrame}} objects, and write single columns of 84 | \code{\link[terra:SpatRaster-class]{terra::SpatRaster}} or \code{\link[sp:SpatialGridDataFrame]{sp::SpatialGridDataFrame}} 85 | objects to GRASS. When \code{return_format="terra"}, temporary binary files 86 | and r.out.bin and r.in.bin are used for speed reasons. \code{read_RAST()} and 87 | \code{write_RAST()} by default use "RRASTER" files written and read by 88 | GDAL. 89 | } 90 | \examples{ 91 | # Run example only if GRASS settings file indicates that the 92 | # nc_basic_spm_grass7 location is active 93 | run <- FALSE 94 | GISRC <- Sys.getenv("GISRC") 95 | 96 | if (nchar(GISRC) > 0) { 97 | location_name <- read.dcf(GISRC)[1, "LOCATION_NAME"] 98 | if (location_name == "nc_basic_spm_grass7") { 99 | run <- TRUE 100 | } 101 | } 102 | 103 | # store original environment variables before modifying 104 | GV <- Sys.getenv("GRASS_VERBOSE") 105 | Sys.setenv("GRASS_VERBOSE" = 0) 106 | original_ignore_stderr <- get.ignore.stderrOption() 107 | set.ignore.stderrOption(TRUE) 108 | 109 | if (run) { 110 | # Retrieve GRASS metadata and creata a new mapset 111 | meta <- gmeta() 112 | location_path <- file.path(meta$GISDBASE, meta$LOCATION_NAME) 113 | previous_mapset <- meta$MAPSET 114 | example_mapset <- "RGRASS_EXAMPLES" 115 | execGRASS("g.mapset", flags = "c", mapset = example_mapset) 116 | } 117 | 118 | if (run) { 119 | # List available mapsets and raster maps 120 | mapsets <- unlist( 121 | strsplit(execGRASS("g.mapsets", flags = "p", intern = TRUE), " ") 122 | ) 123 | print(mapsets) 124 | } 125 | 126 | if (run) { 127 | execGRASS("g.list", type = "raster", pattern = "soils", flags = "m", 128 | intern = TRUE) 129 | } 130 | 131 | if (run) { 132 | execGRASS("g.list", type = "raster", pattern = "soils@PERMANENT", 133 | mapset = ".", flags = "m", intern = TRUE) 134 | } 135 | 136 | if (run) { 137 | execGRASS("g.list", type = "raster", pattern = "soils", 138 | mapset = "PERMANENT", flags = "m", intern = TRUE) 139 | } 140 | # Read/write the GRASS "landuse" dataset as a SpatRaster 141 | if (require("terra", quietly = TRUE)) { 142 | if (run) { 143 | v1 <- read_RAST("landuse", cat = TRUE, return_format = "terra") 144 | print(v1) 145 | print(inMemory(v1)) 146 | } 147 | 148 | if (run) { 149 | write_RAST(v1, "landuse1", flags = c("o", "overwrite")) 150 | execGRASS("r.stats", flags = "c", input = "landuse1") 151 | execGRASS("g.remove", flags = "f", name = "landuse1", type = "raster") 152 | } 153 | } 154 | 155 | # read the geology and elevation GRASS datasets as SpatialGridDataFrames 156 | if (require("sp", quietly = TRUE)) { 157 | if (run) { 158 | nc_basic <- read_RAST(c("geology", "elevation"), cat = c(TRUE, FALSE), 159 | return_format = "SGDF") 160 | print(table(nc_basic$geology)) 161 | } 162 | 163 | if (run) { 164 | execGRASS("r.stats", flags = c("c", "l", "quiet"), input = "geology") 165 | boxplot(nc_basic$elevation ~ nc_basic$geology) 166 | } 167 | if (run) { 168 | # Compute square root of elevation and write back to GRASS 169 | nc_basic$sqdem <- sqrt(nc_basic$elevation) 170 | write_RAST(nc_basic, "sqdemSP", zcol = "sqdem", 171 | flags = c("quiet", "overwrite")) 172 | execGRASS("r.info", map = "sqdemSP") 173 | } 174 | 175 | if (run) { 176 | # Read the new raster data and measure read times 177 | print(system.time( 178 | sqdemSP <- read_RAST(c("sqdemSP", "elevation"), return_format = "SGDF") 179 | )) 180 | } 181 | 182 | if (run) { 183 | print(system.time( 184 | sqdem <- read_RAST(c("sqdemSP", "elevation"), return_format = "terra")) 185 | ) 186 | } 187 | 188 | if (run) { 189 | print(names(sqdem)) 190 | } 191 | 192 | if (run) { 193 | sqdem1 <- read_RAST(c("sqdemSP@RGRASS_EXAMPLES", "elevation@PERMANENT")) 194 | print(names(sqdem1)) 195 | } 196 | 197 | if (run) { 198 | execGRASS("g.remove", flags = "f", name = "sqdemSP", type = "raster") 199 | 200 | # GRASS r.mapcalc example 201 | execGRASS("r.mapcalc", expression = "basins0 = basins - 1", 202 | flags = "overwrite") 203 | execGRASS("r.stats", flags = "c", input = "basins0") 204 | } 205 | 206 | if (run) { 207 | basins0 <- read_RAST("basins0", return_format = "SGDF") 208 | print(table(basins0$basins0)) 209 | execGRASS("g.remove", flags = "f", name = "basins0", type = "raster") 210 | } 211 | 212 | if (run) { 213 | # Create and read a test raster 214 | execGRASS("r.mapcalc", expression = "test_t = 66000", 215 | flags = "overwrite") 216 | execGRASS("r.info", flags = "r", map = "test_t", intern = TRUE) 217 | tt <- read_RAST("test_t") 218 | execGRASS("g.remove", flags = "f", name = "test_t", type = "raster") 219 | } 220 | } 221 | 222 | if (run) { 223 | # Restore the previous mapset and clean up 224 | execGRASS("g.mapset", mapset = previous_mapset) 225 | if (example_mapset != previous_mapset) { 226 | unlink(file.path(location_path, example_mapset), recursive = TRUE) 227 | } 228 | } 229 | 230 | # Restore original GRASS settings 231 | Sys.setenv("GRASS_VERBOSE" = GV) 232 | set.ignore.stderrOption(original_ignore_stderr) 233 | } 234 | \author{ 235 | Roger S. Bivand, e-mail: \href{mailto:Roger.Bivand@nhh.no}{Roger.Bivand@nhh.no} 236 | } 237 | \keyword{spatial} 238 | -------------------------------------------------------------------------------- /man/read_VECT.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/vect_link_ng.R, R/vect_link.R 3 | \name{read_VECT} 4 | \alias{read_VECT} 5 | \alias{write_VECT} 6 | \alias{vInfo} 7 | \alias{vColumns} 8 | \alias{vDataCount} 9 | \alias{vect2neigh} 10 | \title{Read and write GRASS vector object files} 11 | \usage{ 12 | read_VECT( 13 | vname, 14 | layer = "", 15 | proxy = FALSE, 16 | use_gdal_grass_driver = TRUE, 17 | type = NULL, 18 | flags = "overwrite", 19 | Sys_ignore.stdout = FALSE, 20 | ignore.stderr = get.ignore.stderrOption() 21 | ) 22 | 23 | write_VECT( 24 | x, 25 | vname, 26 | flags = "overwrite", 27 | ignore.stderr = get.ignore.stderrOption() 28 | ) 29 | 30 | vInfo(vname, layer, ignore.stderr = NULL) 31 | 32 | vColumns(vname, layer, ignore.stderr = NULL) 33 | 34 | vDataCount(vname, layer, ignore.stderr = NULL) 35 | 36 | vect2neigh( 37 | vname, 38 | ID = NULL, 39 | ignore.stderr = NULL, 40 | remove = TRUE, 41 | vname2 = NULL, 42 | units = "k" 43 | ) 44 | } 45 | \arguments{ 46 | \item{vname}{A GRASS vector file name.} 47 | 48 | \item{layer}{a layer name (string); if missing the first layer will be used.} 49 | 50 | \item{proxy}{Default is \code{FALSE}. Set as \code{TRUE} if you need a 51 | \code{SpatVectorProxy} object.} 52 | 53 | \item{use_gdal_grass_driver}{Default \code{TRUE}. The 54 | \href{https://github.com/OSGeo/gdal-grass}{standalone GDAL-GRASS driver} 55 | for the vector format will be used if it is installed. The advantage is 56 | that no intermediate file needs to be written from GRASS GIS and 57 | subsequently read into R; instead the vector layer is read directly from 58 | the GRASS GIS database. Please read the \strong{Note} further below!.} 59 | 60 | \item{type}{override type detection when multiple types are non-zero, passed 61 | to v.out.ogr.} 62 | 63 | \item{flags}{Character vector containing additional optional flags and/or 64 | options for v.in.ogr, particularly "o" and "overwrite".} 65 | 66 | \item{Sys_ignore.stdout}{Passed to \code{system}.} 67 | 68 | \item{ignore.stderr}{default the value set by \code{set.ignore.stderrOption}; 69 | NULL, taking the value set by \code{set.ignore.stderrOption}, can be set to 70 | TRUE to silence \code{system()} output to standard error; does not apply on 71 | Windows platforms.} 72 | 73 | \item{x}{A \code{SpatVector} object moved to GRASS.} 74 | 75 | \item{ID}{A valid DB column name for unique identifiers (optional).} 76 | 77 | \item{remove}{default TRUE, remove copied vectors created in 78 | \code{vect2neigh}.} 79 | 80 | \item{vname2}{If on a previous run, remove was FALSE, the name of the 81 | temporary vector may be given to circumvent its generation.} 82 | 83 | \item{units}{default "k"; see GRASS 'v.to.db' manual page for alternatives.} 84 | } 85 | \value{ 86 | \code{read_VECT} imports a GRASS vector layer into a \code{SpatVector} or 87 | \code{SpatVectorProxy} object. 88 | \code{vect2neigh} returns a data frame object with left and right 89 | neighbours and boundary lengths, also given class GRASSneigh and 90 | spatial.neighbour (as used in spdep). The incantation to retrieve the 91 | neighbours list is \code{sn2listw(vect2neigh())$neighbours}, and to 92 | retrieve the boundary lengths: \code{sn2listw(vect2neigh())$weights}. The 93 | GRASSneigh object has two other useful attributes: external is a vector 94 | giving the length of shared boundary between each polygon and the external 95 | area, and total giving each polygon's total boundary length. 96 | } 97 | \description{ 98 | \code{read_VECT} moves one GRASS vector object file with attribute data 99 | through a temporary GeoPackage file to a \code{\link[terra:SpatVector-class]{terra::SpatVector}} 100 | object; \code{write_VECT} moves a \code{\link[terra:SpatVector-class]{terra::SpatVector}} object 101 | through a temporary GeoPackage file to a GRASS vector object file. 102 | \code{vect2neigh} returns neighbour pairs with shared boundary length as 103 | described by Markus Neteler, in 104 | \url{https://stat.ethz.ch/pipermail/r-sig-geo/2005-October/000616.html}. 105 | \code{cygwin_clean_temp} can be called to try to clean the GRASS 106 | mapset-specific temporary directory under cygwin. 107 | } 108 | \note{ 109 | Be aware that the GDAL-GRASS driver may have some 110 | \href{https://github.com/OSGeo/gdal-grass/issues}{issues} for vector data. In 111 | our experience, the error and warning messages for vector data can be 112 | ignored. Further, the returned metadata about the coordinate reference system 113 | may currently be incomplete, e.g. it may miss the EPSG code. 114 | } 115 | \examples{ 116 | # Run example if in active GRASS nc_basic_spm_grass7 location 117 | run <- FALSE 118 | if (nchar(Sys.getenv("GISRC")) > 0 && 119 | read.dcf(Sys.getenv("GISRC"))[1, "LOCATION_NAME"] == "nc_basic_spm_grass7") { 120 | run <- require(terra, quietly = TRUE) 121 | } 122 | 123 | # Store original environment variable settings 124 | GV <- Sys.getenv("GRASS_VERBOSE") 125 | Sys.setenv("GRASS_VERBOSE" = 0) 126 | ois <- get.ignore.stderrOption() 127 | set.ignore.stderrOption(TRUE) 128 | 129 | if (run) { 130 | # Create a new mapset 131 | meta <- gmeta() 132 | location_path <- file.path(meta$GISDBASE, meta$LOCATION_NAME) 133 | previous_mapset <- meta$MAPSET 134 | example_mapset <- "RGRASS_EXAMPLES" 135 | execGRASS("g.mapset", "c", mapset = example_mapset) 136 | } 137 | 138 | if (run) { 139 | # Report basic metadata about the schools dataset 140 | execGRASS("v.info", map = "schools", layer = "1") 141 | print(vInfo("schools")) 142 | } 143 | 144 | if (run) { 145 | # Read/write as a SpatVector 146 | schs <- read_VECT("schools") 147 | print(summary(schs)) 148 | } 149 | 150 | if (run) { 151 | try({ 152 | write_VECT(schs, "newsch", flags = c("o", "overwrite")) 153 | }) 154 | schs <- read_VECT("schools", use_gdal_grass_driver = FALSE) 155 | } 156 | 157 | if (run) { 158 | write_VECT(schs, "newsch", flags = c("o", "overwrite")) 159 | execGRASS("v.info", map = "newsch", layer = "1") 160 | } 161 | 162 | if (run) { 163 | nschs <- read_VECT("newsch") 164 | print(summary(nschs)) 165 | } 166 | 167 | if (run) { 168 | print(all.equal(names(nschs), as.character(vColumns("newsch")[, 2]))) 169 | } 170 | 171 | if (run) { 172 | # Show metadata for the roadsmajor dataset and read as spatVector 173 | print(vInfo("roadsmajor")) 174 | } 175 | 176 | if (run) { 177 | roads <- read_VECT("roadsmajor") 178 | print(summary(roads)) 179 | } 180 | 181 | # not run: vect2neigh() currently writes 3 new data sources in the PERMANENT 182 | # mapset, despite this mapset not being the active one. 183 | if (FALSE) { 184 | cen_neig <- vect2neigh("census") 185 | str(cen_neig) 186 | } 187 | 188 | # Cleanup the previously created datasets 189 | if (run) { 190 | execGRASS( 191 | "g.remove", 192 | flags = "f", 193 | name = c("newsch", "newsch1"), 194 | type = "vector" 195 | ) 196 | execGRASS("g.mapset", mapset = previous_mapset) 197 | if (example_mapset != previous_mapset) { 198 | unlink(file.path(location_path, example_mapset), recursive = TRUE) 199 | } 200 | } 201 | 202 | # Restore environment variable settings 203 | Sys.setenv("GRASS_VERBOSE" = GV) 204 | set.ignore.stderrOption(ois) 205 | } 206 | \author{ 207 | Roger S. Bivand, e-mail: \href{mailto:Roger.Bivand@nhh.no}{Roger.Bivand@nhh.no} 208 | } 209 | -------------------------------------------------------------------------------- /man/rgrass.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rgrass-package.R 3 | \docType{package} 4 | \name{rgrass} 5 | \alias{rgrass-package} 6 | \alias{rgrass} 7 | \title{rgrass: Interface between GRASS geographical information system and R} 8 | \description{ 9 | Interpreted interface between GRASS geographical information 10 | system, versions 7 and 8, and R, based on starting R from within the GRASS 11 | environment, or on running R stand-alone and creating a throw-away GRASS 12 | environment from within R. The interface uses classes defined in the sp 13 | package to hold spatial data. 14 | } 15 | \details{ 16 | Index: 17 | 18 | \preformatted{ 19 | read_RAST read GRASS raster files 20 | write_RAST write GRASS raster files 21 | read_VECT read GRASS vector object files 22 | write_VECT write GRASS vector object files 23 | gmeta read GRASS metadata from the current LOCATION 24 | getLocationProj return a WKT2 string of projection information 25 | gmeta2grd create a GridTopology object from the GRASS region 26 | vInfo return vector geometry information 27 | vColumns return vector database columns information 28 | vDataCount return count of vector database rows 29 | vect2neigh return area neighbours with shared boundary length 30 | } 31 | 32 | Note that the examples now use the smaller subset North Carolina location: 33 | \url{https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.tar.gz} 34 | } 35 | \seealso{ 36 | Useful links: 37 | \itemize{ 38 | \item \url{https://osgeo.github.io/rgrass/} 39 | \item \url{https://grass.osgeo.org/} 40 | \item \url{https://github.com/osgeo/rgrass} 41 | \item \url{https://lists.osgeo.org/mailman/listinfo/grass-stats} 42 | \item Report bugs at \url{https://github.com/osgeo/rgrass/issues/} 43 | } 44 | 45 | } 46 | \author{ 47 | \strong{Maintainer}: Steven Pawley \email{dr.stevenpawley@gmail.com} (\href{https://orcid.org/0000-0002-5524-3320}{ORCID}) 48 | 49 | Authors: 50 | \itemize{ 51 | \item Roger Bivand \email{Roger.Bivand@nhh.no} (\href{https://orcid.org/0000-0003-2392-6140}{ORCID}) 52 | } 53 | 54 | Other contributors: 55 | \itemize{ 56 | \item Sebastian Jeworutzki \email{Sebastian.Jeworutzki@rub.de} (\href{https://orcid.org/0000-0002-2671-5253}{ORCID}) [contributor] 57 | \item Rainer Krug \email{Rainer@krugs.de} (\href{https://orcid.org/0000-0002-7490-0066}{ORCID}) [contributor] 58 | \item Robin Lovelace (\href{https://orcid.org/0000-0001-5679-6536}{ORCID}) [contributor] 59 | \item Markus Neteler \email{neteler@osgeo.org} (\href{https://orcid.org/0000-0003-1916-1966}{ORCID}) [contributor] 60 | \item Floris Vanderhaeghe \email{floris.vanderhaeghe@inbo.be} (\href{https://orcid.org/0000-0002-6378-6229}{ORCID}) [contributor] 61 | } 62 | 63 | } 64 | \keyword{internal} 65 | \keyword{package} 66 | \keyword{spatial} 67 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | # This file is part of the standard setup for testthat. 2 | # It is recommended that you do not modify it. 3 | # 4 | # Where should you do additional test configuration? 5 | # Learn more about the roles of various files in: 6 | # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview 7 | # * https://testthat.r-lib.org/articles/special-files.html 8 | 9 | library(testthat) 10 | library(rgrass) 11 | 12 | test_check("rgrass") 13 | -------------------------------------------------------------------------------- /tests/testthat/helper.R: -------------------------------------------------------------------------------- 1 | download_nc_basic <- function() { 2 | tmpdir <- tempdir() 3 | 4 | if (!file.exists(file.path(tmpdir, "nc_basic_spm_grass7.zip"))) { 5 | base_url <- "https://grass.osgeo.org/sampledata" 6 | path_url <- "north_carolina" 7 | file_url <- "nc_basic_spm_grass7.zip" 8 | 9 | download.file( 10 | paste(base_url, path_url, file_url, sep = "/"), 11 | file.path(tmpdir, "nc_basic_spm_grass7.zip") 12 | ) 13 | 14 | unzip( 15 | file.path(tmpdir, "nc_basic_spm_grass7.zip"), 16 | exdir = file.path(tmpdir, "grassdb") 17 | ) 18 | unlink(file.path(tmpdir, "nc_basic_spm_grass7.zip")) 19 | } 20 | 21 | dataset <- list( 22 | gisDbase = file.path(tmpdir, "grassdb"), 23 | location = "nc_basic_spm_grass7" 24 | ) 25 | 26 | return(dataset) 27 | } 28 | 29 | get_gisbase <- function() { 30 | if (Sys.info()["sysname"] == "Linux") { 31 | gisBase <- try(system2("grass", "--config path", stdout = TRUE), silent = TRUE) 32 | } else { 33 | gisBase <- Sys.getenv("GRASS_INSTALLATION") 34 | } 35 | 36 | if (inherits(gisBase, "try-error") | gisBase == "") { 37 | message("GRASS GIS not found on PATH") 38 | return(NULL) 39 | } 40 | return(gisBase) 41 | } 42 | -------------------------------------------------------------------------------- /tests/testthat/setup.R: -------------------------------------------------------------------------------- 1 | testdata <- download_nc_basic() 2 | gisBase <- get_gisbase() 3 | -------------------------------------------------------------------------------- /tests/testthat/test-execGRASS.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(terra) 3 | 4 | test_that("testing basic doGRASS, execGRASS, stringexecGRASS", { 5 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 6 | 7 | loc <- initGRASS( 8 | home = tempdir(), 9 | gisBase = gisBase, 10 | gisDbase = testdata$gisDbase, 11 | location = "nc_basic_spm_grass7", 12 | mapset = "PERMANENT", 13 | override = TRUE 14 | ) 15 | 16 | # test assembling the command using arguments 17 | cmd <- doGRASS( 18 | "r.slope.aspect", 19 | elevation = "elevation", 20 | slope = "slope", 21 | aspect = "aspect" 22 | ) 23 | 24 | expect_type(cmd, "character") 25 | cmd_expected <- ifelse( 26 | .Platform$OS.type == "windows", 27 | "r.slope.aspect.exe", 28 | "r.slope.aspect" 29 | ) 30 | expect_equal(attributes(cmd)$cmd, cmd_expected) 31 | expect_equal( 32 | as.character(cmd), 33 | paste(cmd_expected, "elevation=elevation slope=slope aspect=aspect") 34 | ) 35 | 36 | # test assembling the command using a list 37 | params <- list(elevation = "elevation", slope = "slope", aspect = "aspect") 38 | cmd2 <- doGRASS("r.slope.aspect", parameters = params) 39 | expect_equal(cmd, cmd2) 40 | 41 | # test executing the command 42 | # TODO this fails on windows due to .exe being added 43 | stringexecGRASS(gsub(".exe", "", cmd)) 44 | aspect <- read_RAST("aspect") 45 | expect_equal(as.numeric(minmax(aspect)), c(0, 360)) 46 | execGRASS( 47 | "g.remove", 48 | type = "raster", 49 | name = c("slope", "aspect"), 50 | flags = "f" 51 | ) 52 | 53 | # test executing the command based on the execGRASS wrapper 54 | execGRASS( 55 | "r.slope.aspect", 56 | elevation = "elevation", 57 | slope = "slope", 58 | aspect = "aspect" 59 | ) 60 | aspect <- read_RAST("aspect") 61 | expect_equal(as.numeric(minmax(aspect)), c(0, 360)) 62 | execGRASS( 63 | "g.remove", 64 | type = "raster", 65 | name = c("slope", "aspect"), 66 | flags = "f" 67 | ) 68 | 69 | # Try executing 'r.stats' command which will fail because "fire_blocksgg" 70 | # does not exist in the mapset 71 | # expect_error( 72 | # res <- execGRASS("r.stats", input = "fire_blocksgg", flags = c("c", "n")), 73 | # regexp = "ERROR:" 74 | # ) 75 | 76 | # Test using an invalid parameter 77 | expect_error( 78 | execGRASS( 79 | "r.stats", 80 | input = "elevation", 81 | flags = c("c", "n"), 82 | silent = TRUE 83 | ), 84 | "Invalid parameter name: silent" 85 | ) 86 | 87 | }) 88 | 89 | test_that("testing options doGRASS, execGRASS, stringexecGRASS", { 90 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 91 | 92 | loc <- initGRASS( 93 | home = tempdir(), 94 | gisBase = gisBase, 95 | gisDbase = testdata$gisDbase, 96 | location = "nc_basic_spm_grass7", 97 | mapset = "PERMANENT", 98 | override = TRUE 99 | ) 100 | 101 | # test 'intern' = TRUE 102 | raster_maps <- c("basins", "elevation", "elevation_shade", "geology", "lakes", 103 | "landuse", "soils") 104 | 105 | res <- execGRASS("g.list", type = "raster") 106 | expect_type(res, "integer") 107 | expect_true(res == 0) 108 | 109 | if (.Platform$OS.type != "windows") { 110 | expect_named(attributes(res), c("resOut", "resErr")) 111 | expect_equal(attr(res, "resOut"), raster_maps) 112 | } 113 | expect_length(attr(res, "resErr"), 0) 114 | 115 | res <- execGRASS("g.list", type = "raster", intern = TRUE) 116 | expect_type(res, "character") 117 | expect_equal(res, raster_maps) 118 | 119 | # Execute 'r.stats' with legacyExec 120 | res <- execGRASS( 121 | "r.stats", 122 | input = "elevation", 123 | flags = c("C", "n"), 124 | legacyExec = TRUE 125 | ) 126 | expect_equal(res, 0) 127 | 128 | # Test redirect (allows command to fail with only warning) 129 | expect_warning( 130 | execGRASS( 131 | "r.stats", 132 | input = "fire_blocksgg", 133 | flags = c("C", "n"), 134 | redirect = TRUE, 135 | legacyExec = TRUE 136 | ) 137 | ) 138 | }) 139 | -------------------------------------------------------------------------------- /tests/testthat/test-gmeta.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(terra) 3 | 4 | testthat::test_that("testing gmeta", { 5 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 6 | 7 | # Initialize a temporary GRASS project using the example data 8 | loc <- initGRASS( 9 | home = tempdir(), 10 | gisBase = gisBase, 11 | gisDbase = testdata$gisDbase, 12 | location = "nc_basic_spm_grass7", 13 | mapset = "PERMANENT", 14 | override = TRUE 15 | ) 16 | 17 | # Test gmeta working 18 | meta <- gmeta() 19 | 20 | expect_equal( 21 | names(meta), 22 | c("GISDBASE", "LOCATION_NAME", "MAPSET", "GRASS_GUI", "projection", "zone", "n", 23 | "s", "w", "e", "t", "b", "nsres", "nsres3", "ewres", "ewres3", "tbres", "rows", "rows3", 24 | "cols", "cols3", "depths", "cells", "cells3", "proj4") 25 | ) 26 | 27 | expect_equal(meta$LOCATION_NAME, testdata$location) 28 | expect_equal(meta$projection, "99") 29 | 30 | # Test old proj4 output from grass 31 | meta2 <- gmeta(g.proj_WKT = FALSE) 32 | expect_equal(meta2$proj4, paste(crs("epsg:3358", proj = TRUE), "+type=crs")) 33 | 34 | # Test gmeta2grd 35 | meta3 <- gmeta2grd() 36 | expect_s4_class(meta3, "GridTopology") 37 | 38 | # Test just returning the projection 39 | meta4 <- getLocationProj() 40 | expect_equal(meta4, meta$proj4) 41 | 42 | meta4 <- getLocationProj(g.proj_WKT = FALSE) 43 | expect_equal(meta4, paste(crs("epsg:3358", proj = TRUE), "+type=crs")) 44 | 45 | # Test coercion of projection into terra and sp classes 46 | gLP <- getLocationProj() 47 | expect_type(terra::crs(gLP), "character") 48 | 49 | # disabled due to unknown issue with sp reading WTK 50 | # expect_s4_class(sp::CRS(gLP), "CRS") 51 | }) 52 | -------------------------------------------------------------------------------- /tests/testthat/test-initGRASS.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(terra) 3 | 4 | test_that("testing basic initGRASS", { 5 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 6 | 7 | # Initialize a temporary GRASS project using the example data 8 | loc <- initGRASS( 9 | home = tempdir(), 10 | gisBase = gisBase, 11 | gisDbase = testdata$gisDbase, 12 | location = "nc_basic_spm_grass7", 13 | mapset = "PERMANENT", 14 | override = TRUE 15 | ) 16 | 17 | expect_s3_class(loc, "gmeta") 18 | expect_equal(loc$LOCATION_NAME, "nc_basic_spm_grass7") 19 | expect_equal(loc$projection, "99") 20 | expect_equal(crs(loc$proj4, describe = TRUE)$name, "NAD83(HARN) / North Carolina") 21 | }) 22 | 23 | test_that("testing initialization from SpatRaster", { 24 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 25 | 26 | meuse_grid <- rast(system.file("ex/meuse.tif", package = "terra")) 27 | loc <- initGRASS(home = tempdir(), gisBase = gisBase, SG = meuse_grid, override = TRUE) 28 | expect_s3_class(loc, "gmeta") 29 | }) 30 | 31 | test_that("testing remove_GISRC", { 32 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 33 | 34 | loc <- initGRASS( 35 | home = tempdir(), 36 | gisBase = gisBase, 37 | gisDbase = testdata$gisDbase, 38 | location = "nc_basic_spm_grass7", 39 | mapset = "PERMANENT", 40 | remove_GISRC = TRUE, 41 | pid = 1000, 42 | override = TRUE 43 | ) 44 | 45 | lockfile <- Sys.getenv("GISRC") 46 | expect_true(file.exists(lockfile)) 47 | 48 | remove_GISRC() 49 | expect_false(file.exists(lockfile)) 50 | }) 51 | 52 | test_that("testing set/unset.GIS_LOCK", { 53 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 54 | skip_if_not(Sys.info()["sysname"] == "Linux", "test only works on *nix") 55 | 56 | loc <- initGRASS( 57 | home = tempdir(), 58 | gisBase = gisBase, 59 | gisDbase = testdata$gisDbase, 60 | location = "nc_basic_spm_grass7", 61 | mapset = "PERMANENT", 62 | remove_GISRC = TRUE, 63 | override = TRUE 64 | ) 65 | 66 | expect_false( 67 | file.exists(file.path(testdata$gisDbase, "nc_basic_spm_grass7", "user1", ".gislock")) 68 | ) 69 | 70 | loc <- initGRASS( 71 | home = tempdir(), 72 | gisBase = gisBase, 73 | gisDbase = testdata$gisDbase, 74 | location = "nc_basic_spm_grass7", 75 | mapset = "PERMANENT", 76 | remove_GISRC = TRUE, 77 | pid = 1000, 78 | override = TRUE 79 | ) 80 | 81 | # note - shouldn't this be an integer? 82 | expect_equal(get.GIS_LOCK(), "1000") 83 | 84 | # test setting a lock by switching to mapset 85 | execGRASS("g.mapset", mapset = "user1") 86 | expect_true( 87 | file.exists(file.path(testdata$gisDbase, "nc_basic_spm_grass7", "user1", ".gislock")) 88 | ) 89 | 90 | # changing mapset will cause the lockfile to be removed for current session 91 | execGRASS("g.mapset", mapset = "PERMANENT") 92 | expect_false( 93 | file.exists(file.path(testdata$gisDbase, "nc_basic_spm_grass7", "user1", ".gislock")) 94 | ) 95 | 96 | # test removing the lock 97 | unset.GIS_LOCK() 98 | expect_equal(get.GIS_LOCK(), "") 99 | 100 | # test removing the GICRC 101 | expect_error( 102 | initGRASS( 103 | home = tempdir(), 104 | gisBase = gisBase, 105 | gisDbase = testdata$gisDbase, 106 | location = "nc_basic_spm_grass7", 107 | mapset = "user1", 108 | override = FALSE 109 | ), 110 | regexp = "A GRASS location" 111 | ) 112 | 113 | remove_GISRC() 114 | 115 | expect_no_error( 116 | initGRASS( 117 | home = tempdir(), 118 | gisBase = gisBase, 119 | gisDbase = testdata$gisDbase, 120 | location = "nc_basic_spm_grass7", 121 | mapset = "user1", 122 | override = FALSE 123 | ) 124 | ) 125 | 126 | unlink(file.path(testdata$gisDbase, "nc_basic_spm_grass7", "user1", ".gislock")) 127 | }) 128 | -------------------------------------------------------------------------------- /tests/testthat/test-options.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(terra) 3 | 4 | test_that("testing ignore.stderrOption", { 5 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 6 | origIgnoreStderr <- get.ignore.stderrOption() 7 | 8 | loc <- initGRASS( 9 | home = tempdir(), 10 | gisBase = gisBase, 11 | gisDbase = testdata$gisDbase, 12 | location = "nc_basic_spm_grass7", 13 | mapset = "PERMANENT", 14 | override = TRUE 15 | ) 16 | 17 | # test setting ignore.stderrOption 18 | expect_false(get.ignore.stderrOption()) 19 | set.ignore.stderrOption(TRUE) 20 | expect_true(get.ignore.stderrOption()) 21 | 22 | loc <- initGRASS( 23 | home = tempdir(), 24 | gisBase = gisBase, 25 | gisDbase = testdata$gisDbase, 26 | location = "nc_basic_spm_grass7", 27 | mapset = "PERMANENT", 28 | ignore.stderr = TRUE, 29 | override = TRUE 30 | ) 31 | expect_true(get.ignore.stderrOption()) 32 | 33 | # restore defaults 34 | set.ignore.stderrOption(origIgnoreStderr) 35 | }) 36 | 37 | test_that("testing stop_on_no_flags_parasOption", { 38 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 39 | origStopOnNoFlagsParas <- get.stop_on_no_flags_parasOption() 40 | 41 | # testing stop_on_no_flags_parasOption set to TRUE by default 42 | loc <- initGRASS( 43 | home = tempdir(), 44 | gisBase = gisBase, 45 | gisDbase = testdata$gisDbase, 46 | location = "nc_basic_spm_grass7", 47 | mapset = "PERMANENT", 48 | override = TRUE 49 | ) 50 | expect_true(get.stop_on_no_flags_parasOption()) 51 | 52 | # TODO: what is the purpose of stop_on_no_flags_parasOption because 53 | # commands with no arguments appear to succeed irrespectively, and commands 54 | # missing required arguments appear to fail irrespectively? 55 | # expect_error( 56 | # execGRASS("g.gisenv"), 57 | # regexp = "required parameters with no defaults missing:" 58 | # ) 59 | 60 | set.stop_on_no_flags_parasOption(FALSE) 61 | expect_false(get.stop_on_no_flags_parasOption()) 62 | # expect_no_error(execGRASS("g.gisenv")) 63 | 64 | # restore defaults 65 | set.stop_on_no_flags_parasOption(origStopOnNoFlagsParas) 66 | }) 67 | 68 | test_that("testing echoCmdOption option", { 69 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 70 | origEchoCmd <- get.echoCmdOption() 71 | 72 | # testing echoCmdOption (set to FALSE by default) 73 | loc <- initGRASS( 74 | home = tempdir(), 75 | gisBase = gisBase, 76 | gisDbase = testdata$gisDbase, 77 | location = "nc_basic_spm_grass7", 78 | mapset = "PERMANENT", 79 | override = TRUE 80 | ) 81 | expect_false(get.echoCmdOption()) 82 | 83 | # testing echoCmdOption set to true with the GRASS command printed to the console 84 | set.echoCmdOption(TRUE) 85 | expect_true(get.echoCmdOption()) 86 | 87 | res <- capture.output({ 88 | x <- execGRASS("g.list", type = "raster", intern = TRUE) 89 | } 90 | ) 91 | expect_true(length(res) > 0) 92 | 93 | # testing echoCmdOption set to false with the GRASS command is silent 94 | set.echoCmdOption(FALSE) 95 | loc <- initGRASS( 96 | home = tempdir(), 97 | gisBase = gisBase, 98 | gisDbase = testdata$gisDbase, 99 | location = "nc_basic_spm_grass7", 100 | mapset = "PERMANENT", 101 | override = TRUE 102 | ) 103 | res <- capture.output({ 104 | x <- execGRASS("g.list", type = "raster", intern = TRUE) 105 | } 106 | ) 107 | expect_length(res, 0) 108 | 109 | # restore defaults 110 | set.stop_on_no_flags_parasOption(origEchoCmd) 111 | }) 112 | 113 | test_that("testing useInternOption option", { 114 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 115 | origUseIntern <- get.useInternOption() 116 | 117 | # testing echoCmdOption (set to FALSE by default) 118 | loc <- initGRASS( 119 | home = tempdir(), 120 | gisBase = gisBase, 121 | gisDbase = testdata$gisDbase, 122 | location = "nc_basic_spm_grass7", 123 | mapset = "PERMANENT", 124 | override = TRUE 125 | ) 126 | expect_false(get.useInternOption()) 127 | res <- execGRASS("g.list", type = "raster") 128 | expect_true(res == 0) 129 | 130 | # test echoCmdOption set to TRUE 131 | set.useInternOption(TRUE) 132 | expect_true(get.useInternOption()) 133 | res <- execGRASS("g.list", type = "raster") 134 | expect_length(res, 7) 135 | 136 | # restore defaults 137 | set.useInternOption(origUseIntern) 138 | }) 139 | 140 | test_that("testing legacyExecOption option", { 141 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 142 | origLegacyExec <- get.legacyExecOption() 143 | 144 | # testing echoCmdOption (set to FALSE by default) 145 | loc <- initGRASS( 146 | home = tempdir(), 147 | gisBase = gisBase, 148 | gisDbase = testdata$gisDbase, 149 | location = "nc_basic_spm_grass7", 150 | mapset = "PERMANENT", 151 | override = TRUE 152 | ) 153 | 154 | # test legacyExecOption set to FALSE (uses system2 which returns resOut and resErr) 155 | # default set to FALSE on nix and TRUE on windows 156 | if (.Platform$OS.type != "windows") { 157 | expect_false(get.legacyExecOption()) 158 | } else { 159 | expect_true(get.legacyExecOption()) 160 | } 161 | 162 | res <- execGRASS("r.stats", input = "elevation", flags = c("C", "n"), 163 | ignore.stderr = TRUE) 164 | 165 | if (.Platform$OS.type != "windows") { 166 | expect_named(attributes(res), c("resOut", "resErr")) 167 | } else { 168 | expect_null(attributes(res)) 169 | } 170 | 171 | # test legacyExecOption set to TRUE (uses system only returns the module return code) 172 | set.legacyExecOption(TRUE) 173 | res <- execGRASS("r.stats", input = "elevation", flags = c("C", "n")) 174 | expect_equal(res, 0) 175 | expect_null(attributes(res)) 176 | 177 | # restore defaults 178 | set.legacyExecOption(origLegacyExec) 179 | }) 180 | 181 | test_that("testing defaultFlagsOption option", { 182 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 183 | origDefaultFlags <- get.defaultFlagsOption() 184 | 185 | # testing echoCmdOption (set to FALSE by default) 186 | loc <- initGRASS( 187 | home = tempdir(), 188 | gisBase = gisBase, 189 | gisDbase = testdata$gisDbase, 190 | location = "nc_basic_spm_grass7", 191 | mapset = "PERMANENT", 192 | override = TRUE 193 | ) 194 | 195 | # test defaultFlagsOption set to NULL 196 | expect_null(get.defaultFlagsOption()) 197 | 198 | # test defaultFlagsOption set to "verbose" 199 | set.defaultFlagsOption("verbose") 200 | expect_equal(get.defaultFlagsOption(), "verbose") 201 | 202 | # restore defaults 203 | set.defaultFlagsOption(origDefaultFlags) 204 | }) 205 | -------------------------------------------------------------------------------- /tests/testthat/test-read_RAST.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(terra) 3 | library(sp) 4 | 5 | if (!is.null(gisBase)) { 6 | loc <- initGRASS( 7 | home = tempdir(), 8 | gisBase = gisBase, 9 | gisDbase = testdata$gisDbase, 10 | location = "nc_basic_spm_grass7", 11 | mapset = "PERMANENT", 12 | override = TRUE 13 | ) 14 | } 15 | 16 | test_that("testing read_RAST using terra", { 17 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 18 | 19 | # read a categorical raster map 20 | v1 <- read_RAST("landuse", cat = TRUE, return_format = "terra") 21 | expect_s4_class(v1, "SpatRaster") 22 | expect_false(inMemory(v1)) 23 | 24 | # check the values and labels 25 | lvls <- terra::levels(v1) 26 | expect_equal(lvls[[1]]$value, 0:7) 27 | expect_equal( 28 | lvls[[1]]$label, 29 | c("undefined", "developed", "agriculture", "herbaceous", "shrubland", 30 | "forest", "water", "sediment") 31 | ) 32 | }) 33 | 34 | test_that("testing read_RAST using sp", { 35 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 36 | skip_on_ci() 37 | skip_on_cran() 38 | 39 | # check getting the location 40 | grass_crs <- execGRASS("g.proj", flags = c("w"), intern = TRUE, ignore.stderr = TRUE) 41 | grass_crs <- paste(grass_crs, collapse = "\n") 42 | 43 | crs_terra <- terra::crs(grass_crs) 44 | expect_type(crs_terra, "character") 45 | expect_equal(terra::crs(grass_crs, describe = TRUE)$code, "3358") 46 | 47 | crs_sp <- sp::CRS(terra::crs(grass_crs)) 48 | expect_s4_class(crs_sp, "CRS") 49 | 50 | grass_crs1 <- getLocationProj() 51 | expect_type(terra::crs(grass_crs1), "character") 52 | expect_equal(terra::crs(grass_crs1, describe = TRUE)$code, "3358") 53 | 54 | # test reading a raster map using sp 55 | nc_basic <- read_RAST("landuse", cat = TRUE, return_format = "SGDF") 56 | lvls <- levels(nc_basic$landuse) 57 | 58 | expect_equal( 59 | lvls, 60 | c("developed", "agriculture", "herbaceous", "shrubland", 61 | "forest", "water", "sediment") 62 | ) 63 | }) 64 | -------------------------------------------------------------------------------- /tests/testthat/test-read_VECT.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(terra) 3 | 4 | # test basic read_VECT operation 5 | test_that("testing read_VECT", { 6 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 7 | 8 | if (!is.null(gisBase)) { 9 | loc <- initGRASS( 10 | home = tempdir(), 11 | gisBase = gisBase, 12 | gisDbase = testdata$gisDbase, 13 | location = "nc_basic_spm_grass7", 14 | mapset = "PERMANENT", 15 | override = TRUE 16 | ) 17 | } 18 | 19 | # test basic read/write (using grass gdal driver, misses epsg code) 20 | schs <- read_VECT("schools") 21 | expect_s4_class(schs, "SpatVector") 22 | # expect_equal(crs(schs, describe = TRUE)$code, NA_character_) 23 | 24 | # expect failute when using gdal driver (not using grass driver) 25 | schs2 <- read_VECT("schools", use_gdal_grass_driver = FALSE) 26 | expect_s4_class(schs, "SpatVector") 27 | # expect_equal(crs(schs, describe = TRUE)$code, "3358") 28 | }) 29 | 30 | test_that("testing write_VECT", { 31 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 32 | 33 | shp <- vect(system.file("ex/lux.shp", package = "terra")) 34 | elev <- rast(system.file("ex/elev.tif", package = "terra")) 35 | 36 | loc <- initGRASS(home = tempdir(), gisBase = gisBase, SG = elev, override = TRUE) 37 | write_VECT(shp, "lux") 38 | 39 | lux <- read_VECT("lux") 40 | expect_s4_class(lux, "SpatVector") 41 | expect_equal(nrow(lux), nrow(shp)) 42 | expect_equal(ncol(lux) - 1, ncol(shp)) 43 | expect_setequal(names(lux), c("cat", names(shp))) 44 | 45 | grass_colummns <- vColumns("lux")[, 2] 46 | expect_setequal(grass_colummns, c("cat", names(shp))) 47 | }) 48 | 49 | # test basic vect2neigh operation 50 | test_that("testing vect2neigh", { 51 | skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") 52 | 53 | if (!is.null(gisBase)) { 54 | loc <- initGRASS( 55 | home = tempdir(), 56 | gisBase = gisBase, 57 | gisDbase = testdata$gisDbase, 58 | location = "nc_basic_spm_grass7", 59 | mapset = "PERMANENT", 60 | override = TRUE 61 | ) 62 | } 63 | 64 | cen_neig <- vect2neigh("census", ignore.stderr = TRUE) 65 | expect_s3_class(cen_neig, c("data.frame", "GRASSneigh", "spatial.neighbour")) 66 | expect_equal(names(cen_neig), c("left", "right", "length")) 67 | }) 68 | -------------------------------------------------------------------------------- /vignettes/OSGeo4W_QGIS_Rgui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/vignettes/OSGeo4W_QGIS_Rgui.png -------------------------------------------------------------------------------- /vignettes/OSGeo4W_QGIS_navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/vignettes/OSGeo4W_QGIS_navbar.png -------------------------------------------------------------------------------- /vignettes/OSGeo4W_QGIS_rstudio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/vignettes/OSGeo4W_QGIS_rstudio.png -------------------------------------------------------------------------------- /vignettes/OSGeo4W_Rgui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/vignettes/OSGeo4W_Rgui.png -------------------------------------------------------------------------------- /vignettes/OSGeo4W_rstudio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/vignettes/OSGeo4W_rstudio.png -------------------------------------------------------------------------------- /vignettes/coerce.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Coercion between object formats" 3 | author: "Roger Bivand" 4 | output: 5 | html_document: 6 | toc: true 7 | toc_float: 8 | collapsed: false 9 | smooth_scroll: false 10 | toc_depth: 2 11 | bibliography: refs.bib 12 | vignette: > 13 | %\VignetteIndexEntry{Coercion between object formats} 14 | %\VignetteEngine{knitr::rmarkdown} 15 | %\VignetteEncoding{UTF-8} 16 | --- 17 | 18 | ```{r setup, include=FALSE} 19 | knitr::opts_chunk$set(echo = TRUE, paged.print = FALSE) 20 | ``` 21 | 22 | ## Introduction 23 | 24 | The original R-GRASS interface [@bivand:00; @neteler+mitasova:08] was designed to move raster and later vector data between R and GRASS GIS. To do this, use was made of intermediate files, often using the external GDAL library on both sides. On the R side, the **rgdal** now archived package was used, interfacing GDAL and PROJ as GRASS GIS also did. The GRASS commands `r.in.gdal`, `r.out.gdal`, `v.in.ogr` and `v.out.ogr` were matched by **rgdal** functions using the same underlying external libraries: 25 | 26 | 27 | ```{r, out.width=500, echo=FALSE} 28 | knitr::include_graphics("fig1.png") 29 | ``` 30 | 31 | GDAL was supplemented for raster data by simply reading and writing uncompressed binary files using `r.in.bin` and `r.out.bin`, with custom functions on the R side. As then written, the R-GRASS interface used **sp** classes for both raster and vector data, supplemented more recently with **sf** classes for vector data only. 32 | 33 | The current version of the R-GRASS interface has been simplified to use the **terra** package because it, like **sf** and **rgdal** before it, links to the important external libraries. The workhorse driver is known as `RRASTER`, and has been widely used in **raster** and **terra** (see also (https://rspatial.org)). It uses GDAL but writes a flat uncompressed binary file. Using `terra::rast()` also appears to preserve category names and colour tables, but needs further testing (see (https://github.com/osgeo/rgrass/issues/42)). 34 | 35 | ```{r, out.width=500, echo=FALSE} 36 | knitr::include_graphics("fig2_p7_RRASTER_GRASS.png") 37 | ``` 38 | 39 | From GDAL 3.5.0, the `RRASTER` driver also supports WKT2_2019 CRS representations; in earlier versions of GDAL, the driver only supported the proj-string representation (https://github.com/osgeo/rgrass/issues/51). 40 | 41 | These changes mean that users transferring data between R and GRASS will need to coerce between **terra** classes `SpatVector` and `SpatRaster` and the class system of choice. In addition, `SpatRaster` is only read into memory from file when this is required, so requiring some care. 42 | 43 | ## Loading and attaching packages 44 | 45 | This vignette is constructed conditioning on the availability of aforementioned R packages, i.e. if some were missing at the time of package building, some code blocks will not be displayed. 46 | 47 | 48 | ```{r include=FALSE, message=FALSE} 49 | terra_available <- requireNamespace("terra", quietly = TRUE) 50 | sf_available <- requireNamespace("sf", quietly = TRUE) 51 | sp_available <- requireNamespace("sp", quietly = TRUE) 52 | stars_available <- requireNamespace("stars", quietly = TRUE) && packageVersion("stars") > "0.5.4" 53 | raster_available <- requireNamespace("raster", quietly = TRUE) 54 | ``` 55 | 56 | On loading and attaching, **terra** displays its version: 57 | 58 | ```{r, eval=terra_available} 59 | library("terra") 60 | ``` 61 | 62 | ```{r, eval=sf_available} 63 | library("sf") 64 | ``` 65 | 66 | ```{r, eval=sp_available} 67 | library("sp") 68 | ``` 69 | 70 | ```{r, eval=stars_available} 71 | library("stars") 72 | ``` 73 | 74 | ```{r, eval=raster_available} 75 | library("raster") 76 | ``` 77 | 78 | `terra::gdal()` tells us the versions of the external libraries being used by **terra**: 79 | 80 | ```{r, eval=terra_available} 81 | gdal(lib = "all") 82 | ``` 83 | 84 | When using CRAN binary packages built static for Windows and macOS, the R packages will use the same versions of the external libraries, but not necessarily the same versions as those against which GRASS was installed. 85 | 86 | 87 | 88 | ## `"SpatVector"` coercion 89 | 90 | In the **terra** package [@terra], vector data are held in `"SpatVector"` objects. This means that when `read_VECT()` is used, a `"SpatVector"` object is returned, and the same class of object is needed for `write_VECT()` for writing to GRASS. 91 | 92 | 93 | ```{r, eval=terra_available} 94 | fv <- system.file("ex/lux.shp", package = "terra") 95 | (v <- vect(fv)) 96 | ``` 97 | 98 | These objects are always held in memory, so there is no `inMemory()` method: 99 | 100 | ```{r, , eval=terra_available} 101 | try(inMemory(v)) 102 | ``` 103 | 104 | The coordinate reference system is expressed in WKT2-2019 form: 105 | 106 | ```{r, , eval=terra_available} 107 | cat(crs(v), "\n") 108 | ``` 109 | 110 | ### `"sf"` 111 | 112 | Most new work should use vector classes defined in the **sf** package [@sf; @sf-rj]. In this case, coercion uses `st_as_sf()`: 113 | 114 | ```{r, eval=(terra_available && sf_available)} 115 | v_sf <- st_as_sf(v) 116 | v_sf 117 | ``` 118 | 119 | and the `vect()` method to get from **sf** to **terra**: 120 | 121 | ```{r, eval=(terra_available && sf_available)} 122 | v_sf_rt <- vect(v_sf) 123 | v_sf_rt 124 | ``` 125 | 126 | ```{r, eval=(terra_available && sf_available)} 127 | all.equal(v_sf_rt, v, check.attributes = FALSE) 128 | ``` 129 | 130 | ### `"Spatial"` 131 | 132 | To coerce to and from vector classes defined in the **sp** package [@asdar], methods in **raster** are used as an intermediate step: 133 | 134 | ```{r, eval=(terra_available && raster_available && sp_available)} 135 | v_sp <- as(v, "Spatial") 136 | print(summary(v_sp)) 137 | ``` 138 | 139 | ```{r, eval=(terra_available && sf_available && sp_available)} 140 | v_sp_rt <- vect(st_as_sf(v_sp)) 141 | all.equal(v_sp_rt, v, check.attributes = FALSE) 142 | ``` 143 | 144 | ## `"SpatRaster"` coercion 145 | 146 | In the **terra** package, raster data are held in `"SpatRaster"` objects. This means that when `read_RAST()` is used, a `"SpatRaster"` object is returned, and the same class of object is needed for `write_RAST()` for writing to GRASS. 147 | 148 | ```{r, eval=terra_available} 149 | fr <- system.file("ex/elev.tif", package = "terra") 150 | (r <- rast(fr)) 151 | ``` 152 | 153 | In general, `"SpatRaster"` objects are files, rather than data held in memory: 154 | 155 | ```{r, eval=terra_available} 156 | try(inMemory(r)) 157 | ``` 158 | 159 | ### `"stars"` 160 | 161 | The **stars** package [@stars] uses GDAL through **sf**. A coercion method is provided from `"SpatRaster"` to `"stars"`: 162 | 163 | ```{r, eval=(terra_available && stars_available)} 164 | r_stars <- st_as_stars(r) 165 | print(r_stars) 166 | ``` 167 | which round-trips in memory. 168 | 169 | ```{r, eval=(terra_available && stars_available)} 170 | (r_stars_rt <- rast(r_stars)) 171 | ``` 172 | 173 | When coercing to `"stars_proxy"` the same applies: 174 | 175 | ```{r, eval=(terra_available && stars_available)} 176 | (r_stars_p <- st_as_stars(r, proxy = TRUE)) 177 | ``` 178 | with coercion from `"stars_proxy"` also not reading data into memory: 179 | 180 | ```{r, eval=(terra_available && stars_available)} 181 | (r_stars_p_rt <- rast(r_stars_p)) 182 | ``` 183 | 184 | ### `"RasterLayer"` 185 | 186 | From version 3.6-3 the **raster** package [@raster] uses **terra** for all GDAL operations. Because of this, coercing a `"SpatRaster"` object to a `"RasterLayer"` object is simple: 187 | 188 | ```{r, eval=(terra_available && raster_available)} 189 | (r_RL <- raster(r)) 190 | ``` 191 | ```{r, eval=(terra_available && raster_available)} 192 | inMemory(r_RL) 193 | ``` 194 | 195 | The WKT2-2019 CRS representation is present but not shown by default: 196 | 197 | ```{r, eval=(terra_available && raster_available)} 198 | cat(wkt(r_RL), "\n") 199 | ``` 200 | 201 | This object (held on file rather than in memory) can be round-tripped: 202 | 203 | ```{r, eval=(terra_available && raster_available)} 204 | (r_RL_rt <- rast(r_RL)) 205 | ``` 206 | 207 | ### `"Spatial"` 208 | 209 | `"RasterLayer"` objects can be used for coercion from a `"SpatRaster"` object to a `"SpatialGridDataFrame"` object: 210 | 211 | ```{r, eval=(terra_available && raster_available && sp_available)} 212 | r_sp_RL <- as(r_RL, "SpatialGridDataFrame") 213 | summary(r_sp_RL) 214 | ``` 215 | 216 | The WKT2-2019 CRS representation is present but not shown by default: 217 | 218 | ```{r, eval=(terra_available && raster_available && sp_available)} 219 | cat(wkt(r_sp_RL), "\n") 220 | ``` 221 | 222 | This object can be round-tripped, but use of **raster** forefronts the Proj.4 string CRS representation: 223 | ```{r, eval=(terra_available && raster_available && sp_available)} 224 | (r_sp_RL_rt <- raster(r_sp_RL)) 225 | cat(wkt(r_sp_RL_rt), "\n") 226 | ``` 227 | 228 | 229 | ```{r, eval=(terra_available && raster_available && sp_available)} 230 | (r_sp_rt <- rast(r_sp_RL_rt)) 231 | ``` 232 | ```{r, eval=(terra_available && raster_available && sp_available)} 233 | crs(r_sp_RL_rt) 234 | ``` 235 | 236 | Coercion to the **sp** `"SpatialGridDataFrame"` representation is also provided by **stars**: 237 | 238 | ```{r, eval=(terra_available && stars_available && sp_available)} 239 | r_sp_stars <- as(r_stars, "Spatial") 240 | summary(r_sp_stars) 241 | ``` 242 | 243 | ```{r, eval=(terra_available && stars_available && sp_available)} 244 | cat(wkt(r_sp_stars), "\n") 245 | ``` 246 | 247 | and can be round-tripped: 248 | 249 | ```{r, eval=(terra_available && stars_available && sp_available)} 250 | (r_sp_stars_rt <- rast(st_as_stars(r_sp_stars))) 251 | ``` 252 | `` 253 | ```{r, eval=(terra_available && stars_available && sp_available)} 254 | cat(crs(r_sp_rt), "\n") 255 | ``` 256 | 257 | ## References 258 | -------------------------------------------------------------------------------- /vignettes/fig1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/vignettes/fig1.png -------------------------------------------------------------------------------- /vignettes/fig2_p7_RRASTER_GRASS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/vignettes/fig2_p7_RRASTER_GRASS.png -------------------------------------------------------------------------------- /vignettes/refs.bib: -------------------------------------------------------------------------------- 1 | @Book{neteler+mitasova:08, 2 | author = {M. Neteler and H. Mitasova}, 3 | title = {Open Source {GIS}: A {GRASS} {GIS} Approach, Third Edition}, 4 | year = {2008}, 5 | publisher = {Springer}, 6 | address = {New York} 7 | } 8 | 9 | @article{bivand:00, 10 | author = {R. S. Bivand}, 11 | title = {Using the {R} statistical data analysis language on {GRASS} 5.0 {GIS} data base files}, 12 | journal = {Computers and Geosciences}, 13 | volume = {26}, 14 | pages = {1043--1052}, 15 | year = {2000} 16 | } 17 | 18 | @incollection{bivand:14, 19 | author = {R. S. Bivand}, 20 | editor = {Robert J. Abrahart and Linda See}, 21 | title = {GeoComputation and Open-Source Software : Components and Software Component Stacks}, 22 | booktitle = {GeoComputation (Second Edition)}, 23 | year = {2014}, 24 | publisher = {CRC Press}, 25 | address = {Boca Raton, FL}, 26 | pages = {329--255} 27 | } 28 | @Book{asdar, 29 | author = {Roger S. Bivand and Edzer Pebesma and Virgilio 30 | Gomez-Rubio}, 31 | title = {Applied spatial data analysis with {R}, Second edition}, 32 | year = {2013}, 33 | publisher = {Springer, NY}, 34 | url = {https://asdar-book.org/} 35 | } 36 | @Manual{rgdal, 37 | title = {{rgdal}: Bindings for the 'Geospatial' Data Abstraction Library}, 38 | author = {Roger Bivand and Tim Keitt and Barry Rowlingson}, 39 | year = {2022}, 40 | note = {R package version 1.5-32}, 41 | url = {https://cran.r-project.org/package=rgdal} 42 | } 43 | @Manual{raster, 44 | title = {{raster}: Geographic Data Analysis and Modeling}, 45 | author = {Robert J. Hijmans}, 46 | year = {2022}, 47 | note = {R package version 3.5-21}, 48 | url = {https://cran.r-project.org/package=raster}, 49 | } 50 | @Manual{terra, 51 | title = {{terra}: Spatial Data Analysis}, 52 | author = {Robert J. Hijmans}, 53 | year = {2022}, 54 | note = {R package version 1.6-0}, 55 | url = {https://cran.r-project.org/package=terra} 56 | } 57 | @Manual{sf, 58 | title = {{sf}: Simple Features for {R}}, 59 | author = {Edzer Pebesma}, 60 | year = {2022}, 61 | note = {R package version 1.0.8}, 62 | url = {https://cran.r-project.org/package=sf} 63 | } 64 | @Article{sf-rj, 65 | author = {Edzer Pebesma}, 66 | title = {{Simple Features for {R}: Standardized Support for Spatial 67 | Vector Data}}, 68 | year = {2018}, 69 | journal = {{The R Journal}}, 70 | doi = {10.32614/RJ-2018-009}, 71 | url = {https://doi.org/10.32614/RJ-2018-009}, 72 | pages = {439--446}, 73 | volume = {10}, 74 | number = {1}, 75 | } 76 | 77 | @Manual{stars, 78 | title = {{stars}: Spatiotemporal Arrays, Raster and Vector Data Cubes}, 79 | author = {Edzer Pebesma}, 80 | year = {2021}, 81 | note = {R package version 0.5-5}, 82 | url = {https://CRAN.R-project.org/package=stars}, 83 | } 84 | 85 | @online{pebesma_r-spatial_2022, 86 | title = {{R-spatial} Evolution: Retirement of {rgdal}, {rgeos} and {maptools}}, 87 | author = {Pebesma, Edzer and Bivand, Roger}, 88 | date = {2022}, 89 | url = {https://r-spatial.org/r/2022/04/12/evolution.html}, 90 | urldate = {2022-11-10} 91 | } 92 | -------------------------------------------------------------------------------- /vignettes/rstudio_in_GRASS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSGeo/rgrass/636ba767478fb84ce55adc72c4f5bff9f1d18557/vignettes/rstudio_in_GRASS.png --------------------------------------------------------------------------------