[Raster-commits] r149 - pkg/raster/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jan 17 11:17:59 CET 2009
Author: rhijmans
Date: 2009-01-17 11:17:59 +0100 (Sat, 17 Jan 2009)
New Revision: 149
Modified:
pkg/raster/R/compare.R
pkg/raster/R/properties.R
Log:
improved origin checking in compare
Modified: pkg/raster/R/compare.R
===================================================================
--- pkg/raster/R/compare.R 2009-01-17 09:56:21 UTC (rev 148)
+++ pkg/raster/R/compare.R 2009-01-17 10:17:59 UTC (rev 149)
@@ -52,11 +52,14 @@
}
# Can also check orig through bb & rowcol, but orig is useful for e.g. Merge(raster, raster)
if (orig) {
- if (!(isTRUE(all.equal(origin(objects[[1]]), origin(objects[[i]]), tolerance=tolerance, scale=minres)))) {
+ dif1 <- origin(objects[[1]]) - origin(objects[[i]])
+ dif2 <- abs(origin(objects[[1]])) - origin(objects[[i]])
+ dif3 <- pmin(dif1, dif2)
+ if (!(isTRUE(all.equal(dif3, c(0,0), tolerance=tolerance, scale=minres)))) {
result <- F
if (stopiffalse) { stop('different origin') }
if (showwarning) { warning('different origin') }
- }
+ }
}
}
return(result)
Modified: pkg/raster/R/properties.R
===================================================================
--- pkg/raster/R/properties.R 2009-01-17 09:56:21 UTC (rev 148)
+++ pkg/raster/R/properties.R 2009-01-17 10:17:59 UTC (rev 149)
@@ -126,13 +126,7 @@
origin <- function(object) {
x <- xmin(object) - xres(object)*(round(xmin(object) / xres(object)))
- if ( x < 0 & abs(x) < 0.5 * xres(object)) {
- x <- x + xres(object)
- }
y <- ymax(object) - yres(object)*(round(ymax(object) / yres(object)))
- if ( y < 0 & abs(y) < 0.5 * yres(object)) {
- y <- y + yres(object)
- }
return(c(x, y))
}
More information about the Raster-commits
mailing list