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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 9 03:19:59 CET 2009


Author: rhijmans
Date: 2009-01-09 03:19:58 +0100 (Fri, 09 Jan 2009)
New Revision: 107

Modified:
   pkg/raster/DESCRIPTION
   pkg/raster/R/set.R
Log:


Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-01-08 07:01:56 UTC (rev 106)
+++ pkg/raster/DESCRIPTION	2009-01-09 02:19:58 UTC (rev 107)
@@ -2,7 +2,7 @@
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
 Version: 0.8.4
-Date: 7-Jan-2009
+Date: 9-Jan-2009
 Depends: methods, sp, rgdal (>= 0.5-33)
 Author: Robert J. Hijmans & Jacob van Etten
 Maintainer: Robert J. Hijmans <r.hijmans at gmail.com> 

Modified: pkg/raster/R/set.R
===================================================================
--- pkg/raster/R/set.R	2009-01-08 07:01:56 UTC (rev 106)
+++ pkg/raster/R/set.R	2009-01-09 02:19:58 UTC (rev 107)
@@ -18,7 +18,6 @@
 }
 
 setRaster <- function(raster, filename="", values=NA) {
-
 	if (class(raster) == 'RasterStack') { raster <- raster at rasters[[1]] }
 	if (class(raster) == 'RasterBrick') { raster <- raster }
 	if (class(raster) != 'RasterLayer') { stop('the first argument should be a RasterLayer or a RasterStack object') }
@@ -34,9 +33,9 @@
 
 	raster <- setFilename(raster, filename)
 	raster <- setDatatype(raster, 'numeric')
-	if (!is.na(values[1])) {
+	if ( length(values) != 1 | ( length(values) == 1 & ncells(raster) == 1) ) {
 		raster <- setValues(raster, values)
-	}	
+	}
 	return(raster)
 }
 



More information about the Raster-commits mailing list