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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jan 24 10:20:29 CET 2009


Author: rhijmans
Date: 2009-01-24 10:20:28 +0100 (Sat, 24 Jan 2009)
New Revision: 177

Modified:
   pkg/raster/DESCRIPTION
   pkg/raster/R/bounding.box.R
   pkg/raster/R/replacement.R
   pkg/raster/man/bbox.Rd
Log:


Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-01-23 09:26:46 UTC (rev 176)
+++ pkg/raster/DESCRIPTION	2009-01-24 09:20:28 UTC (rev 177)
@@ -1,8 +1,8 @@
 Package: raster
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
-Version: 0.8.6-5
-Date: 23-Jan-2009
+Version: 0.8.6-6
+Date: 24-Jan-2009
 Depends: methods, sp, rgdal (>= 0.5-33), R (>= 2.8.0)
 Author: Robert J. Hijmans & Jacob van Etten
 Maintainer: Robert J. Hijmans <r.hijmans at gmail.com> 

Modified: pkg/raster/R/bounding.box.R
===================================================================
--- pkg/raster/R/bounding.box.R	2009-01-23 09:26:46 UTC (rev 176)
+++ pkg/raster/R/bounding.box.R	2009-01-24 09:20:28 UTC (rev 177)
@@ -86,7 +86,8 @@
 )
 
 
-bbIndices <- function(object, bndbox) {
+cellsFromBbox <- function(object, bndbox) {
+	bndbox <- getBbox(bndbox)
 	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) 
@@ -151,7 +152,7 @@
 		newobj at bbox@ymax <- newobj at bbox@ymin + nrow(newobj) * yrs
 		
 		if (dataContent(object) == 'all') {
-			indices <- bbIndices(object, bb)
+			indices <- cellsFromBbox(object, bb)
 			newobj <- setValues(newobj, values(object)[indices])
 		}
 	} else if (ncol(object)==ncol(newobj) & nrow(object)==nrow(newobj)) {

Modified: pkg/raster/R/replacement.R
===================================================================
--- pkg/raster/R/replacement.R	2009-01-23 09:26:46 UTC (rev 176)
+++ pkg/raster/R/replacement.R	2009-01-24 09:20:28 UTC (rev 177)
@@ -48,6 +48,9 @@
 setReplaceMethod("[", "RasterLayer",  
 	function(x, i, j, value) {
 		if  (!missing(j)) {	stop("incorrect number of dimensions") }
+		if (class(i) == "RasterLayer") {
+			i <- as.logical( .getRasterValues(i) ) 
+		}
 # what about data rows ?		
 		if (dataContent(x) == 'nodata') {
 			if (ncell(x) < 1000000) {

Modified: pkg/raster/man/bbox.Rd
===================================================================
--- pkg/raster/man/bbox.Rd	2009-01-23 09:26:46 UTC (rev 176)
+++ pkg/raster/man/bbox.Rd	2009-01-24 09:20:28 UTC (rev 177)
@@ -10,7 +10,7 @@
 \alias{newBbox}
 \alias{setBbox}
 \alias{changeBbox}
-
+\alias{cellsFromBbox}
   
 \title{Bounding box functions}
 \description{
@@ -27,6 +27,7 @@
 newBbox(xmn, xmx, ymn, ymx)
 setBbox(object, bndbox, keepres=FALSE, snap=FALSE)
 changeBbox(object, xmn=xmin(object), xmx=xmax(object), ymn=ymin(object), ymx = ymax(object), keepres=FALSE) 
+cellsFromBbox(object, bndbox)
 }
 
 \arguments{



More information about the Raster-commits mailing list