[Raster-commits] r239 - in pkg/raster: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 3 05:01:14 CET 2009


Author: rhijmans
Date: 2009-02-03 05:01:14 +0100 (Tue, 03 Feb 2009)
New Revision: 239

Modified:
   pkg/raster/R/bounding.box.R
   pkg/raster/R/get.R
   pkg/raster/R/set.values.R
   pkg/raster/man/get.Rd
Log:


Modified: pkg/raster/R/bounding.box.R
===================================================================
--- pkg/raster/R/bounding.box.R	2009-02-03 02:35:24 UTC (rev 238)
+++ pkg/raster/R/bounding.box.R	2009-02-03 04:01:14 UTC (rev 239)
@@ -15,6 +15,7 @@
 	bb at xmax <- xmx
 	bb at ymin <- ymn
 	bb at ymax <- ymx
+	validObject(bb)
 	return(bb)
 }
 
@@ -86,8 +87,14 @@
 )
 
 
+
+
+
+
 cellsFromBbox <- function(object, bndbox) {
 	bndbox <- getBbox(bndbox)
+#	bndbox at xmax - 0.01 * xres(object)
+#	bndbox at ymin - 0.01 * yres(object)
 	srow <- rowFromY(object, bndbox 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) 
@@ -169,6 +176,9 @@
 
 changeBbox <- function(object, xmn=xmin(object), xmx=xmax(object), ymn=ymin(object), ymx = ymax(object), keepres=FALSE) {
 	bb <- newBbox(xmn, xmx, ymn, ymx) 
+	if (class(bb) == 'BoundingBox') { 
+		return(bb)
+	}
 	object <- setBbox(object, bb, keepres=keepres) 
 	return(object)
 }

Modified: pkg/raster/R/get.R
===================================================================
--- pkg/raster/R/get.R	2009-02-03 02:35:24 UTC (rev 238)
+++ pkg/raster/R/get.R	2009-02-03 04:01:14 UTC (rev 239)
@@ -117,28 +117,6 @@
 }  
 	
 
-cellFromBbox <- function(object, bbox) {
-	if (.isSPgrid(object)) { object <- asRasterLayer(object, FALSE) }
-	bbox <- getBbox(bbox)
-	startrow <- rowFromY(object, ymax(bbox))
-	endrow <- rowFromY(object, ymin(bbox))
-	startcol <- colFromX(object, xmin(bbox))
-	endcol <- colFromX(object, xmax(bbox))
-
-#	cols <- rep(startcol:endcol, times=(endrow - startrow))
-#	rows <- rep(startrow:endrow, each=(endcol - startcol))
-#	cells <- cellFromRowCol(object, rows, cols)
-
-	# RH: ouch. Use Apply instead:
-	cells <- vector("integer", length=0)
-	for (r in startrow:endrow) {
-		firstcell <- cellFromRowCol(object, r, startcol)
-		lastcell <- cellFromRowCol(object, r, endcol)
-		cells <- c(cells, firstcell:lastcell)
-	}
-	return(cells)
-}
-
 	
 cxyFromBbox <- function(object, bbox) {
 	if (.isSPgrid(object)) { object <- asRasterLayer(object, FALSE) }

Modified: pkg/raster/R/set.values.R
===================================================================
--- pkg/raster/R/set.values.R	2009-02-03 02:35:24 UTC (rev 238)
+++ pkg/raster/R/set.values.R	2009-02-03 04:01:14 UTC (rev 239)
@@ -134,6 +134,9 @@
 	} else {
 		object at data@values <- vector()
 	}
+	object at data@min <- Inf
+	object at data@max <- -Inf	
+	object at data@haveminmax <- FALSE
 	return(object)
 }
 

Modified: pkg/raster/man/get.Rd
===================================================================
--- pkg/raster/man/get.Rd	2009-02-03 02:35:24 UTC (rev 238)
+++ pkg/raster/man/get.Rd	2009-02-03 04:01:14 UTC (rev 239)
@@ -2,7 +2,6 @@
 \alias{colFromCell}
 \alias{rowFromCell}
 \alias{cellFromRowCol}
-\alias{cellFromBbox}
 \alias{colFromX}
 \alias{rowFromY}
 \alias{cellFromXY}
@@ -25,7 +24,6 @@
 colFromCell(object, cell)
 rowFromCell(object, cell)
 cellFromRowCol(object, rownr, colnr)
-cellFromBbox(object, bbox)
 colFromX(object, x)
 rowFromY(object, y)
 cellFromXY(object, xy)



More information about the Raster-commits mailing list