[Raster-commits] r287 - pkg/raster/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 16 03:05:36 CET 2009


Author: jacobvanetten
Date: 2009-02-16 03:05:35 +0100 (Mon, 16 Feb 2009)
New Revision: 287

Modified:
   pkg/raster/R/distance.R
Log:
distance small issues

Modified: pkg/raster/R/distance.R
===================================================================
--- pkg/raster/R/distance.R	2009-02-15 14:48:33 UTC (rev 286)
+++ pkg/raster/R/distance.R	2009-02-16 02:05:35 UTC (rev 287)
@@ -55,7 +55,7 @@
 			outRaster <- setRaster(object, filename)
 			for(r in 1:nrows)
 			{
-				rowValues <- values(readRow(object, rownr = r))
+				rowValues <- valuesRow(readRow(object, rownr = r), rownr = r)
 				outRowValues <- rep(Inf,times=ncols)
 				outRowValues[is.na(rowValues)] <- 0
 				outRaster <- setValues(outRaster, outRowValues, r)
@@ -66,9 +66,9 @@
 				while(remainingCells){
 					remainingCells <- FALSE
 					oldRowValues <- integer(0)
-					rowWindow <- values(readRow(outRaster, rownr=1))
+					rowWindow <- valuesRow(readRow(outRaster, rownr=1), rownr = 1)
 					for(r in 1:nrows){
-						if(r<nrows){rowWindow <- c(rowWindow,values(readRow(outRaster, rownr=r+1)))}
+						if(r<nrows-1){rowWindow <- c(rowWindow,valuesRow(readRow(outRaster, rownr=r+1), rownr=r+1))}
 						adj <- adjacency(fromCells=(((max(1,r-1))*ncols)+1):(min(nrows,(r+2)*ncols)), toCells=((r-1)*ncols+1):(r*ncols),directions=8)
 						coord <- cbind(xyFromCell(object,adj[,1]),xyFromCell(object,adj[,2]))
 						distance <- apply(coord,1,function(x){distanceGreatcircle(x[1:2],x[3:4])})
@@ -91,9 +91,9 @@
 				while(remainingCells){
 					remainingCells <- FALSE
 					oldRowValues <- integer(0)
-					rowWindow <- values(readRow(outRaster, rownr=1))
+					rowWindow <- valuesRow(readRow(outRaster, rownr = 1), rownr = 1)
 					for(r in 1:nrows){
-						if(r<nrows){rowWindow <- c(rowWindow,values(readRow(outRaster, rownr=r+1)))}
+						if(r<nrows-1){rowWindow <- c(rowWindow,valuesRow(readRow(outRaster, rownr=r+1), rownr=r+1))}
 						fromCells <- (((max(1,r-1))*ncols)+1):(min(nrows,(r+2)*ncols))
 						toCells <- ((r-1)*ncols+1):(r*ncols)
 						adj1 <- adjacency(object,fromCells=fromCells,toCells=toCells,directions=4)



More information about the Raster-commits mailing list