diff --git a/.github/workflows/rcmdcheck.yml b/.github/workflows/rcmdcheck.yml new file mode 100644 index 0000000..018bc31 --- /dev/null +++ b/.github/workflows/rcmdcheck.yml @@ -0,0 +1,53 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: rcmdcheck + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-tinytex@v2 + + - name: Install additional LaTeX packages + run: tlmgr install grfext multirow caption setspace + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true diff --git a/.github/workflows/tic.yml b/.github/workflows/tic.yml deleted file mode 100644 index 6fb12a2..0000000 --- a/.github/workflows/tic.yml +++ /dev/null @@ -1,145 +0,0 @@ -## tic GitHub Actions template: linux-macos-windows-deploy -## revision date: 2020-12-11 -on: - workflow_dispatch: - push: - pull_request: - # for now, CRON jobs only run on the default branch of the repo (i.e. usually on master) - schedule: - # * is a special character in YAML so you have to quote this string - - cron: "0 4 * * *" - -name: tic - -jobs: - all: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - # use a different tic template type if you do not want to build on all listed platforms - - { os: windows-latest, r: "release" } - - { os: macOS-latest, r: "release", pkgdown: "true", latex: "true" } - - { os: ubuntu-latest, r: "devel", latex: "true" } - - { os: ubuntu-latest, r: "release", latex: "true" } - - env: - # otherwise remotes::fun() errors cause the build to fail. Example: Unavailability of binaries - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - CRAN: ${{ matrix.config.cran }} - # make sure to run `tic::use_ghactions_deploy()` to set up deployment - TIC_DEPLOY_KEY: ${{ secrets.TIC_DEPLOY_KEY }} - # prevent rgl issues because no X11 display is available - RGL_USE_NULL: true - # if you use bookdown or blogdown, replace "PKGDOWN" by the respective - # capitalized term. This also might need to be done in tic.R - BUILD_PKGDOWN: ${{ matrix.config.pkgdown }} - # macOS >= 10.15.4 linking - SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk - # use GITHUB_TOKEN from GitHub to workaround rate limits in {remotes} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v3 - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - Ncpus: 4 - rtools-version: '42' - - # LaTeX. Installation time: - # Linux: ~ 1 min - # macOS: ~ 1 min 30s - # Windows: never finishes - - uses: r-lib/actions/setup-tinytex@v2 - if: matrix.config.latex == 'true' - - - uses: r-lib/actions/setup-pandoc@v2 - - # set date/week for use in cache creation - # https://github.community/t5/GitHub-Actions/How-to-set-and-access-a-Workflow-variable/m-p/42970 - # - cache R packages daily - - name: "[Cache] Prepare daily timestamp for cache" - if: runner.os != 'Windows' - id: date - run: echo "::set-output name=date::$(date '+%d-%m')" - - - name: "[Cache] Cache R packages" - if: runner.os != 'Windows' - uses: pat-s/always-upload-cache@v2.1.3 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}} - restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}} - - # for some strange Windows reason this step and the next one need to be decoupled - - name: "[Stage] Prepare" - run: | - Rscript -e "if (!requireNamespace('remotes')) install.packages('remotes', type = 'source')" - Rscript -e "if (getRversion() < '3.2' && !requireNamespace('curl')) install.packages('curl', type = 'source')" - - - name: "[Custom block] [Linux] Install spatial libraries" - if: runner.os == 'Linux' - run: sudo apt-get install libgdal-dev libproj-dev libgeos-dev libudunits2-dev - - - name: "[Custom block] [macOS] Install spatial libraries" - if: runner.os == 'macOS' - run: | - # conflicts with gfortran from r-lib/actions when linking gcc - #rm '/usr/local/bin/gfortran' - brew install pkg-config gdal proj geos - - - name: "[Stage] [Linux] Install curl and libgit2" - if: runner.os == 'Linux' - run: sudo apt install libcurl4-openssl-dev libgit2-dev texlive-fonts-recommended texlive-latex-recommended texlive-latex-extra - - - name: "[Stage] [macOS] Install libgit2" - if: runner.os == 'macOS' - run: brew install libgit2 - - - name: "[Stage] [macOS] Install system libs for pkgdown" - if: runner.os == 'macOS' && matrix.config.pkgdown != '' - run: brew install harfbuzz fribidi - - - name: "[Stage] [Linux] Install system libs for pkgdown" - if: runner.os == 'Linux' && matrix.config.pkgdown != '' - run: sudo apt install libharfbuzz-dev libfribidi-dev - - - name: "[Stage] Install" - if: matrix.config.os != 'macOS-latest' || matrix.config.r != 'devel' - run: Rscript -e "remotes::install_github('ropensci/tic')" -e "print(tic::dsl_load())" -e "tic::prepare_all_stages()" -e "tic::before_install()" -e "tic::install()" - - # macOS devel needs its own stage because we need to work with an option to suppress the usage of binaries - - name: "[Stage] Prepare & Install (macOS-devel)" - if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'devel' - run: | - echo -e 'options(Ncpus = 4, pkgType = "source", repos = structure(c(CRAN = "https://cloud.r-project.org/")))' > $HOME/.Rprofile - Rscript -e "remotes::install_github('ropensci/tic')" -e "print(tic::dsl_load())" -e "tic::prepare_all_stages()" -e "tic::before_install()" -e "tic::install()" - - - name: "[Stage] Script" - run: Rscript -e 'tic::script()' - - - name: "[Stage] After Success" - if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'release' - run: Rscript -e "tic::after_success()" - - - name: "[Stage] Upload R CMD check artifacts" - if: failure() - uses: actions/upload-artifact@v2.2.1 - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check - - name: "[Stage] Before Deploy" - run: | - Rscript -e "tic::before_deploy()" - - - name: "[Stage] Deploy" - run: Rscript -e "tic::deploy()" - - - name: "[Stage] After Deploy" - run: Rscript -e "tic::after_deploy()" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1ae24cf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: r -sudo: required -dist: trusty -cache: -# - packages - - ccache - -r: - - release - - devel - - oldrel - -addons: - apt: - sources: - - sourceline: 'ppa:ubuntugis/ubuntugis-unstable' - packages: - - devscripts # checkbashisms - - libgdal-dev - - libproj-dev - - libgeos-dev - - libudunits2-dev - - libnetcdf-dev - - netcdf-bin diff --git a/NEWS.md b/NEWS.md index 451e43d..a360735 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# version 2.1-2 + +* `variogram()` supports `stars` (raster) objects, benefiting from them being gridded + +# version 2.1-1 + # version 2.1-0 * import `sftime`; modify `krigeST()` variogram functions to accept `sftime` objects for `data` (as alternative to `STI` or `STIDF`), and `stars` or `sftime` objects for `newdata`; #108 with great help from @henningte diff --git a/R/variogram.formula.R b/R/variogram.formula.R index aec65c6..7e9806f 100644 --- a/R/variogram.formula.R +++ b/R/variogram.formula.R @@ -3,7 +3,7 @@ "variogram.formula" <- function (object, locations = coordinates(data), data, ...) { - if ((missing(locations) && inherits(data, "sf")) || (inherits(locations, "sf"))) { + if ((missing(locations) && inherits(data, c("sf", "stars"))) || (inherits(locations, c("sf", "stars")))) { if (!requireNamespace("sf", quietly = TRUE)) stop("sf required: install that first") # nocov if (missing(locations)) diff --git a/README.md b/README.md index 06a4ff8..750c6b5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ gstat ===== -[![R-CMD-check](https://github.com/r-spatial/gstat/workflows/tic/badge.svg)](https://github.com/r-spatial/gstat/actions) +[![R-CMD-check](https://github.com/r-spatial/gstat/workflows/rcmdcheck/badge.svg)](https://github.com/r-spatial/gstat/actions/workflows/rcmdcheck.yml) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/r-spatial/gstat?branch=master&svg=true)](https://ci.appveyor.com/project/edzerpebesma/gstat) [![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html) [![CRAN](http://www.r-pkg.org/badges/version/gstat)](https://cran.r-project.org/package=gstat) diff --git a/man/vgm.Rd b/man/vgm.Rd index 3aef5a8..606e625 100644 --- a/man/vgm.Rd +++ b/man/vgm.Rd @@ -20,8 +20,9 @@ as.vgm.variomodel(m) } \arguments{ \item{psill}{ (partial) sill of the variogram model component, or model: see Details } -\item{model}{ model type, e.g. "Exp", "Sph", "Gau", "Mat". Calling vgm() without -a model argument returns a data.frame with available models. } +\item{model}{ model type, e.g. "Exp", "Sph", "Gau", or "Mat". Can be a character vector of model +types combined with c(), e.g. c("Exp", "Sph"), in which case the best fitting is returned. +Calling vgm() without a model argument returns a data.frame with available models. } \item{range}{ range parameter of the variogram model component; in case of anisotropy: major range } \item{kappa}{ smoothness parameter for the Matern class of variogram models } @@ -59,7 +60,7 @@ to vgm. } \author{ Edzer Pebesma } \details{ If only the first argument (\code{psill}) is given a -\code{character} value indicating a model, as in \code{vgm("Sph")}, +\code{character} value/vector indicating one or more models, as in \code{vgm("Sph")}, then this taken as a shorthand form of \code{vgm(NA,"Sph",NA,NA)}, i.e. a spherical variogram with nugget and unknown parameter values; see examples below. Read \link{fit.variogram} to find out how diff --git a/tests/unproj.R b/tests/unproj.R index c609f74..95d0164 100644 --- a/tests/unproj.R +++ b/tests/unproj.R @@ -4,7 +4,9 @@ suppressPackageStartupMessages(library(sp)) library(gstat) -if (require(sp, quietly = TRUE) && require(fields, quietly = TRUE) && require(sf, quietly = TRUE)) { +if (require(sp, quietly = TRUE) && + suppressPackageStartupMessages(require(fields, quietly = TRUE)) && + suppressPackageStartupMessages(require(sf, quietly = TRUE))) { data(meuse) coordinates(meuse) = ~x+y proj4string(meuse) = CRS("+init=epsg:28992") diff --git a/tests/unproj.Rout.save b/tests/unproj.Rout.save index 952daa6..a66be11 100644 --- a/tests/unproj.Rout.save +++ b/tests/unproj.Rout.save @@ -1,6 +1,6 @@ -R version 4.2.3 (2023-03-15) -- "Shortstop Beagle" -Copyright (C) 2023 The R Foundation for Statistical Computing +R version 4.3.3 (2024-02-29) -- "Angel Food Cake" +Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -21,7 +21,9 @@ Type 'q()' to quit R. > suppressPackageStartupMessages(library(sp)) > library(gstat) > -> if (require(sp, quietly = TRUE) && require(fields, quietly = TRUE) && require(sf, quietly = TRUE)) { +> if (require(sp, quietly = TRUE) && ++ suppressPackageStartupMessages(require(fields, quietly = TRUE)) && ++ suppressPackageStartupMessages(require(sf, quietly = TRUE))) { + data(meuse) + coordinates(meuse) = ~x+y + proj4string(meuse) = CRS("+init=epsg:28992") @@ -72,21 +74,6 @@ Type 'q()' to quit R. + cat('==========\nspDistsN1 Distances:\n') + print(spDistsN1(coordinates(foo), coordinates(foo)[1,], longlat=TRUE)) + } -Spam version 2.9-1 (2022-08-07) is loaded. -Type 'help( Spam)' or 'demo( spam)' for a short introduction -and overview of this package. -Help for individual functions is also obtained by adding the -suffix '.spam' to the function name, e.g. 'help( chol.spam)'. - -Attaching package: 'spam' - -The following objects are masked from 'package:base': - - backsolve, forwardsolve - - -Try help(fields) to get started. -Linking to GEOS 3.11.1, GDAL 3.6.2, PROJ 9.1.1; sf_use_s2() is TRUE ========== variogram: dist gamma dir.hor dir.ver id left right @@ -106,4 +93,4 @@ In CPL_crs_from_input(x) : > > proc.time() user system elapsed - 2.028 0.818 1.946 + 1.466 1.314 1.282 diff --git a/tic.R b/tic.R deleted file mode 100644 index 492701d..0000000 --- a/tic.R +++ /dev/null @@ -1,8 +0,0 @@ -# installs dependencies, runs R CMD check, runs covr::codecov() -do_package_checks() - -if (ci_on_ghactions() && ci_has_env("BUILD_PKGDOWN")) { - # creates pkgdown site and pushes to gh-pages branch - # only for the runner with the "BUILD_PKGDOWN" env var set - do_pkgdown() -}