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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 11 00:44:37 CEST 2009


Author: jacobvanetten
Date: 2009-08-11 00:44:36 +0200 (Tue, 11 Aug 2009)
New Revision: 470

Modified:
   pkg/raster/DESCRIPTION
   pkg/raster/R/distance.R
   pkg/raster/man/distance.Rd
Log:
distance(): feature added

Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-08-10 18:15:08 UTC (rev 469)
+++ pkg/raster/DESCRIPTION	2009-08-10 22:44:36 UTC (rev 470)
@@ -1,7 +1,7 @@
 Package: raster
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
-Version: 0.8.9-23
+Version: 0.8.9-24
 Date: 10-August-2009
 Depends: methods, sp, rgdal (>= 0.5-33), R (>= 2.8.0)
 Author: Robert J. Hijmans & Jacob van Etten

Modified: pkg/raster/R/distance.R
===================================================================
--- pkg/raster/R/distance.R	2009-08-10 18:15:08 UTC (rev 469)
+++ pkg/raster/R/distance.R	2009-08-10 22:44:36 UTC (rev 470)
@@ -19,7 +19,8 @@
 			outRaster <- raster(object, filename=filename)
 
 			fromCells <- which(!is.na(values(object)))
-			toCells <- (1:n)[-fromCells]
+			fromCells <- fromCells[which(values(object)[fromCells] == TRUE)]
+			toCells <- which(is.na(values(object)))
 			accDist <- rep(0,times=n)
 			accDist[toCells] <- Inf
 			if (isLatLon(object)) {

Modified: pkg/raster/man/distance.Rd
===================================================================
--- pkg/raster/man/distance.Rd	2009-08-10 18:15:08 UTC (rev 469)
+++ pkg/raster/man/distance.Rd	2009-08-10 22:44:36 UTC (rev 470)
@@ -8,8 +8,10 @@
 \title{Distance}
 
 \description{
- The function calculates the distance to cells of a RasterLayer that are \code{NA}.
+ The function calculates the distance to cells of a RasterLayer.
  
+ Origin cells should have value TRUE (or 1), destination cells should be \code{NA} and cells that can not be traversed should be set to FALSE (or 0).
+ 
  The distance is in meters if the RasterLayer is not projected (\code{+proj=longlat})
  and in map units (typically meters) when it is projected.
  



More information about the Raster-commits mailing list