Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retain coltab in wrap of raster #1215

Closed
eborgnine opened this issue Jun 30, 2023 · 1 comment
Closed

retain coltab in wrap of raster #1215

eborgnine opened this issue Jun 30, 2023 · 1 comment

Comments

@eborgnine
Copy link

Currently the coltab is dropped when a raster is wrapped.
this could be fixed by adding to finalizeWrap

r@attributes$coltab = coltab(r)

and in the unwrap method
ext(rr) <- r@attributes$coltab

@rhijmans
Copy link
Member

rhijmans commented Jul 3, 2023

Thanks very much, I overlooked that. I now get:


library(terra)
s <- r <- rast(ncols=3, nrows=2, vals=1:6)
coltab(r) <- data.frame(value=1:6, col=rainbow(6, end=.9))
rast(wrap(r))
#class       : SpatRaster 
#dimensions  : 2, 3, 1  (nrow, ncol, nlyr)
#resolution  : 120, 90  (x, y)
#extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
#coord. ref. : lon/lat WGS 84 
#source(s)   : memory
#color table : 1 
#name        : lyr.1 
#min value   :     1 
#max value   :     6 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants