[Raster-commits] r382 - pkg/raster/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Mar 25 09:03:23 CET 2009
Author: rhijmans
Date: 2009-03-25 09:03:23 +0100 (Wed, 25 Mar 2009)
New Revision: 382
Modified:
pkg/raster/R/cellsFromBbox.R
Log:
Modified: pkg/raster/R/cellsFromBbox.R
===================================================================
--- pkg/raster/R/cellsFromBbox.R 2009-03-24 13:32:16 UTC (rev 381)
+++ pkg/raster/R/cellsFromBbox.R 2009-03-25 08:03:23 UTC (rev 382)
@@ -9,25 +9,16 @@
cellsFromBbox <- function(object, bndbox, expand=FALSE) {
- bndbox <- extent(bndbox)
-# bndbox at xmax - 0.01 * xres(object)
-# bndbox at ymin - 0.01 * yres(object)
+ bndbox <- extent(bndbox)
+ bndbox <- alignBbox(bndbox, object)
innerBox <- intersectBbox(extent(object), bndbox)
-
- srow <- rowFromY(object, innerBox at ymax)
- if (trunc((ymin(object) - bndbox at ymin)/yres(object)) == (ymin(object) - bndbox at ymin)/yres(object)) {
- bndbox at ymin <- bndbox at ymin + 0.5 * yres(object)
- }
- erow <- rowFromY(object, innerBox at ymin)
-
+ srow <- rowFromY(object, innerBox at ymax)
+ erow <- rowFromY(object, innerBox at ymin + 0.5 * yres(object))
scol <- colFromX(object, innerBox at xmin)
- if (trunc((xmax(object) - bndbox at xmax)/xres(object)) == (xmax(object) - bndbox at xmax)/xres(object)) {
- bndbox at xmax <- bndbox at xmax - 0.5 * xres(object)
- }
- ecol <- colFromX(object, innerBox at xmax)
-
+ ecol <- colFromX(object, innerBox at xmax - 0.5 * xres(object))
+
if (expand) {
addrowstop <- as.integer(round((bndbox at ymax - innerBox at ymax) / yres(object)))
addrowsbot <- as.integer(round((innerBox at ymin - bndbox at ymin) / yres(object)))
@@ -35,9 +26,8 @@
addcolsright <- as.integer(round((bndbox at xmax - innerBox at xmax) / xres(object)))
nc <- ecol-scol+1+addcolsleft+addcolsright
}
-
+
cell <- vector()
-
if (expand && addrowstop > 0) {
cell <- rep(NA, nc * addrowstop)
}
More information about the Raster-commits
mailing list