Description Usage Arguments Value Examples
Convert list of annual raster stack to data.table
1 2 3 4 5 6 7 8 9 10 | annualStackToDTx1000(x, whNotNA, ...)
## S3 method for class 'RasterLayer'
annualStackToDTx1000(x, whNotNA, ...)
## S3 method for class 'list'
annualStackToDTx1000(x, whNotNA, ...)
## S3 method for class 'RasterStack'
annualStackToDTx1000(x, whNotNA, ...)
|
x |
|
whNotNA |
Pixel indexes that should go through this process (i.e. not NA) |
... |
Not currently used |
data.table
of the raster stack or the list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | library(raster)
r1 <- raster(extent(0,10,0,10), vals = 1:100)
r2 <- raster(extent(0,10,0,10), vals = 100:1)
r3 <- raster(extent(0,10,0,10), vals = 200:101)
r4 <- raster(extent(0,10,0,10), vals = 300:201)
# list of Rasters
lRast <- list(r1, r2, r3)
lRast[[1]][5] <- NA
whNotNA <- setdiff(1:ncell(r1), 5)
# unnamed -- should error
try(out1 <- annualStackToDTx1000(lRast, whNotNA))
# named
names(lRast) <- c("OneToHun", "HunToOne", "TwoHunToOneHun")
out1 <- annualStackToDTx1000(lRast, whNotNA)
# RasterStack
out2 <- annualStackToDTx1000(raster::stack(lRast), whNotNA)
# List of RasterStacks
s1 <- raster::stack(r1, r2)
names(s1) <- names(lRast)[1:2]
s2 <- raster::stack(r4, r3)
names(s2) <- c(names(lRast)[3], "ThreeHunToTwoHun")
out3 <- annualStackToDTx1000(list(s1 = s1, s2 = s2), whNotNA) ## named list required
# With duplicated names -- to remove duplicates;
# actually, this doesn't make sense: RasterStack can't have duplicated names
names(lRast) <- c("OneToHun", "OneToHun", "TwoHunToOneHun")
out4 <- annualStackToDTx1000(raster::stack(lRast), whNotNA)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.