Skip to content

Commit

Permalink
fixes #1513
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed May 21, 2024
1 parent b680133 commit b7a869c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions R/coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,29 @@ as.list.SpatRaster <- function(x, geom=NULL, ...) {
lapply(1:nlyr(x), function(i) x[[i]])
}
}

setMethod("as.list", signature(x="SpatRaster"), as.list.SpatRaster)


as.list.SpatRasterCollection <- function(x, ...) {
lapply(1:length(x), function(i) x[i])
out <- lapply(1:length(x), function(i) x[i])
names(out) <- names(x)
out
}
setMethod("as.list", signature(x="SpatRasterCollection"), as.list.SpatRasterCollection)


as.list.SpatRasterDataset <- function(x, ...) {
lapply(1:length(x), function(i) x[i])
out <- lapply(1:length(x), function(i) x[i])
names(out) <- names(x)
out
}
setMethod("as.list", signature(x="SpatRasterDataset"), as.list.SpatRasterDataset)


as.list.SpatVectorCollection <- function(x, ...) {
lapply(1:length(x), function(i) x[i])
out <- lapply(1:length(x), function(i) x[i])
names(out) <- names(x)
out
}
setMethod("as.list", signature(x="SpatVectorCollection"), as.list.SpatVectorCollection)

Expand Down

0 comments on commit b7a869c

Please sign in to comment.