[Raster-commits] r207 - pkg/raster/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 29 06:55:38 CET 2009
Author: rhijmans
Date: 2009-01-29 06:55:38 +0100 (Thu, 29 Jan 2009)
New Revision: 207
Modified:
pkg/raster/R/conversion.R
pkg/raster/R/values.R
Log:
Modified: pkg/raster/R/conversion.R
===================================================================
--- pkg/raster/R/conversion.R 2009-01-29 01:41:05 UTC (rev 206)
+++ pkg/raster/R/conversion.R 2009-01-29 05:55:38 UTC (rev 207)
@@ -153,12 +153,15 @@
if (type=='pixel') {
object <- makeSparse(object)
pts <- SpatialPoints(xyFromCell(object, dataIndices(object)))
- sp <- SpatialPixelsDataFrame(points=pts, data=as.data.frame(values(object)), proj4string=projection(object, FALSE))
+ data <- values(object)
+ data <- as.data.frame(data)
+ sp <- SpatialPixelsDataFrame(points=pts, data=data, proj4string=projection(object, FALSE))
} else if (type=='grid') {
if ( dataContent(object) == 'all') {
- values <- as.data.frame(values(object))
- sp <- SpatialGridDataFrame(grd, proj4string=projection(object, FALSE), data=values)
+ data <- values(object)
+ data <- as.data.frame(data)
+ sp <- SpatialGridDataFrame(grd, proj4string=projection(object, FALSE), data=data)
} else {
sp <- SpatialGrid(grd, proj4string=projection(object, FALSE))
}
Modified: pkg/raster/R/values.R
===================================================================
--- pkg/raster/R/values.R 2009-01-29 01:41:05 UTC (rev 206)
+++ pkg/raster/R/values.R 2009-01-29 05:55:38 UTC (rev 207)
@@ -1,4 +1,18 @@
+# Author: Robert J. Hijmans, r.hijmans at gmail.com
+# International Rice Research Institute
+# Date : June 2008
+# Version 0,1
+# Licence GPL v3
+
+
+
+#if (!isGeneric("values")) {
+# setGeneric("values", function(object, ...)
+# standardGeneric("values"))
+#}
+
+#setMethod('values', signature(object='Raster'),
values <- function(object, format='vector', names=FALSE) {
if (dataContent(object)=="nodata") {stop("first read some data (e.g., readAll()") }
if (format=='matrix') {
@@ -9,6 +23,7 @@
return(object at data@values)
}
}
+#)
More information about the Raster-commits
mailing list