Skip to content

Commit

Permalink
fixes #1215
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Jul 3, 2023
1 parent 1be10e9 commit 352cc8d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/wrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ finalizeWrap <- function(x, r) {
r@attributes$levels <- cats(x)
r@attributes$levindex <- activeCat(x, 0)
}
if (any(has.colors(x))) {
r@attributes$colors <- coltab(x)
}

v <- time(x)
if (any(!is.na(v))) {
r@attributes$time <- v
Expand Down Expand Up @@ -284,6 +288,14 @@ setMethod("unwrap", signature(x="PackedSpatRaster"),
set.cats(r, layer=0, x@attributes$levels, active=x@attributes$levindex)
}
}
if (any(nms=="colors")) {
for (i in seq_along(x@attributes$colors)) {
if (!is.null(x@attributes$colors[[i]])) {
d <- terra:::.makeSpatDF(x@attributes$colors[[i]])
if (!r@ptr$setColors(i-1, d)) messages("cols<-", r)
}
}
}
}
r
}
Expand Down

0 comments on commit 352cc8d

Please sign in to comment.