[Raster-commits] r112 - in pkg/raster: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jan 10 11:31:31 CET 2009
Author: rhijmans
Date: 2009-01-10 11:31:31 +0100 (Sat, 10 Jan 2009)
New Revision: 112
Modified:
pkg/raster/R/compare.R
pkg/raster/R/stack.create.R
pkg/raster/man/utils.Rd
Log:
Modified: pkg/raster/R/compare.R
===================================================================
--- pkg/raster/R/compare.R 2009-01-10 09:43:46 UTC (rev 111)
+++ pkg/raster/R/compare.R 2009-01-10 10:31:31 UTC (rev 112)
@@ -8,7 +8,7 @@
-compare <- function(objects, bb=TRUE, rowcol=TRUE, prj=TRUE, res=FALSE, orig=FALSE, tolerance=0.05, stopiffalse=TRUE) {
+compare <- function(objects, bb=TRUE, rowcol=TRUE, prj=TRUE, res=FALSE, orig=FALSE, tolerance=0.05, stopiffalse=TRUE, showwarning=FALSE) {
result <- TRUE
if (!isTRUE(length(objects) > 1)) {
result <- F
@@ -19,23 +19,27 @@
if (bb) {
if (!(isTRUE(all.equal(boundingbox(objects[[1]]), boundingbox(objects[[i]]), tolerance=tolerance, scale=minres )))) {
result <- F
- if (stopiffalse) { stop('Different bounding boxes') }
+ if (stopiffalse) { stop('Different bounding box') }
+ if (showwarning) { warning('Different bounding box') }
}
}
if (rowcol) {
if ( !(identical(ncol(objects[[1]]), ncol(objects[[i]]))) ) {
result <- F
if (stopiffalse) { stop('ncols different') }
+ if (showwarning) { warning('ncols different') }
}
if ( !(identical(nrow(objects[[1]]), nrow(objects[[i]]))) ) {
result <- F
if (stopiffalse) { stop('nrows different') }
+ if (showwarning) { warning('nrows different') }
}
}
if (prj) {
if ( !(identical(projection(objects[[1]]), projection(objects[[i]])))) {
result <- F
- if (stopiffalse) {stop('different projections')}
+ if (stopiffalse) {stop('different projection')}
+ if (showwarning) { warning('different projection')}
}
}
# Can also check res through bb & rowcol
@@ -43,6 +47,7 @@
if (!(isTRUE(all.equal(resolution(objects[[1]]), resolution(objects[[i]]), tolerance=tolerance, scale=minres)))) {
result <- F
if (stopiffalse) { stop('different resolution') }
+ if (showwarning) { warning('different resolution') }
}
}
# Can also check orig through bb & rowcol, but orig is useful for e.g. Merge(raster, raster)
@@ -50,6 +55,7 @@
if (!(isTRUE(all.equal(origin(objects[[1]]), origin(objects[[i]]), tolerance=tolerance, scale=minres)))) {
result <- F
if (stopiffalse) { stop('different origin') }
+ if (showwarning) { warning('different origin') }
}
}
}
Modified: pkg/raster/R/stack.create.R
===================================================================
--- pkg/raster/R/stack.create.R 2009-01-10 09:43:46 UTC (rev 111)
+++ pkg/raster/R/stack.create.R 2009-01-10 10:31:31 UTC (rev 112)
@@ -18,18 +18,36 @@
}
+#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))) {
+# stop("this function is depracated. Use makeStack() instead.")
rstack <- new("RasterStack")
return(stackAddFiles(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")
@@ -61,7 +79,7 @@
stackAddRasters <- function(rstack, rasters) {
#rasters is a list of raster objects
if (class(rstack) != "RasterStack") {
- stop("rstack should be a RasterStack objectr")
+ stop("rstack should be a RasterStack object")
}
for (i in 1 : length(rasters)) {
if (length(rasters) == 1) { raster <- rasters
Modified: pkg/raster/man/utils.Rd
===================================================================
--- pkg/raster/man/utils.Rd 2009-01-10 09:43:46 UTC (rev 111)
+++ pkg/raster/man/utils.Rd 2009-01-10 10:31:31 UTC (rev 112)
@@ -12,7 +12,7 @@
}
\usage{
-compare(objects, bb=TRUE, rowcol=TRUE, prj=TRUE, res=FALSE, orig=FALSE, tolerance=0.05, stopiffalse=TRUE)
+compare(objects, bb=TRUE, rowcol=TRUE, prj=TRUE, res=FALSE, orig=FALSE, tolerance=0.05, stopiffalse=TRUE, showwarning=FALSE)
roundCoords(object, digits=0)
newCRS(projstring)
}
@@ -25,7 +25,8 @@
\item{res} { logical. If \code{TRUE}, resolutions are compared}
\item{orig} { logical. If \code{TRUE}, origins are compared}
\item{tolerance} { difference permissable (relative to the cell resolution) for objects to be 'equal', for non integer numbers in origin and resolution. See ?all.equal }
- \item{stopiffalse}{logical. If \code{TRUE}, an error will be reported if rasters are not the same}
+ \item{stopiffalse}{logical. If \code{TRUE}, an error will occur if the objects are not the same}
+ \item{showwarning}{logical. If \code{TRUE}, an warning will be given if objects are not the same. Only relevant when \code{stopiffalse} is \code{TRUE}}
\item{object} { a Raster* object }
\item{digits} { integer indicating the precision to be used}
\item{projstring}{ a PROJ4 type character string describing projection and datum}
More information about the Raster-commits
mailing list