You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am planning to add support on tidyterra for SpatRaster with coltab. However, after the latest release on CRAN (v1.7.46) I see a change of behaviour.
Before, terra::coltab() accepted a list of data frame (as per the docs: ...you can also supply a list of such data.frames to set a color table to all layers) but on the latest release this approach does not work any more, and a list of data frames throws an error, see:
library(terra)
#> terra 1.7.46r<- rast(ncols=3, nrows=2, vals=1:6)
coltb<-data.frame(value=1:6, col= rainbow(6, end=.9))
r_copy<-r
coltab(r_copy) <-coltb
has.colors(r_copy)
#> [1] TRUE# Try to re-set colors:# note that coltab(r) <- coltab(r_copy) does not work any more# I can't use the outputmycoltab<- coltab(r_copy)
class(mycoltab)
#> [1] "list"mycoltab#> [[1]]#> values red green blue alpha#> 1 1 255 0 0 255#> 2 2 235 255 0 255#> 3 3 0 255 41 255#> 4 4 0 194 255 255#> 5 5 82 0 255 255#> 6 6 255 0 153 255
try(coltab(r) <-mycoltab)
#> Error : [coltab<-] cannot set these values
has.colors(r)
#> [1] FALSE# Need to unlist the coltab
class(mycoltab[[1]])
#> [1] "data.frame"
coltab(r) <-mycoltab[[1]]
has.colors(r)
#> [1] TRUE
Hi @rhijmans
I am planning to add support on tidyterra for
SpatRaster
with coltab. However, after the latest release on CRAN (v1.7.46) I see a change of behaviour.Before,
terra::coltab()
accepted a list of data frame (as per the docs: ...you can also supply a list of such data.frames to set a color table to all layers) but on the latest release this approach does not work any more, and a list of data frames throws an error, see:Created on 2023-09-15 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: