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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 22 14:02:01 CEST 2009


Author: rhijmans
Date: 2009-04-22 14:02:00 +0200 (Wed, 22 Apr 2009)
New Revision: 423

Added:
   pkg/raster/R/drawBox.R
Removed:
   pkg/raster/R/drawBbox.R
Modified:
   pkg/raster/R/plot.R
   pkg/raster/R/reclass.R
   pkg/raster/R/valuesRow.R
   pkg/raster/R/zonal.R
   pkg/raster/man/click.Rd
   pkg/raster/man/drawBbox.Rd
   pkg/raster/man/getBbox.Rd
Log:


Deleted: pkg/raster/R/drawBbox.R
===================================================================
--- pkg/raster/R/drawBbox.R	2009-04-20 15:36:34 UTC (rev 422)
+++ pkg/raster/R/drawBbox.R	2009-04-22 12:02:00 UTC (rev 423)
@@ -1,19 +0,0 @@
-# R function for the raster package
-# Author: Robert J. Hijmans
-# International Rice Research Institute. Philippines
-# contact: r.hijmans at gmail.com
-# Date : January 2009
-# Version 0.8
-# Licence GPL v3
-
-
-
-drawBbox <- function(show=TRUE, col="red") {
-	loc <- locator(n=2, type="p")
-	bb <- newBbox(min(loc$x), max(loc$x), min(loc$y), max(loc$y))
-	if (show) {
-		p <- rbind(c(bb at xmin, bb at ymin), c(bb at xmin, bb at ymax), c(bb at xmax, bb at ymax), c(bb at xmax, bb at ymin), c(bb at xmin, bb at ymin) )
-		lines(p, col=col)
-	}
-	return(bb)
-}

Added: pkg/raster/R/drawBox.R
===================================================================
--- pkg/raster/R/drawBox.R	                        (rev 0)
+++ pkg/raster/R/drawBox.R	2009-04-22 12:02:00 UTC (rev 423)
@@ -0,0 +1,19 @@
+# R function for the raster package
+# Author: Robert J. Hijmans
+# International Rice Research Institute. Philippines
+# contact: r.hijmans at gmail.com
+# Date : January 2009
+# Version 0.8
+# Licence GPL v3
+
+
+
+drawBox <- function(show=TRUE, col="red") {
+	loc <- locator(n=2, type="p")
+	bb <- newBbox(min(loc$x), max(loc$x), min(loc$y), max(loc$y))
+	if (show) {
+		p <- rbind(c(bb at xmin, bb at ymin), c(bb at xmin, bb at ymax), c(bb at xmax, bb at ymax), c(bb at xmax, bb at ymin), c(bb at xmin, bb at ymin) )
+		lines(p, col=col)
+	}
+	return(bb)
+}

Modified: pkg/raster/R/plot.R
===================================================================
--- pkg/raster/R/plot.R	2009-04-20 15:36:34 UTC (rev 422)
+++ pkg/raster/R/plot.R	2009-04-22 12:02:00 UTC (rev 423)
@@ -6,18 +6,18 @@
 
 
 setMethod("plot", signature(x='RasterStack', y='ANY'), 
-	function(x, y, ...)  {
+	function(x, y, col=rev(terrain.colors(25)), subsample=TRUE, maxdim=500, addbox=TRUE, axes = TRUE, xlab="", ylab="", ...)  {
 		if (missing(y)) {
 			nl <- nlayers(x)
-			if (nl > 25) {
-				warning('only first 25 layers are mapped')
-				nl <- 25
+			if (nl > 12) {
+				warning('only first 12 layers are plotted')
+				nl <- 12
 			}
 			nc <- ceiling(sqrt(nl))
 			nr <- ceiling(nl / nc)
 			par(mfrow=c(nr, nc))
 			for (i in 1:nl) {
-				.plotraster(x, index=i, col=rev(terrain.colors(25)), subsample=TRUE, maxdim=500, addbox=TRUE, axes = TRUE, xlab="", ylab="", ...) 
+				.plotraster(x, index=i, col=col, subsample=subsample, maxdim=maxdim, addbox=addbox, axes=axes, xlab=xlab, ylab=ylab, ...) 
 			}
 		} else if (is.numeric(y)) {
 			y <- unique(as.integer(round(y)))
@@ -28,10 +28,10 @@
 				par(mfrow=c(nr, nc))
 				par(mfrow=c(nr, nc))
 				for (i in 1:length(y)) {
-					.plotraster(x, index=y[i], col=rev(terrain.colors(25)), subsample=TRUE, maxdim=500, addbox=TRUE, axes = TRUE, xlab="", ylab="", ...) 
+					.plotraster(x, index=y[i], col=col, subsample=subsample, maxdim=maxdim, addbox=addbox, axes=axes, xlab=xlab, ylab=ylab, ...) 
 				}
 			} else {
-				.plotraster(x, index=y, col=rev(terrain.colors(25)), subsample=TRUE, maxdim=500, addbox=TRUE, axes = TRUE, xlab="", ylab="", ...) 
+				.plotraster(x, index=y, col=col, subsample=subsample, maxdim=maxdim, addbox=addbox, axes=axes, xlab=xlab, ylab=ylab, ...) 
 			}		
 		}
 	}
@@ -39,8 +39,8 @@
 
 
 setMethod("plot", signature(x='RasterLayer', y='missing'), 
-	function(x, ...)  {
-		.plotraster(x, col=rev(terrain.colors(25)), subsample=TRUE, maxdim=500, addbox=TRUE, axes = TRUE, xlab="", ylab="", ...) 
+	function(x, col=rev(terrain.colors(25)), subsample=TRUE, maxdim=500, addbox=TRUE, axes = TRUE, xlab="", ylab="", ...)  {
+		.plotraster(x, col=col, subsample=subsample, maxdim=maxdim, addbox=addbox, axes=axes, xlab=xlab, ylab=ylab, ...) 
 	}
 )	
 
@@ -58,4 +58,3 @@
 	}
 )
 	
-

Modified: pkg/raster/R/reclass.R
===================================================================
--- pkg/raster/R/reclass.R	2009-04-20 15:36:34 UTC (rev 422)
+++ pkg/raster/R/reclass.R	2009-04-22 12:02:00 UTC (rev 423)
@@ -33,7 +33,7 @@
 			if (is.na(rclmat[i,1]) | is.na(rclmat[i,2])) {
 				res[ is.na(values(raster)) ] <- rclmat[i, 3] 
 			} else { 
-				res[ (values(raster) > rclmat[i,1]) & (values(raster) <= rclmat[i,2]) ] <- rclmat[i , 3] 
+				res[ (values(raster) >= rclmat[i,1]) & (values(raster) <= rclmat[i,2]) ] <- rclmat[i , 3] 
 			}
 		}
 		if ( dataContent(raster) == 'all') { 

Modified: pkg/raster/R/valuesRow.R
===================================================================
--- pkg/raster/R/valuesRow.R	2009-04-20 15:36:34 UTC (rev 422)
+++ pkg/raster/R/valuesRow.R	2009-04-22 12:02:00 UTC (rev 423)
@@ -9,7 +9,7 @@
 
 valuesRow <- function(object, rownr) {
 	if (dataContent(object) == 'nodata') {
-		stop('no values in memory. First read or set values')
+		return(values(readRow(object, rownr)))
 	}
 	if (rownr < 0) {
 		if (dataContent(object) == 'all') {

Modified: pkg/raster/R/zonal.R
===================================================================
--- pkg/raster/R/zonal.R	2009-04-20 15:36:34 UTC (rev 422)
+++ pkg/raster/R/zonal.R	2009-04-22 12:02:00 UTC (rev 423)
@@ -7,8 +7,11 @@
 zonal <- function(raster, zones, stat='mean', keepdata=TRUE, track=-1) {
 
 	if (class(stat) != 'character') {
-		if (canProcessInMemory(raster, 4)) {
-			d <- cbind(values(readAll(raster)), as.integer(values(readAll(zones))))
+		if (canProcessInMemory(raster, 3)) {
+			d <- values(readAll(raster))
+			rm(raster)
+			d <- cbind(d, as.integer(values(readAll(zones))))
+			rm(zones)
 			if (keepdata) {
 				d <- na.omit(d)
 			}

Modified: pkg/raster/man/click.Rd
===================================================================
--- pkg/raster/man/click.Rd	2009-04-20 15:36:34 UTC (rev 422)
+++ pkg/raster/man/click.Rd	2009-04-22 12:02:00 UTC (rev 423)
@@ -29,7 +29,7 @@
 The value(s) of \code{object} at the point(s) clicked on; and the coordinates if \code{xy==TRUE}.
 } 
 
-\seealso{ \code{\link[raster]{drawBbox}} }
+\seealso{ \code{\link[raster]{drawBox}} }
 
 \author{ Robert J. Hijmans }
 

Modified: pkg/raster/man/drawBbox.Rd
===================================================================
--- pkg/raster/man/drawBbox.Rd	2009-04-20 15:36:34 UTC (rev 422)
+++ pkg/raster/man/drawBbox.Rd	2009-04-22 12:02:00 UTC (rev 423)
@@ -1,12 +1,12 @@
-\name{drawBbox}
-\alias{drawBbox}
+\name{drawBox}
+\alias{drawBox}
 
 \title{ Draw Bounding Box }
 \description{
   Click on two points of a plot (map) to obtain a BoundingBox object  
 }
 \usage{
-drawBbox(show = TRUE, col = "red") 
+drawBox(show = TRUE, col = "red") 
 }
 
 \arguments{
@@ -25,8 +25,8 @@
 r1 <- raster(nrow=10, ncol=10)
 r1[] <- runif(ncell(r1))
 #plot(r1)
-#bb <- drawBbox()
-#mean(values(crop(r1, drawBbox())))
+#bb <- drawBox()
+#mean(values(crop(r1, drawBox())))
 
 
 

Modified: pkg/raster/man/getBbox.Rd
===================================================================
--- pkg/raster/man/getBbox.Rd	2009-04-20 15:36:34 UTC (rev 422)
+++ pkg/raster/man/getBbox.Rd	2009-04-22 12:02:00 UTC (rev 423)
@@ -32,7 +32,7 @@
   
 \author{Robert J. Hijmans}
 
-\seealso{ \code{\link[raster]{setBoungingBox}}, \code{\link[raster]{drawBbox}} }
+\seealso{ \code{\link[raster]{setExtent}}, \code{\link[raster]{drawBox}} }
 
 \examples{
 r <- raster()



More information about the Raster-commits mailing list