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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 28 10:58:27 CET 2009


Author: rhijmans
Date: 2009-01-28 10:58:22 +0100 (Wed, 28 Jan 2009)
New Revision: 201

Added:
   pkg/raster/man/pointToRaster.Rd
   pkg/raster/man/saveStack.Rd
Modified:
   pkg/raster/R/compare.logical.functions.R
   pkg/raster/R/point2raster.R
   pkg/raster/R/stack.R
   pkg/raster/man/create.stack.Rd
Log:


Modified: pkg/raster/R/compare.logical.functions.R
===================================================================
--- pkg/raster/R/compare.logical.functions.R	2009-01-28 09:20:32 UTC (rev 200)
+++ pkg/raster/R/compare.logical.functions.R	2009-01-28 09:58:22 UTC (rev 201)
@@ -24,7 +24,7 @@
 
 setMethod('==', signature(e1='BasicRaster', e2='BasicRaster'),
 	function(e1,e2){
-		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.0001, stopiffalse=FALSE) 
+		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.05, stopiffalse=FALSE) 
 		return(cond)
 	}
 )	
@@ -33,7 +33,7 @@
 
 setMethod('!=', signature(e1='BasicRaster', e2='BasicRaster'),
 	function(e1,e2){
-		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.0001, stopiffalse=FALSE) 
+		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.05, stopiffalse=FALSE) 
 		return(!cond)
 	}
 )	

Modified: pkg/raster/R/point2raster.R
===================================================================
--- pkg/raster/R/point2raster.R	2009-01-28 09:20:32 UTC (rev 200)
+++ pkg/raster/R/point2raster.R	2009-01-28 09:58:22 UTC (rev 201)
@@ -3,27 +3,21 @@
 	if (class(xy) != 'matrix') {stop('xy must be a matrix')}
 	if (length(values) != length(xy[,1])) {stop('values must be a vector of length=length(xy[,1])')}
 	
-	xya <- cbind(xy, values)
 	rs <- setRaster(raster, filename)
-	cells <- cellFromXY(rs, xya[,1:2])
+	cells <- cellFromXY(rs, xy)
 	rows <- rowFromCell(rs, cells)
 	cols <- colFromCell(rs, cells)
-	xyarc <- cbind(xya, rows, cols)
+	xyarc <- cbind(xy, values, rows, cols)
 	urows <- unique(rows)
 	urows <- urows[order(urows)]
-#	allrows <- seq(1:nrow(rs))
-#	allrows <- cbind(allrows, FALSE)
-#	allrows[urows, 2] <- TRUE
 	d <- vector(length=ncol(rs))
 	d[] <- NA
 	dna <- d
 	v <- vector(length=0)	
-	for (r in 1 : rs at nrows) {
-#		if (!allrows[r, 2]) {	
+	for (r in 1:rs at nrows) {
 		if (r %in% urows) {
 			ss <- subset(xyarc, xyarc[,4] == r)
-			cols <- ss[,5]
-			ucols <- unique(cols)
+			ucols <- unique(ss[,5])
 			ucols <- ucols[order(ucols)]
 			d <- dna
 			for (c in 1:length(ucols)) {

Modified: pkg/raster/R/stack.R
===================================================================
--- pkg/raster/R/stack.R	2009-01-28 09:20:32 UTC (rev 200)
+++ pkg/raster/R/stack.R	2009-01-28 09:58:22 UTC (rev 201)
@@ -156,7 +156,7 @@
 }	
 
 
-stackRemove <- function(rstack, indices) {
+dropLayer <- function(rstack, indices) {
 	indices <- sort(indices, decreasing=TRUE)
 	for (i in 1:length(indices)) {
 		index <- -1 * indices[i]

Modified: pkg/raster/man/create.stack.Rd
===================================================================
--- pkg/raster/man/create.stack.Rd	2009-01-28 09:20:32 UTC (rev 200)
+++ pkg/raster/man/create.stack.Rd	2009-01-28 09:58:22 UTC (rev 201)
@@ -5,29 +5,24 @@
 \alias{stackFromRasters}
 \alias{addFiles}
 \alias{addRasters}
-\alias{stackRemove}
-\alias{stackSave}
-\alias{stackOpen}
+\alias{dropLayer}
 
 \title{ Create or change a new stack }
 \description{
   A raster stack is a collection of rasters with the same spatial extent and resolution. They can be crated from RasterLayer objects, or from raster files.
-  You can add raster to or remove raster from a rasterstack. You can also save a stack to a file, to recreate it later.  
+  You can add raster to or remove raster from a rasterstack. 
 }
 
 \usage{
-stackOpen(stackfile)
-stackSave(rstack)
 makeStack(x, ...)
 stackFromFiles(rasterfiles, bands= rep(1, length(rasterfiles)))
 addFiles(rstack, rasterfiles, bands= rep(1, length(rasterfiles))) 
 addRasters(rstack, rasters) 
-stackRemove(rstack, indices) 
+dropLayer(rstack, indices) 
 }
 
 \arguments{
-  \item{stackfile}{ Filename for the stack (to save it on disk) }
-  \item{rstack}{ a RasterStack object }
+   \item{rstack}{ a RasterStack object }
   \item{x}{a RasterLayer object}
   \item{...}{additional RasterLayer objects (or filenames) }
   \item{rasterfiles}{ Filename(s) of (a) raster dataset(s) }
@@ -37,7 +32,8 @@
 }
 \details{
   When a  stack is saved to a file, only pointers (filenames) to raster datasets are saved, not the data. If the name or location of a raster file changes, the stack becomes invalid.
-  rasters contained in a stack can be accessed like this stack at rasters[[index]] where index is between 1 and stack at nrasters.  
+  In stackFromFiles, use index=-1 to add all bands of a single file to the RasterStack
+
 }
 \value{
   a stack object
@@ -54,12 +50,7 @@
   rs <- rasterFromFile(rasterfile)
   st <- addRasters(st, c(rs, rs))
   st
-  st <- stackRemove(st, c(3, 5))
+  st <- dropLayer(st, c(3, 5))
   nlayers(st)
-  st <- setFilename(st, "mystack")
-  st <- stackSave(st)
-# note that setFilename adds an extension .stk to a stackfile  
-  st2 <- stackOpen("mystack.stk")
-  st2
 }
 \keyword{ spatial }

Added: pkg/raster/man/pointToRaster.Rd
===================================================================
--- pkg/raster/man/pointToRaster.Rd	                        (rev 0)
+++ pkg/raster/man/pointToRaster.Rd	2009-01-28 09:58:22 UTC (rev 201)
@@ -0,0 +1,34 @@
+\name{ point to raster conversion}
+\alias{pointsToRaster}
+\alias{diversity.index.richness}
+
+\title{ Point to raster diversity functions }
+\description{
+  Convert points to a RasterLayer object
+}
+\usage{
+pointsToRaster(raster, xy, values, fun=length, filename="", overwrite=FALSE)
+}
+
+\arguments{
+  \item{raster}{ ~~Describe \code{rs} here~~ }
+  \item{filename}{ ~~Describe \code{filename} here~~ }
+  \item{overwrite}{ ~~Describe \code{filename} here~~ }  
+  \item{xy}{ ~~Describe \code{xya} here~~ }
+  \item{values}{ ~~Describe \code{xya} here~~ }  
+  \item{fun}{ ~~Describe \code{fun} here~~ }
+}
+
+
+\details{
+}
+\value{
+  a RasterLayer object
+}
+\author{Robert J. Hijmans  \email{r.hijmans at gmail.com}}
+
+
+\examples{
+
+}
+\keyword{ spatial }

Added: pkg/raster/man/saveStack.Rd
===================================================================
--- pkg/raster/man/saveStack.Rd	                        (rev 0)
+++ pkg/raster/man/saveStack.Rd	2009-01-28 09:58:22 UTC (rev 201)
@@ -0,0 +1,40 @@
+\name{rasterstack.create}
+\alias{stackSave}
+\alias{stackOpen}
+
+\title{ Create or change a new stack }
+\description{
+  A raster stack is a collection of rasters with the same spatial extent and resolution. They can be crated from RasterLayer objects, or from raster files.
+  These two functions allow you to save the references to raster files and recreate a rasterStack object later. 
+}
+
+\usage{
+stackOpen(stackfile)
+stackSave(rstack)
+}
+
+\arguments{
+  \item{stackfile}{ Filename for the stack (to save it on disk) }
+  \item{rstack}{ a RasterStack object }
+}
+\details{
+  When a  stack is saved to a file, only pointers (filenames) to raster datasets are saved, not the data. If the name or location of a raster file changes, the stack becomes invalid.
+  In stackFromFiles, use index=-1 to add all bands of a single file to the RasterStack
+
+}
+\value{
+  a stack object
+}
+\author{Robert J. Hijmans  \email{r.hijmans at gmail.com}}
+
+\seealso{ ~~objects to See Also as \code{\link{help}}, ~~~ }
+\examples{
+  rasterfile <- system.file("external/test.ag", package="sp")
+  st <- stackFromFiles(c(rasterfile, rasterfile))
+  st <- setFilename(st, "mystack")
+  st <- stackSave(st)
+# note that setFilename adds an extension .stk to a stackfile  
+  st2 <- stackOpen("mystack.stk")
+  st2
+}
+\keyword{ spatial }



More information about the Raster-commits mailing list