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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 12 10:16:13 CET 2009


Author: rhijmans
Date: 2009-01-12 10:16:13 +0100 (Mon, 12 Jan 2009)
New Revision: 120

Modified:
   pkg/raster/DESCRIPTION
   pkg/raster/R/set.R
   pkg/raster/R/standard.generic.functions.R
   pkg/raster/man/set.Rd
Log:


Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-01-12 03:59:53 UTC (rev 119)
+++ pkg/raster/DESCRIPTION	2009-01-12 09:16:13 UTC (rev 120)
@@ -2,8 +2,8 @@
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
 Version: 0.8.4
-Date: 11-Jan-2009
-Depends: methods, sp, rgdal (>= 0.5-33)
+Date: 12-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> 
 Description: Package for reading and manipulating (geographic, spatial) raster (grid) data

Modified: pkg/raster/R/set.R
===================================================================
--- pkg/raster/R/set.R	2009-01-12 03:59:53 UTC (rev 119)
+++ pkg/raster/R/set.R	2009-01-12 09:16:13 UTC (rev 120)
@@ -191,10 +191,13 @@
 	}
 }
 
-setValuesSparse <- function(raster, sparsevalues, indices) {
+setValuesSparse <- function(raster, sparsevalues, cellnumbers) {
+	if (!(isTRUE(length(cellnumbers) == (length(sparsevalues))))) {
+		stop()
+	}
 	raster at data@content <- 'sparse'
 	raster at data@values <- sparsevalues
-	raster at data@indices <- indices
+	raster at data@indices <- cellnumbers
 	raster at data@source <- 'ram'
 	raster <- setMinmax(raster)
 	return(raster)

Modified: pkg/raster/R/standard.generic.functions.R
===================================================================
--- pkg/raster/R/standard.generic.functions.R	2009-01-12 03:59:53 UTC (rev 119)
+++ pkg/raster/R/standard.generic.functions.R	2009-01-12 09:16:13 UTC (rev 120)
@@ -304,34 +304,32 @@
 )		
 
 
-# helper functions to set ... variables if they are not specified by the user. There probably exists a formal, and direct, mechanism to do this in R, but I have not discovered this yet...
-.getmaxdim <- function(maxdim=1000, ...) {
-	return(maxdim)
-}
+# helper function to set ... variables if they are not specified by the user. There probably exists a formal, and direct, mechanism to do this in R, but I have not discovered this yet...
+#.getmaxdim <- function(maxdim=1000, ...) {
+#	return(maxdim)
+#}
 
-.getcex <- function(cex = 0.1, ...) {
+getcex <- function(cex = 0.1, ...) {
 	return(cex)
 }
 
 setMethod("plot", signature(x='RasterLayer', y='RasterLayer'), 
-	function(x, y, ...)  {
+	function(x, y, maxdim=1000, ...)  {
 		comp <- compare(c(x, y), bb=TRUE, rowcol=TRUE, prj=FALSE, tolerance=0.0001, stopiffalse=TRUE) 
-		maxdim <- .getmaxdim(...)
 		nc <- ncells(x)
 		x <- readSkip(x, maxdim=maxdim)
 		y <- readSkip(y, maxdim=maxdim)
 		if (length(x) < nc) {
-			warning(paste('plot used a sample of ', round(100*length(x)/ncells(y)), "% of the cells", sep=""))
+			warning(paste('plot used a sample of ', round(100*length(x)/nc), "% of the cells", sep=""))
 		}
-		cex <- .getcex(...)
+		cex <- getcex(...)
 		plot(x, y, ...)			
 	}
 )
 	
 
 setMethod('hist', signature(x='RasterLayer'), 
-	function(x, ...){
-		maxsamp <- 1000000
+	function(x, maxsamp=10000, ...){
 		if (dataContent(x) != 'all') {
 			if (dataSource(x) == 'disk') {
 		# TO DO: ake a function that does this by block and combines  all data into a single histogram

Modified: pkg/raster/man/set.Rd
===================================================================
--- pkg/raster/man/set.Rd	2009-01-12 03:59:53 UTC (rev 119)
+++ pkg/raster/man/set.Rd	2009-01-12 09:16:13 UTC (rev 120)
@@ -28,7 +28,7 @@
 setMinmax(raster)
 setValues(raster, values, rownr=-1) 
 setValuesBlock(raster, blockvalues, firstcell, lastcell) 
-setValuesSparse(raster, sparsevalues, indices) 
+setValuesSparse(raster, sparsevalues, cellnumbers) 
 
 makeSparse(raster)
 }
@@ -45,7 +45,7 @@
   \item{firstcell}{ first cell (upper left corner) of the blockdata }
   \item{lastcell}{ last cell (upper left corner) of the blockdata }
   \item{sparsevalues}{ not implemented yet -- sparse data values. I.e. values for a number of raster cells }
-  \item{indices}{ the cell numbers corresponding to the sparse data }
+  \item{cellnumbers}{ the cell numbers corresponding to the sparse data }
   \item{nrows}{ the new number of rows for the raster }
   \item{ncols}{ the new number of cols for the raster }  
   \item{projstring} {a character string describing a projection and datum in PROJ4 format }



More information about the Raster-commits mailing list