[Raster-commits] r414 - pkg/raster/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Apr 18 10:33:08 CEST 2009


Author: rhijmans
Date: 2009-04-18 10:33:06 +0200 (Sat, 18 Apr 2009)
New Revision: 414

Modified:
   pkg/raster/R/init.R
   pkg/raster/R/writeAscii.R
Log:


Modified: pkg/raster/R/init.R
===================================================================
--- pkg/raster/R/init.R	2009-04-18 05:08:58 UTC (rev 413)
+++ pkg/raster/R/init.R	2009-04-18 08:33:06 UTC (rev 414)
@@ -16,11 +16,9 @@
 		if (outraster at file@name != "") {	
 			outraster <- writeRaster(outraster, overwrite=overwrite) 
 		}
-		
 	} else if (dataSource(raster) == 'disk') {
 		starttime <- proc.time()
-
-		n <- length(ncol(raster))
+		n <- ncol(raster)
 		v <- vector(length=0)
 
 		for (r in 1:nrow(raster)) {
@@ -30,9 +28,7 @@
 				outraster <- setValues(outraster, fun(n), r) 
 				outraster <- writeRaster(outraster, filetype=filetype, overwrite=overwrite)
 			}	
-			
 			if (r %in% track) { .showTrack(r, outraster at nrows, track, starttime) }
-			
 		}
 		if (outraster at file@name == "") { 
 			outraster <- setValues(outraster, v) 

Modified: pkg/raster/R/writeAscii.R
===================================================================
--- pkg/raster/R/writeAscii.R	2009-04-18 05:08:58 UTC (rev 413)
+++ pkg/raster/R/writeAscii.R	2009-04-18 08:33:06 UTC (rev 414)
@@ -8,7 +8,11 @@
 
 
 .writeAscii <- function(raster, overwrite=FALSE) {
-	filename <- filename(raster)
+	filename <- trim(raster at file@name)
+	if (filename == "") {
+		stop('first provide a filename. E.g.: filename(raster) <- "c:/myfile"')
+	}
+	
 	if (dataIndices(raster)[1] == 1) {
 		resdif <- abs((yres(raster) - xres(raster)) / yres(raster) )
 		if (resdif > 0.01) {



More information about the Raster-commits mailing list