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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 25 09:26:17 CET 2009


Author: rhijmans
Date: 2009-02-25 09:26:17 +0100 (Wed, 25 Feb 2009)
New Revision: 298

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


Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-02-25 08:15:27 UTC (rev 297)
+++ pkg/raster/DESCRIPTION	2009-02-25 08:26:17 UTC (rev 298)
@@ -1,8 +1,8 @@
 Package: raster
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
-Version: 0.8.8-6
-Date: 22-Feb-2009
+Version: 0.8.8-7
+Date: 25-Feb-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> 

Modified: pkg/raster/R/copyRaster.R
===================================================================
--- pkg/raster/R/copyRaster.R	2009-02-25 08:15:27 UTC (rev 297)
+++ pkg/raster/R/copyRaster.R	2009-02-25 08:26:17 UTC (rev 298)
@@ -6,6 +6,20 @@
 
 
 saveAs <- function(raster, filename, filetype='raster', datatype='FLT4S', overwrite=FALSE) {
+	
+	if (dataContent(raster) == 'all') {
+		raster <- setDatatype(raster, datatype)
+		filename(raster) <- filename
+		raster <- writeRaster(raster, filetype=filetype, overwrite=overwrite)
+		return(raster)
+	} 
+	
+	if ( trim(filename(raster)) == trim(filename) ) {
+		stop('filenames should be different')
+	}
+
+# if filetype and datatype are the same, then use copyRasterfile 
+
 	newr <- setRaster(raster, filename)
 	newr <- setDatatype(newr, datatype)
 	for (r in 1:nrow(newr)) {



More information about the Raster-commits mailing list