tests/testthat/test_pvts_mosaic.R

library(testthat)
library(PVts)
library(raster)

context("pvts_mosaicfreecloud")

test_that("pvts_mosaicfreecloud works - stars", {
  data("pvts_datasets")
  x = pvts_datasets$mosaic[,1:100,1:100]
  time = as.Date(c("2016-07-30","2016-08-15","2016-09-16"))
  CLUSTER = NULL
  f1 = pvts_mosaicfreecloud(x,time,CLUSTER)
  test_value = round(mean(getValues(f1),na.rm=T))
  expect_equal(test_value, 88)
})

test_that("pvts_mosaicfreecloud works - RasterStack", {
  data("pvts_datasets")
  landsat8images <- as(pvts_datasets$mosaic[,1:100,1:100] %>% merge,'Raster')
  x = stack(landsat8images)
  time = as.Date(c("2016-07-30","2016-08-15","2016-09-16"))
  CLUSTER = NULL
  f1 = pvts_mosaicfreecloud(x,time,CLUSTER)
  test_value = round(mean(getValues(f1),na.rm=T))
  expect_equal(test_value, 88)
})

test_that("pvts_mosaicfreecloud works - RasterBrick", {
  data("pvts_datasets")
  landsat8images <- as(pvts_datasets$mosaic[,1:100,1:100] %>% merge,'Raster')
  x = landsat8images
  time = as.Date(c("2016-07-30","2016-08-15","2016-09-16"))
  CLUSTER = NULL
  f1 = pvts_mosaicfreecloud(x,time,CLUSTER)
  test_value = round(mean(getValues(f1),na.rm=T))
  expect_equal(test_value, 88)
})
pvts-approach/PVts documentation built on July 1, 2019, 4:59 p.m.