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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Apr 17 03:08:59 CEST 2009


Author: rhijmans
Date: 2009-04-17 03:08:58 +0200 (Fri, 17 Apr 2009)
New Revision: 409

Modified:
   pkg/raster/R/raster.R
   pkg/raster/man/raster.Rd
Log:


Modified: pkg/raster/R/raster.R
===================================================================
--- pkg/raster/R/raster.R	2009-04-15 07:21:08 UTC (rev 408)
+++ pkg/raster/R/raster.R	2009-04-17 01:08:58 UTC (rev 409)
@@ -18,7 +18,15 @@
 	}
 )
 
+setMethod('raster', signature(x='matrix'), 
+	function(x, xmn=0, xmx=1, ymn=0, ymx=1, projs=NA) {
+		r <- raster(ncols=ncol(x), nrows=nrow(x), projs=projs, xmn=xmn, xmx=xmx, ymn=ymn, ymx=ymx)
+		r <- setValues(r, as.vector(t(x)))
+		return(r)
+	}
+)
 
+
 setMethod('raster', signature(x='character'), 
 	function(x, values=FALSE, band=1) {
 		fileext <- toupper(ext(x)) 
@@ -59,7 +67,7 @@
 
 
 setMethod('raster', signature(x='BoundingBox'), 
-	function(x, nrows=10, ncols=10, projs='NA') {
+	function(x, nrows=10, ncols=10, projs=NA) {
 		bb <- extent(x)
 		nr = as.integer(round(nrows))
 		nc = as.integer(round(ncols))

Modified: pkg/raster/man/raster.Rd
===================================================================
--- pkg/raster/man/raster.Rd	2009-04-15 07:21:08 UTC (rev 408)
+++ pkg/raster/man/raster.Rd	2009-04-17 01:08:58 UTC (rev 409)
@@ -7,6 +7,7 @@
 \alias{raster,character-method}
 \alias{raster,missing-method}
 \alias{raster,Raster-method}
+\alias{raster,matrix-method}
 
 \title{Create a RasterLayer object}
 
@@ -65,7 +66,7 @@
   
 3) Create a RasterLayer object from a BoundingBox object
   
-\code{raster(x, nrows=10, ncols=10, projs='NA')}
+\code{raster(x, nrows=10, ncols=10, projs=NA)}
 
 \tabular{rll}{
  \tab \code{x} \tab BoundingBox object \cr
@@ -79,7 +80,6 @@
 4) Create a RasterLayer object from a Raster* object. This copies the parameters of a Raster* object to a new RasterLayer, 
 but does not copy the filename nor the data associated with the original Raster* object. 
 
-
 \code{raster(x, filename="", values=NULL)}
 
 \tabular{rll}{
@@ -88,6 +88,20 @@
  \tab \code{values} \tab If not \code{NULL} it is used to set values to new object. Either pass a vector of length == ncells(x), or a single number \cr
 }
 
+
+5) Create a RasterLayer object from a matrix. The default extent is set to be between 0 and 1 in the x and y direction but can be changed at creation of the RasterLayer object or later. You can also provide a projection.  
+
+\code{function(x, xmn=0, xmx=1, ymn=0, ymx=1, projs=NA)}
+
+\tabular{rll}{
+ \tab \code{x} \tab a Raster* object \cr
+ \tab \code{xmn} \tab minimum x coordinate or raster (left border) \cr
+ \tab \code{xmx} \tab maximum x coordinate of raster (right border) \cr
+ \tab \code{ymn} \tab minimum y coordinate or raster (bottom border) \cr
+ \tab \code{ymx} \tab maximum y coordinate of raster (top border) \cr
+ \tab \code{projs} \tab PROJ4 type description of a map projection \cr
+}
+
 }}
 
 



More information about the Raster-commits mailing list