Skip to content

Commit

Permalink
Fixing pipeline (1)
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstiDE committed Jan 16, 2024
1 parent 75e21d9 commit 3f21f67
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 15 deletions.
4 changes: 0 additions & 4 deletions R/ggR.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
#' When \code{img} contains factor values and \code{annotation=TRUE}, the raster values will automatically be converted
#' to numeric in order to proceed with the brightness calculation.
#'
#' The raster package provides a class lookup-table for categorical rasters (e.g. what you get if you run superClass in classification mode). If your raster has a lookup-table ggR will automatically treat it as categorical (see \link[terra]{factor}).
#' However, the factor status of Raster objects is easily lost and the values are interpreted as numeric. In such cases you should make use of the \code{forceCat = TRUE} argument, which makes sure
#' that ggplot2 uses a discrete scale, not a continuous one.
#'
#' The geom_raster argument switches from the default use of annotation_raster to geom_raster. The difference between the two is that geom_raster performs
#' a meaningful mapping from pixel values to fill colour, while annotation_raster is simply adding a picture to your plot. In practice this means that whenever you
#' need a legend for your raster you should use \code{geom_raster = TRUE}. This also allows you to specify and modify the fill scale manually.
Expand Down
2 changes: 1 addition & 1 deletion R/rasterCVA.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' Returns a SpatRaster with two layers: change vector angle and change vector magnitude
#' @export
#' @examples
#' \donttest{
#' \dontrun{
#' library(terra)
#' pca <- rasterPCA(lsat)$map
#'
Expand Down
2 changes: 1 addition & 1 deletion R/rasterPCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' @return Returns a named list containing the PCA model object ($model) and a SpatRaster with the principal component layers ($object).
#' @export
#' @examples
#' \donttest{
#' \dontrun{
#' library(ggplot2)
#' library(reshape2)
#' ggRGB(rlogo, 1,2,3)
Expand Down
2 changes: 1 addition & 1 deletion R/readMeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ readMeta <- function(file, raw = FALSE){
#' @param na Numeric vector. No-data value per band
#' @param vsat Numeric vector. Saturation value per band
#' @param scal Numeric vector. Scale factor per band. e.g. if data was scaled to 1000*reflectance for integer conversion.
#' @param dtyp Character vector. Data type per band. See \code{\link[terra]{dataType}} for options.
#' @param dtyp Character vector. Data type per band.
#' @param radRes Numeric vector. Radiometric resolution per band.
#' @param spatRes Numeric vector. Spatial resolution per band.
#' @param calrad data.frame. Calibration coefficients for dn->radiance conversion. Must have columns 'gain' and 'offset'. Rows named according to \code{bands}.
Expand Down
2 changes: 1 addition & 1 deletion man/ImageMetaData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/ggR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rasterCVA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rasterPCA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion tests/testthat/test-panSharpen.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ context("panSharpen")
library(terra)

test_that("panSharpen methods", {
skip_on_ci()
skip_on_cran()
skip_on_covr()
suppressWarnings({
agg <- aggregate(lsat, 10)
pan <- sum(lsat[[1:3]])
Expand All @@ -11,7 +14,7 @@ test_that("panSharpen methods", {
nlayers <- c(3,3,7)
names(nlayers) <- names(panList) <- meth

for(m in meth) expect_is(panList[[m]], "SpatRaster", info = m)
for(m in meth) expect_is(panList[[m]], "SpatRaster")
for(m in meth) expect_equal(names(panList[[m]]), paste0(names(agg)[1:nlayers[m]], "_pan"), info = m) # tests inmplicitly for correct number of layers
for(m in meth) expect_equal(res(panList[[m]]), res(pan), info = m)
})
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-rasterPCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ ld <- as.data.frame(lsat_t)

for(spc in c(FALSE, TRUE)) {
test_that(paste("stats::princomp(covMat(raster)) == stats::princomp(sample) with spca=",spc), {
skip_on_ci()
skip_on_cran()
skip_on_covr()
expect_s3_class(r <- rasterPCA(lsat_t, nSamples = NULL, spca = spc), c("RStoolbox", "rasterPCA"))
expect_s3_class(rs <- rasterPCA(lsat_t, nSamples = ncell(lsat_t), spca = spc), c("RStoolbox", "rasterPCA"))
expect_equal(abs(unclass(rs$model$loadings)), abs(unclass(r$model$loadings)))
Expand All @@ -22,6 +25,9 @@ for(i in seq_len(nrow(G))){
spc <- G[i,"spc"]
smpl <- if(G[i,"smpl"]) ncell(lsat_t) else NULL
test_that(paste("rasterPCA NA handling; spca =",spc, "; nSamples =", deparse(smpl)), {
skip_on_ci()
skip_on_cran()
skip_on_covr()
suppressWarnings({
expect_s3_class(r <- rasterPCA(lsat_t, nSamples = smpl, spca = spc), c("RStoolbox", "rasterPCA"))
expect_true(all(is.na(r$map[c(100:200,400:500)])))
Expand Down

0 comments on commit 3f21f67

Please sign in to comment.