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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 3 16:16:59 CET 2009


Author: rhijmans
Date: 2009-02-03 16:16:58 +0100 (Tue, 03 Feb 2009)
New Revision: 241

Modified:
   pkg/raster/R/pointsToRaster.R
   pkg/raster/R/stack.R
   pkg/raster/man/pointToRaster.Rd
Log:


Modified: pkg/raster/R/pointsToRaster.R
===================================================================
--- pkg/raster/R/pointsToRaster.R	2009-02-03 05:54:27 UTC (rev 240)
+++ pkg/raster/R/pointsToRaster.R	2009-02-03 15:16:58 UTC (rev 241)
@@ -5,7 +5,7 @@
 # Licence GPL v3
 
 
-pointsToRaster <- function(raster, xy, values, fun=length, filename="", overwrite=FALSE) {
+pointsToRaster <- function(raster, xy, values=rep(1, length(xy[,1])), fun=length, filename="", overwrite=FALSE) {
 # make this an argument ?  so that you can use e.g.  background=0 
 	background=NA
 

Modified: pkg/raster/R/stack.R
===================================================================
--- pkg/raster/R/stack.R	2009-02-03 05:54:27 UTC (rev 240)
+++ pkg/raster/R/stack.R	2009-02-03 15:16:58 UTC (rev 241)
@@ -132,8 +132,7 @@
 			}
 			rstack at data@colnames[1] <- cname
 			if (dataContent(raster) == 'all') {
-				rstack at data@values <- matrix(nrow=ncell(rstack), ncol=length(rasters))
-				rstack at data@values[,1] <- values(raster)
+				rstack at data@values <- as.matrix(values(raster))
 				rstack at data@content <- 'all'
 				raster <- clearValues(raster)
 			} else {
@@ -162,7 +161,7 @@
 				if (dataContent(raster) != 'all') {
 					raster <- readAll(raster)
 				} 
-				rstack at data@values[,nl] <- values(raster)
+				rstack at data@values <- cbind(rstack at data@values, values(raster))
 				raster <- clearValues(raster)
 			} else {
 				if (dataSource(raster)=='disk') {

Modified: pkg/raster/man/pointToRaster.Rd
===================================================================
--- pkg/raster/man/pointToRaster.Rd	2009-02-03 05:54:27 UTC (rev 240)
+++ pkg/raster/man/pointToRaster.Rd	2009-02-03 15:16:58 UTC (rev 241)
@@ -6,7 +6,7 @@
   Convert points to a RasterLayer object
 }
 \usage{
-pointsToRaster(raster, xy, values, fun=length, filename="", overwrite=FALSE)
+pointsToRaster(raster, xy, values=rep(1, length(xy[,1])), fun=length, filename="", overwrite=FALSE)
 }
 
 \arguments{



More information about the Raster-commits mailing list