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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 13 12:41:44 CET 2009


Author: rhijmans
Date: 2009-01-13 12:41:44 +0100 (Tue, 13 Jan 2009)
New Revision: 131

Modified:
   pkg/raster/R/adjacency.R
   pkg/raster/man/adjacency.Rd
Log:
return() in bishop function, and expanded example

Modified: pkg/raster/R/adjacency.R
===================================================================
--- pkg/raster/R/adjacency.R	2009-01-13 08:16:43 UTC (rev 130)
+++ pkg/raster/R/adjacency.R	2009-01-13 11:41:44 UTC (rev 131)
@@ -287,4 +287,5 @@
 	}
 	else{}
 	fromto <- subset(fromto,fromto[,2] %in% toCells)
+	return(fromto)
 }

Modified: pkg/raster/man/adjacency.Rd
===================================================================
--- pkg/raster/man/adjacency.Rd	2009-01-13 08:16:43 UTC (rev 130)
+++ pkg/raster/man/adjacency.Rd	2009-01-13 11:41:44 UTC (rev 131)
@@ -2,9 +2,9 @@
 \alias{adjacency}
 \alias{adjBishop}
 
-\title{ adjacency }
+\title{adjacency}
 \description{
-	calculate adjacent cells in a grid
+	calculate adjacent cells on a grid
 }
 \usage{
 adjacency(raster, fromCells, toCells, directions, outerMeridianConnect) 
@@ -12,11 +12,11 @@
 }
 
 \arguments{
-  \item{raster}{ an object of the Raster family }
-  \item{fromCells}{ a vector of cell numbers for which adjacent cells should be calculated }
-  \item{toCells}{ a vector of cell numbers from which adjacent cells are selected }
-  \item{directions}{ in how many direction cells should be connected: 4, 8 or 16. }
-  \item{outerMeridianConnect}{ logical value indicating whether the outer columns of the raster should be connected as a cylinder }
+  \item{raster}{an object of the Raster family}
+  \item{fromCells}{a vector of cell numbers for which adjacent cells should be calculated}
+  \item{toCells}{a vector of cell numbers from which adjacent cells are selected}
+  \item{directions}{in how many direction cells should be connected: 4, 8 or 16.}
+  \item{outerMeridianConnect}{logical value indicating whether the outer columns of the raster should be connected as a cylinder}
 }
 
 \details{
@@ -28,12 +28,18 @@
 \value{
   a two column matrix with each row containing a pair of adjacent cells. 
 }
-\author{ Jacob van Etten \email{jacobvanetten at yahoo.com} }
+\author{Jacob van Etten \email{jacobvanetten at yahoo.com}}
 
 \examples{
 	rs <- newRaster(nrows=10, ncols=10)
-	adjacency(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncells(rs)), directions=16, outerMeridianConnect = TRUE) 
-	adjBishop(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncells(rs)), outerMeridianConnect = TRUE) 
+	adj <- adjacency(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncells(rs)), directions=4, outerMeridianConnect = TRUE) 
+	v <- vector(length=ncells(rs))
+	v[adj[,2]] <- 2
+	v[adj[,1]] <- 1
+	rs <- setValues(rs, v)
+	plot(rs)
+
+	adjbis <- adjBishop(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncells(rs)), outerMeridianConnect = TRUE) 
 }
 
-\keyword{ spatial }
\ No newline at end of file
+\keyword{spatial}



More information about the Raster-commits mailing list