[Raster-commits] r180 - in pkg/raster: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jan 25 16:14:28 CET 2009
Author: rhijmans
Date: 2009-01-25 16:14:28 +0100 (Sun, 25 Jan 2009)
New Revision: 180
Removed:
pkg/raster/R/read.stack.R
Modified:
pkg/raster/DESCRIPTION
pkg/raster/R/adjacency.R
pkg/raster/R/all.classes.R
pkg/raster/R/calc.R
pkg/raster/R/read.raster.R
pkg/raster/R/set.values.R
pkg/raster/R/show.R
pkg/raster/R/stack.create.R
pkg/raster/R/write.R
pkg/raster/R/writeRaster.R
pkg/raster/man/adjacency.Rd
pkg/raster/man/create.stack.Rd
pkg/raster/man/write.Rd
Log:
Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/DESCRIPTION 2009-01-25 15:14:28 UTC (rev 180)
@@ -1,7 +1,7 @@
Package: raster
Type: Package
Title: Raster data handling for geographic data analysis and modeling
-Version: 0.8.7
+Version: 0.8.7-1
Date: 25-Jan-2009
Depends: methods, sp, rgdal (>= 0.5-33), R (>= 2.8.0)
Author: Robert J. Hijmans & Jacob van Etten
Modified: pkg/raster/R/adjacency.R
===================================================================
--- pkg/raster/R/adjacency.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/adjacency.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -4,8 +4,7 @@
# Version 0.8
# Licence GPL v3
-.cs <- function(a,b)
-{
+.cs <- function(a,b) {
aRep <- rep(a,times=length(b))
out <- cbind(aRep,as.integer(aRep+rep(b,each=length(a))),deparse.level=0)
return(out)
@@ -21,8 +20,10 @@
# return(raster)
#}
-adjacency <- function(raster, fromCells, toCells, directions, outerMeridianConnect)
-{
+adjacency <- function(raster, fromCells, toCells, directions, outerMeridianConnect) {
+
+ if (directions=="Bishop") { return(.adjBishop(raster, fromCells, toCells, outerMeridianConnect)) }
+
nCols <- ncol(raster)
nCells <- ncell(raster)
@@ -241,8 +242,9 @@
return(fromto)
}
-adjBishop <- function(raster, fromCells, toCells, outerMeridianConnect)
-{
+
+
+.adjBishop <- function(raster, fromCells, toCells, outerMeridianConnect) {
nCols <- ncol(raster)
nCells <- ncell(raster)
Modified: pkg/raster/R/all.classes.R
===================================================================
--- pkg/raster/R/all.classes.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/all.classes.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -20,8 +20,7 @@
ymin = 0,
ymax = 1
),
- validity = function(object)
- {
+ validity = function(object) {
c1 <- (object at xmin <= object at xmax)
c2 <- (object at ymin <= object at ymax)
return(c1 & c2)
@@ -41,8 +40,7 @@
nrows= as.integer(1),
crs = CRS(as.character(NA))
),
- validity = function(object)
- {
+ validity = function(object) {
c1 <- (object at ncols > 0)
c2 <- (object at nrows > 0)
return(c1 & c2)
@@ -83,8 +81,7 @@
band = as.integer(1),
bandorder = 'BIL'
),
- validity = function(object)
- {
+ validity = function(object) {
}
)
@@ -94,24 +91,23 @@
values='vector',
content='character', #nodata, all, row, block, sparse
indices = 'vector',
- colnames = 'character',
+ colname = 'character',
haveminmax = 'logical',
- min = 'vector',
- max = 'vector',
+ min = 'numeric',
+ max = 'numeric',
source='character' # ram, disk
),
prototype (
values=vector(),
content='nodata',
indices = vector(mode='numeric'),
- colnames = '',
+ colname = '',
haveminmax = FALSE,
- min = numeric(0),
- max = numeric(0),
+ min = Inf,
+ max = -Inf,
source='ram'
),
- validity = function(object)
- {
+ validity = function(object) {
}
)
@@ -136,17 +132,22 @@
content='character', #nodata, all, row, block, sparse
indices = 'vector',
colnames = 'vector',
- nlayers='integer'
+ nlayers='integer',
+ haveminmax = 'logical',
+ min = 'numeric',
+ max = 'numeric'
),
prototype (
values=matrix(NA,0,0),
content='nodata',
indices =vector(mode='numeric'),
colnames =vector(mode='character'),
- nlayers=as.integer(0)
+ nlayers=as.integer(0),
+ haveminmax = FALSE,
+ min = Inf,
+ max = -Inf
),
- validity = function(object)
- {
+ validity = function(object) {
}
)
@@ -157,21 +158,17 @@
contains = 'Raster',
representation (
filename ='character',
- rasters ='list',
+ layers ='list',
data = 'MultipleRasterData'
),
prototype (
filename='',
- rasters = list()
+ layers = list()
),
- validity = function(object)
- {
- cond1 <- length(object at rasters) == object at data@nlayers
- #cond2 <- Are the rasters equal in dimensions etc.? The exact implementation will depend on the format of the raster at data slot (list, array, vector)
- cond <- cond1 #& cond2
+ validity = function(object) {
+ cond1 <- length(object at layers) == object at data@nlayers
+ cond <- cond1
return(cond)
}
)
-
-
Modified: pkg/raster/R/calc.R
===================================================================
--- pkg/raster/R/calc.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/calc.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -48,7 +48,7 @@
stop("function 'fun' returns more than one value")
}
- outraster <- setRaster(object at rasters[[1]], filename)
+ outraster <- setRaster(object at layers[[1]], filename)
if (filename(outraster)=="") {
object <- readAll(object)
outraster <- setValues(outraster, apply(values(object), 1, fun))
Modified: pkg/raster/R/read.raster.R
===================================================================
--- pkg/raster/R/read.raster.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/read.raster.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -298,7 +298,7 @@
.stackRead <- function(rstack, rownumber, startcol=1, ncolumns=(ncol(rstack)-startcol+1)) {
for (i in seq(nlayers(rstack))) {
- raster <- readPartOfRow(rstack at rasters[[i]], rownumber, startcol, ncolumns)
+ raster <- readPartOfRow(rstack at layers[[i]], rownumber, startcol, ncolumns)
if ( i == 1 ) {
rstack at data@values <- as.matrix(values(raster))
rstack at data@content <- dataContent(raster)
@@ -313,21 +313,17 @@
.stackReadCells <- function(object, cells) {
for (i in seq(nlayers(object))) {
- v <- .rasterReadCells(object at rasters[[i]], cells)
+ v <- .rasterReadCells(object at layers[[i]], cells)
if (i == 1) {
result <- v
} else {
result <- cbind(result, v)
- # colnames(result)[length(result[1,])] <- rstack at rasters[[i]]@file at shortname
+ # colnames(result)[length(result[1,])] <- rstack at layers[[i]]@file at shortname
}
}
if (!(is.null(dim(result)))) {
for (i in seq(nlayers(object))) {
- label <- object at rasters[[i]]@file at shortname
- if (nchar(label) == "") {
- label <- paste("raster_", i, sep="")
- }
- colnames(result)[i] <- label
+ colnames(result) <- object at data@colnames
}
}
return(result)
Deleted: pkg/raster/R/read.stack.R
===================================================================
--- pkg/raster/R/read.stack.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/read.stack.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -1,6 +0,0 @@
-# Author: Robert J. Hijmans, r.hijmans at gmail.com
-# International Rice Research Institute
-# Date : June 2008
-# Version 0,1
-# Licence GPL v3
-
Modified: pkg/raster/R/set.values.R
===================================================================
--- pkg/raster/R/set.values.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/set.values.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -55,13 +55,13 @@
clearValues <- function(object) {
- if (class(object) == 'RasterLayer') {
- object <- setRaster(object)
+ object at data@content <- 'nodata'
+ object at data@indices = vector(mode='numeric')
+ if (class(object) == 'RasterStack') {
+ object at data@values <- matrix(NA,0,0)
} else {
- object at data@values <- matrix(NA,0,0)
+ object at data@values <- vector()
}
- object at data@content <- 'nodata'
- object at data@indices <- ""
return(object)
}
Modified: pkg/raster/R/show.R
===================================================================
--- pkg/raster/R/show.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/show.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -71,19 +71,20 @@
setMethod ('show' , 'RasterStack',
function ( object ){
- cat ('class :' , class ( object ) , '\n')
- cat ('filename :' , filename(object), '\n')
- cat ('nlayers :' , nlayers(object), '\n')
- cat ('nrow :' , nrow(object), '\n')
- cat ('ncol :' , ncol(object), '\n')
- cat ('ncells :' , ncell(object), '\n')
- cat ('projection:' , projection(object, TRUE), '\n')
- cat ('xmin :' , xmin(object), '\n')
- cat ('xmax :' , xmax(object), '\n')
- cat ('ymin :' , ymin(object), '\n')
- cat ('ymax :' , ymax(object), '\n')
- cat ('xres :' , xres(object) , '\n')
- cat ('yres :' , yres(object) , '\n')
+ cat ('class :' , class ( object ) , '\n')
+ cat ('filename :' , filename(object), '\n')
+ cat ('nlayers :' , nlayers(object), '\n')
+ cat ('nrow :' , nrow(object), '\n')
+ cat ('ncol :' , ncol(object), '\n')
+ cat ('ncells :' , ncell(object), '\n')
+ cat ('projection :' , projection(object, TRUE), '\n')
+ cat ('data content:' , dataContent(object), '\n')
+ cat ('xmin :' , xmin(object), '\n')
+ cat ('xmax :' , xmax(object), '\n')
+ cat ('ymin :' , ymin(object), '\n')
+ cat ('ymax :' , ymax(object), '\n')
+ cat ('xres :' , xres(object) , '\n')
+ cat ('yres :' , yres(object) , '\n')
cat ('\n')
}
)
Modified: pkg/raster/R/stack.create.R
===================================================================
--- pkg/raster/R/stack.create.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/stack.create.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -1,138 +1,155 @@
# Author: Robert J. Hijmans, r.hijmans at gmail.com
# International Rice Research Institute
# Date : June 2008
-# Version 0,1
+# Version 0.8
# Licence GPL v3
-stackFromFile <- function(stackfile) {
- st <- read.table(stackfile, as.is=FALSE, strip.white=TRUE)
- rasterfiles <- list()
- bands <- list()
- for (i in 1:length(st[,1])) {
- rasterfiles[i] <- as.character(st[i,1])
- bands[i] <- as.integer(st[i,2])
- }
- rst <- stackFromRasterfiles(rasterfiles, bands)
+stackOpen <- function(stackfile) {
+ st <- read.table(stackfile, as.is=FALSE, strip.white=TRUE)
+ rst <- stackFromFiles(st[,1], st[,2])
rst <- setFilename(rst, stackfile)
return(rst)
}
+stackSave <- function(rstack) {
+ stackfile <- trim(rstack at filename)
+ if (stackfile == "") { stop('RasterStack does not have a filename.') }
+ thefile <- file(stackfile, "w")
+ for (i in 1:length(rstack at layers)) {
+ fname <- trim(filename(rstack at layers[[i]]))
+ if (trim(fname) == "") {
+ stop("cannot save a Stack that has Layers without filenames. Use writeStack instead.")
+ }
+ cat(fname, "\t", band(rstack at layers[[i]]),"\n", file=thefile)
+ }
+ close(thefile)
+ return(rstack)
+}
-#makeStack <- function(objects, bands= rep(1, length(objects))) {
-# if !isTRUE(all.equal(length(bands), length(objects))) {
-# warning("length of bands vectors != length of objects vector")
-# }
-# rstack <- new("RasterStack")
-# for (i in seq(objects)) {
-# if (class(object[i])=='character') {
-# rstack <- stackAddFiles(rstack, objects[i], band[i])
-# } else {
-# rstack <- stackAddRasters(rstack, objects[i])
-# }
-# }
-# return(rstack)
-#}
-
-stackFromRasterfiles <- function(rasterfiles, bands= rep(1, length(rasterfiles))) {
+stackFromFiles <- function(rasterfiles, bands= rep(1, length(rasterfiles))) {
# stop("this function is depracated. Use makeStack() instead.")
rstack <- new("RasterStack")
- return(stackAddFiles(rstack, rasterfiles, bands))
+ return(addFiles(rstack, rasterfiles, bands))
}
-stackFromRasters <- function(rasters) {
-#stop("this function is depracated. Use makeStack() instead.")
- rstack <- new("RasterStack")
- return(stackAddRasters(rstack, rasters))
-}
-stackAddFiles <- function(rstack, rasterfiles, bands= rep(1, length(rasterfiles))) {
- if (class(rstack) != "RasterStack") {
- stop("rstack should be a RasterStack objectr")
- }
-
- if (is.list(rasterfiles)) {rasterfiles <- unlist(rasterfiles)}
- if (is.list(bands)) {bands <- unlist(bands)}
-
- for (i in 1 : length(rasterfiles)) {
- if (length(rasterfiles)==1) {
- fn <- rasterfiles
- band <- bands
+if (!isGeneric("stack")) {
+ setGeneric("stack", function(x, ...)
+ standardGeneric("stack"))
+}
+
+
+setMethod("stack", signature(x='RasterLayer'),
+function(x, ...) {
+ rlist <- c(x, list(...))
+ for (i in 1:length(rlist)) {
+ if (is.character(rlist[[i]])) {
+ rlist[i] <- rasterFromFile(rlist[[i]])
} else {
- fn <- rasterfiles[i]
- band <- bands[i]
+ if (class(rlist[[i]]) != "RasterLayer") {
+ stop("Arguments should be RasterLayer objects or filenames")
+ }
}
- filename <- trim(fn)
- if (!(file.exists(filename))) {
- stop(paste(filename, "does not exist"))
- }
- raster <- rasterFromFile(filename, FALSE, band=band)
- rstack <- stackAddRasters(rstack, raster)
}
+ return(addRasters(new("RasterStack"), rlist))
+} )
+
+
+addFiles <- function(rstack, rasterfiles, bands= rep(1, length(rasterfiles))) {
+ rasters <- list()
+ for (i in 1:length(rasterfiles)) {
+ rasters <- c(rasters, rasterFromFile(rasterfiles[[i]], FALSE, band=bands[[i]]))
+ }
+ rstack <- addRasters(rstack, rasters)
return(rstack)
}
-stackAddRasters <- function(rstack, rasters) {
+addRasters <- function(rstack, rasters) {
#rasters is a list of raster objects
if (class(rstack) != "RasterStack") {
stop("rstack should be a RasterStack object")
}
+ if (length(rasters) == 1 & class(rasters) == 'RasterLayer') {
+ rasters <- list(rasters)
+ }
+
for (i in 1 : length(rasters)) {
- if (length(rasters) == 1) {
- raster <- rasters
- } else {
- raster <- rasters[[i]]
+ raster <- rasters[[i]]
+ if (dataContent(raster) != 'all' & dataSource(raster) == 'ram') {
+ stop("Cannot add a memory based raster without values to a stack")
}
-
- addraster <- TRUE
- i <- nlayers(rstack) + 1
- if (i == 1) {
+ nl <- rstack at data@nlayers + 1
+ rstack at data@nlayers <- as.integer(nl)
+ if (nlayers(rstack) == 1) {
rstack <- setRowCol(rstack, nrow(raster), ncol(raster))
rstack <- setBbox(rstack, raster, snap=FALSE)
rstack <- setProjection(rstack, projection(raster))
+ if (trim(raster at file@shortname) != "") {
+ cname <- trim(raster at file@shortname)
+ } else {
+ cname <- "layer1"
+ }
+ rstack at data@colnames[1] <- cname
+ if (dataContent(raster) == 'all') {
+ rstack at data@values <- matrix(nrow=ncell(rstack), ncol=length(rasters))
+ rstack at data@values[,1] <- values(raster)
+ rstack at data@content <- 'all'
+ raster <- clearValues(raster)
+ } else {
+ if (dataSource(raster) == 'ram' & dataContent(raster) != "all") {
+ stop("adding memory based raster to stack, withouth adding values")
+ }
+ }
} else {
if (!compare(c(rstack, raster))) {
stop(paste("could not add raster:", filename(raster)))
}
count <- 1
- for (j in 1:(i-1)) {
- if (filename(raster) == rstack at rasters[[j]]@file at shortname) {
+ cname <- trim(raster at file@shortname)
+ if (cname == "") {
+ cname <- paste("layer", nl, sep="")
+ }
+ cn <- cname
+ for (j in 1:(nl-1)) {
+ if ( cn == rstack at data@colnames[j] ) {
count <- count + 1
+ cn <- paste(cname, "_", count, sep="")
}
}
- if (count > 1) {
- raster at file@shortname <- paste(raster at file@shortname, "_", count, sep="") }
+ rstack at data@colnames[nl] <- cn
+ if (dataContent(rstack)=='all') {
+ if (dataContent(raster) != 'all') {
+ raster <- readAll(raster)
+ }
+ rstack at data@values[,nl] <- values(raster)
+ raster <- clearValues(raster)
+ } else {
+ if (dataSource(raster)=='disk') {
+ raster <- clearValues(raster)
+ }
+ }
}
- rstack at rasters[i] <- raster
- rstack at data@nlayers <- as.integer(rstack at data@nlayers + 1)
+ rstack at layers[nl] <- raster
+ rstack at data@min[nl] <- raster at data@min
+ rstack at data@max[nl] <- raster at data@max
}
return(rstack)
}
-stackRemoveRasters <- function(rstack, indices) {
+stackRemove <- function(rstack, indices) {
indices <- sort(indices, decreasing=TRUE)
for (i in 1:length(indices)) {
index <- -1 * indices[i]
- rstack at rasters <- rstack at rasters[index]
+ rstack at layers <- rstack at layers[index]
rstack at data@nlayers <- as.integer(rstack at data@nlayers - 1)
}
return(rstack)
}
-stackSave <- function(rstack) {
- stackfile <- trim(rstack at filename)
- if (stackfile == "") { stop('RasterStack does not have a filename.') }
- thefile <- file(stackfile, "w")
- for (i in 1:length(rstack at rasters)) {
- cat(filename(rstack at rasters[[i]]), "\t", rstack at rasters[[i]]@file at band,"\n", file=thefile)
- }
- close(thefile)
- return(rstack)
-}
-
Modified: pkg/raster/R/write.R
===================================================================
--- pkg/raster/R/write.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/write.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -32,7 +32,7 @@
writeRaster <- function(raster, format='raster', overwrite=FALSE) {
if (dataContent(raster) != 'row' & dataContent(raster) != 'all' & dataContent(raster) != 'sparse' ) {
- stop('First use setValues()')
+ stop('No data available for writing. First use setValues()')
}
if (format=='raster') {
@@ -54,4 +54,9 @@
return(raster)
}
-
+writeStack <- function(rstack, overwrite=FALSE) {
+ stop("not available yet")
+ for (i in 1:nlayers(rstack)) {
+
+ }
+}
Modified: pkg/raster/R/writeRaster.R
===================================================================
--- pkg/raster/R/writeRaster.R 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/R/writeRaster.R 2009-01-25 15:14:28 UTC (rev 180)
@@ -75,8 +75,8 @@
raster at file@name <- .setFileExtensionHeader(filename(raster))
binraster <- .setFileExtensionValues(filename(raster))
attr(raster, "filecon") <- file(binraster, "wb")
- raster at data@min <- 3e34
- raster at data@max <- -3e34
+ raster at data@min <- Inf
+ raster at data@max <- -Inf
raster at data@haveminmax <- FALSE
raster at file@driver <- 'raster'
raster at file@gdalhandle <- list()
Modified: pkg/raster/man/adjacency.Rd
===================================================================
--- pkg/raster/man/adjacency.Rd 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/man/adjacency.Rd 2009-01-25 15:14:28 UTC (rev 180)
@@ -1,21 +1,19 @@
\name{adjacency}
\alias{adjacency}
-\alias{adjBishop}
\title{adjacency}
\description{
- calculate adjacent cells on a grid
+ Identify cells that are adjacent to a set of cells on a grid
}
\usage{
adjacency(raster, fromCells, toCells, directions, outerMeridianConnect)
-adjBishop(raster, fromCells, toCells, outerMeridianConnect)
}
\arguments{
\item{raster}{an object of the Raster family}
\item{fromCells}{a vector of cell numbers for which adjacent cells should be calculated}
\item{toCells}{a vector of cell numbers from which adjacent cells are selected}
- \item{directions}{in how many direction cells should be connected: 4, 8 or 16.}
+ \item{directions}{in how many direction cells should be connected: 4, 8 or 16; or Bishop}
\item{outerMeridianConnect}{logical value indicating whether the outer columns of the raster should be connected as a cylinder}
}
@@ -39,7 +37,7 @@
rs <- setValues(rs, v)
plot(rs)
- adjbis <- adjBishop(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncell(rs)), outerMeridianConnect = TRUE)
+ adjbis <- adjacency(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncell(rs)), direction='Bishop', outerMeridianConnect = TRUE)
}
\keyword{spatial}
Modified: pkg/raster/man/create.stack.Rd
===================================================================
--- pkg/raster/man/create.stack.Rd 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/man/create.stack.Rd 2009-01-25 15:14:28 UTC (rev 180)
@@ -1,11 +1,13 @@
\name{rasterstack.create}
-\alias{stackFromFile}
-\alias{stackFromRasterfiles}
+\alias{stack}
+\alias{stack,RasterLayer-method}
+\alias{stackFromFiles}
\alias{stackFromRasters}
-\alias{stackAddFiles}
-\alias{stackAddRasters}
-\alias{stackRemoveRasters}
+\alias{addFiles}
+\alias{addRasters}
+\alias{stackRemove}
\alias{stackSave}
+\alias{stackOpen}
\title{ Create or change a new stack }
\description{
@@ -14,22 +16,24 @@
}
\usage{
-stackFromFile(stackfile)
-stackFromRasterfiles(rasterfiles, bands= rep(1, length(rasterfiles)))
-stackFromRasters(rasters)
-stackAddFiles(rstack, rasterfiles, bands= rep(1, length(rasterfiles)))
-stackAddRasters(rstack, rasters)
-stackRemoveRasters(rstack, indices)
+stackOpen(stackfile)
stackSave(rstack)
+stack(x, ...)
+stackFromFiles(rasterfiles, bands= rep(1, length(rasterfiles)))
+addFiles(rstack, rasterfiles, bands= rep(1, length(rasterfiles)))
+addRasters(rstack, rasters)
+stackRemove(rstack, indices)
}
\arguments{
\item{stackfile}{ Filename for the stack (to save it on disk) }
- \item{rstack}{ a stack object }
+ \item{rstack}{ a RasterStack object }
+ \item{x}{a RasterLayer object}
+ \item{...}{additional RasterLayer objects (or filenames) }
\item{rasterfiles}{ Filename(s) of (a) raster dataset(s) }
\item{bands}{ A vector or list of bands of raster data files (default values = 1)}
\item{rasters}{ RasterLayer object(s) }
- \item{indices}{ the indices of the raster(s) to remove from a stack }
+ \item{indices}{ the indices of the raster(s) to remove from a RasterStack }
}
\details{
When a stack is saved to a file, only pointers (filenames) to raster datasets are saved, not the data. If the name or location of a raster file changes, the stack becomes invalid.
@@ -43,19 +47,19 @@
\seealso{ ~~objects to See Also as \code{\link{help}}, ~~~ }
\examples{
rasterfile <- system.file("external/test.ag", package="sp")
- st <- stackFromRasterfiles(rasterfile)
+ st <- stackFromFiles(rasterfile)
# now adding the same file multiple times, in most cases you would add different files
# this generates warnings, but it is not an error
- st <- stackAddFiles(st, c(rasterfile, rasterfile))
+ st <- addFiles(st, c(rasterfile, rasterfile))
rs <- rasterFromFile(rasterfile)
- st <- stackAddRasters(st, c(rs, rs))
+ st <- addRasters(st, c(rs, rs))
st
- st <- stackRemoveRasters(st, c(3, 5))
+ st <- stackRemove(st, c(3, 5))
nlayers(st)
st <- setFilename(st, "mystack")
st <- stackSave(st)
# note that setFilename adds an extension .stk to a stackfile
- st2 <- stackFromFile("mystack.stk")
+ st2 <- stackOpen("mystack.stk")
st2
}
\keyword{ spatial }
Modified: pkg/raster/man/write.Rd
===================================================================
--- pkg/raster/man/write.Rd 2009-01-25 06:30:39 UTC (rev 179)
+++ pkg/raster/man/write.Rd 2009-01-25 15:14:28 UTC (rev 180)
@@ -1,6 +1,7 @@
\name{write}
\alias{writeRaster}
+\alias{writeStack}
\alias{rasterWriteFormats}
\title{Write raster data to a file}
@@ -13,12 +14,14 @@
\usage{
writeRaster(raster, format='raster', overwrite=FALSE)
rasterWriteFormats()
+ writeStack(rstack, overwrite=FALSE)
}
\arguments{
\item{raster}{RasterLayer object}
\item{format}{either 'raster', 'ascii' or a supported GDAL 'driver' name}
\item{overwrite}{Logical. If \code{TRUE} existing files are overwritten}
+ \item{rstack}{RasterStack object}
}
\details{
More information about the Raster-commits
mailing list