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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 6 06:10:28 CEST 2009


Author: rhijmans
Date: 2009-04-06 06:10:27 +0200 (Mon, 06 Apr 2009)
New Revision: 394

Added:
   pkg/raster/R/resetConnection.R
Modified:
   pkg/raster/R/closeHandle.R
   pkg/raster/R/pointsToRaster.R
   pkg/raster/man/writeadvanced.Rd
Log:


Modified: pkg/raster/R/closeHandle.R
===================================================================
--- pkg/raster/R/closeHandle.R	2009-04-05 15:30:47 UTC (rev 393)
+++ pkg/raster/R/closeHandle.R	2009-04-06 04:10:27 UTC (rev 394)
@@ -5,10 +5,10 @@
 # Licence GPL v3
 
 
-closeHandle <- function(raster) {
+closeConnection <- function(raster) {
 #	if handle = gdal then gdalclose the handle
 	if (class(raster) != 'RasterLayer') {
-		stop('closeHandle is only for RasterLayer objects')
+		stop('closeConnection is only for RasterLayer objects')
 	}
 	if (.driver(raster) == "gdal") {
 		try(closeDataset(raster at file@con), silent = T)

Modified: pkg/raster/R/pointsToRaster.R
===================================================================
--- pkg/raster/R/pointsToRaster.R	2009-04-05 15:30:47 UTC (rev 393)
+++ pkg/raster/R/pointsToRaster.R	2009-04-06 04:10:27 UTC (rev 394)
@@ -7,13 +7,6 @@
 
 pointsToRaster <- function(raster, xy, values=rep(1, length(xy[,1])), fun=length, background=NA, filename="", overwrite=FALSE, filetype='raster', datatype='FLT4S', track=-1) {
 	
-#	if (class(xy) == 'SpatialPointsDataFrame' & length(values)==1)  {
-#		values <- xy[[values]]
-#	}
-
-	if (!is.vector(values)) {
-		stop('values should be a vector')
-	}
 	xy <- .pointsToMatrix(xy)
 	
 	rs <- raster(raster, filename)

Added: pkg/raster/R/resetConnection.R
===================================================================
--- pkg/raster/R/resetConnection.R	                        (rev 0)
+++ pkg/raster/R/resetConnection.R	2009-04-06 04:10:27 UTC (rev 394)
@@ -0,0 +1,26 @@
+# Author: Robert J. Hijmans, r.hijmans at gmail.com
+# International Rice Research Institute
+# Date : April  2009
+# Version 0.8
+# Licence GPL v3
+
+
+
+resetConnection <- function(raster) {
+	if (class(raster) != 'RasterLayer') {
+		stop('resetConnection is only for RasterLayer objects')
+	}
+
+	fn <- trim(filename(object))
+	if (fn == "") { stop('no file') }
+	fileext <- toupper(fileExtension(fn)) 
+	if ( fileext == ".GRD" ) {
+		fileExtension(fn) <- '.gri'
+		attr(object at file, "con") <- file(fn, "rb")
+	} else {
+		attr(object at file, "con") <- GDAL.open(fn)
+	}
+	return(object)
+}
+
+

Modified: pkg/raster/man/writeadvanced.Rd
===================================================================
--- pkg/raster/man/writeadvanced.Rd	2009-04-05 15:30:47 UTC (rev 393)
+++ pkg/raster/man/writeadvanced.Rd	2009-04-06 04:10:27 UTC (rev 394)
@@ -1,6 +1,7 @@
 \name{advanced writing}
 
-\alias{closeHandle}
+\alias{closeConnection}
+\alias{resetConnection}
 \alias{canProcessInMemory}
 
 \title{ advanced writing }
@@ -20,7 +21,8 @@
 
 \usage{
 canProcessInMemory(raster, n=4)
-closeHandle(raster)
+closeConnection(raster)
+resetConnection(raster)
 }
 
 \arguments{



More information about the Raster-commits mailing list