diff --git a/R/spatial_non_supported.R b/R/spatial_non_supported.R index 5850f261c..5bbbb92a1 100644 --- a/R/spatial_non_supported.R +++ b/R/spatial_non_supported.R @@ -1,19 +1,19 @@ #' @export tmapGetShapeMeta1.default = function(shp, o) { - stop("Specified shp argument of tm_shape is a ", class(shp)[1], ", which is a recognized/supported spatial data class.", call. = FALSE) + stop("Specified shp argument of tm_shape is a ", class(shp)[1], ", which is not a recognized/supported spatial data class.", call. = FALSE) } #' @export tmapGetShapeMeta2.default = function(shp, smeta, o) { - stop("Specified shp argument of tm_shape is a ", class(shp)[1], ", which is a recognized/supported spatial data class.", call. = FALSE) + stop("Specified shp argument of tm_shape is a ", class(shp)[1], ", which is not a recognized/supported spatial data class.", call. = FALSE) } #' @export tmapSubsetShp.default = function(shp, vars) { - stop("Specified shp argument of tm_shape is a ", class(shp)[1], ", which is a recognized/supported spatial data class.", call. = FALSE) + stop("Specified shp argument of tm_shape is a ", class(shp)[1], ", which is not a recognized/supported spatial data class.", call. = FALSE) } #' @export tmapShape.default = function(shp, is.main, crs, bbox, unit, filter, shp_name, smeta, o, tmf) { - stop("Specified shp argument of tm_shape is a ", class(shp)[1], ", which is a recognized/supported spatial data class.", call. = FALSE) + stop("Specified shp argument of tm_shape is a ", class(shp)[1], ", which is not a recognized/supported spatial data class.", call. = FALSE) } diff --git a/R/tm_layers_raster.R b/R/tm_layers_raster.R index 8a94eb91f..ba25d84bc 100644 --- a/R/tm_layers_raster.R +++ b/R/tm_layers_raster.R @@ -36,7 +36,7 @@ #' @example ./examples/tm_raster.R #' @export tm_raster = function(col = tm_vars(), - col.scale = tm_scale(value.na = "#00000000"), + col.scale = tm_scale(), col.legend = tm_legend(), col.chart = tm_chart_none(), col.free = NA, diff --git a/R/tmapScale_misc.R b/R/tmapScale_misc.R index 72fee8635..1ff78aeb2 100644 --- a/R/tmapScale_misc.R +++ b/R/tmapScale_misc.R @@ -39,7 +39,8 @@ get_scale_defaults = function(scale, o, aes, layer, cls, ct = NULL) { m = getPalMeta(as.character(values[1])) ona = getAesOption("value.na", o, aes, layer, cls = cls) - if ((!is.na(ona) && "value.na" %in% scale$called) || is.null(m)) { + # take option value.na instead of cols4all palette na-color in these three cases: + if ((!is.na(ona) && "value.na" %in% scale$called) || is.null(m) || substr(ona, 8, 9) == "00") { ona } else{ getPalNA(as.character(values[1])) diff --git a/tests/testthat/test-terra-stars.R b/tests/testthat/test-terra-stars.R index 1586c0687..d0227861a 100644 --- a/tests/testthat/test-terra-stars.R +++ b/tests/testthat/test-terra-stars.R @@ -1,6 +1,6 @@ test_that("terra works", { - + skip_on_cran() skip_if_not_installed("spDataLarge") landsat = terra::rast(system.file("raster/landsat.tif", package = "spDataLarge")) @@ -9,44 +9,44 @@ test_that("terra works", { land_terra = terra::rast(tmap::land) names(land_terra) <- names(tmap::land) tm_shape(land_terra) + tm_raster("trees") - + expect_snapshot(error = TRUE, { tm_shape(land_terra) + tm_raster("treess") }) - + # FIXME this is not expected. - + tm_shape(landsat) + - tm_rgb(tm_vars(c("landsat_4", "landsat_3", "landsat_2"), multivariate = TRUE), col.scale = tm_scale_rgb(maxColorValue = 31961)) + tm_rgb(tm_vars(c("landsat_4", "landsat_3", "landsat_2"), multivariate = TRUE), col.scale = tm_scale_rgb(max_color_value = 31961)) # Defaults of stars and terra are identical. tm_shape(landsat) + tm_raster(col.free = FALSE) tm_shape(landsat) + - tm_raster(c("landsat_1", "landsat_2", "landsat_3", "landsat_4"), col.free = FALSE) + + tm_raster(c("landsat_1", "landsat_2", "landsat_3", "landsat_4"), col.free = FALSE) + tm_options(max.raster = 10000) - + skip_on_os("linux") tm_shape(landsat) + tm_raster("landsat_1", col.free = FALSE) - + }) test_that("stars works", { - + skip_on_cran() skip_if_not_installed("spDataLarge") landsat = stars::read_stars(system.file("raster/landsat.tif", package = "spDataLarge")) land_stars = tmap::land - + tm_shape(land_stars) + tm_raster("trees") - + tm_shape(land_stars) + tm_raster("treess") - + # Fixed (issue #789) - # Removed the argument raster.warp from v4, because it is not useful. + # Removed the argument raster.warp from v4, because it is not useful. # Now the first strategy is warp (st_warp) and if unsuccessful, # then throw a warning and try a (slow) transformation (st_transform). # Somehow, the warp won't work with "robin". However, with crs = "+proj=eck4" is does work. expect_no_warning(tm_shape(landsat) + tm_raster("landsat.tif", col.free = FALSE)) - + p <- tm_shape(landsat) + tm_raster(col.free = FALSE) tm_shape(landsat) + tm_raster("landsat.tif") + @@ -66,10 +66,10 @@ test_that("multi rast works.", { tm_shape(multi_rast[[3:1]]) + tm_rgb() }) - + tm_shape(multi_rast) + - tm_rgb(tm_vars(c("landsat_4", "landsat_3", "landsat_2"), multivariate = TRUE), col.scale = tm_scale_rgb(maxColorValue = 31961)) - + tm_rgb(tm_vars(c("landsat_4", "landsat_3", "landsat_2"), multivariate = TRUE), col.scale = tm_scale_rgb(max_color_value = 31961)) + }) test_that("Both approaches work for stars.", { @@ -79,11 +79,11 @@ test_that("Both approaches work for stars.", { # direct approach landsat_stars = stars::read_stars(system.file("raster/landsat.tif", package = "spDataLarge")) expect_no_condition(tm_shape(landsat_stars) + - tm_rgb(tm_vars("band", dimvalues = c(4,3,2)), col.scale = tm_scale_rgb(maxColorValue = 31961)) + tm_rgb(tm_vars("band", dimvalues = c(4,3,2)), col.scale = tm_scale_rgb(max_color_value = 31961)) ) - + # indirect approach landsat_stars2 = split(landsat_stars, "band") tm_shape(landsat_stars2) + - tm_rgb(tm_vars(c("X4", "X3", "X2"), multivariate = TRUE), col.scale = tm_scale_rgb(maxColorValue = 31961)) + tm_rgb(tm_vars(c("X4", "X3", "X2"), multivariate = TRUE), col.scale = tm_scale_rgb(max_color_value = 31961)) })