-
Notifications
You must be signed in to change notification settings - Fork 125
Description
For example:
> naCountRaster
class : SpatRaster
size : 594, 583, 1 (nrow, ncol, nlyr)
resolution : 5000, 5000 (x, y)
extent : -1640000, 1275000, -1420000, 1550000 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=aea +lat_0=38.5 +lon_0=-64.5 +lat_1=29.5 +lat_2=47.5 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs
source : NACount.img
name : Layer_1
min value : 0
max value : 0
> tm_shape(st_as_stars(naCountRaster)) + tm_raster(col.scale = tm_scale_continuous())
Error in cut.default(b_t, breaks = breaks, include.lowest = TRUE) :
'breaks' are not unique
The user of tmap
can work around this by checking the raster ahead of time and using something other than tm_scale_continuous
if there's only 1 unique value, such as tm_scale_discrete
. However, doing this check all the time is inconvenient, and tmap
would be improved by automatically handling this case. For example, tm_scale_continuous
could fail over internally to tm_scale_discrete
if there is only 1 unique value. (It would have to pick a palette value to use; that behavior should be documented.)
In the real-world example above, I am mapping a raster that tallies how many predictions of a species distribution model were NA across a long time series of rasters representing model covariates. In this project, a covariate raster might have NA values where clouds blocked a satellite's view of the Earth's surface. This is a common occurrence, so NA values are common. But it is also feasible that a model might not use covariates that are affected by clouds, in which case there might never be any NA predictions.
Thanks for considering this.