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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 28 03:34:30 CET 2009


Author: jacobvanetten
Date: 2009-01-28 03:34:30 +0100 (Wed, 28 Jan 2009)
New Revision: 197

Modified:
   pkg/raster/R/get.R
Log:
bug fix cellFromXY

Modified: pkg/raster/R/get.R
===================================================================
--- pkg/raster/R/get.R	2009-01-28 02:33:38 UTC (rev 196)
+++ pkg/raster/R/get.R	2009-01-28 02:34:30 UTC (rev 197)
@@ -48,13 +48,11 @@
     return(colnr)
 }
 
-
-	
 cellFromXY <- function(object, xy) {
 	if (.isSPgrid(object)) { object <- asRasterLayer(object, FALSE) }
 	if (class(xy) == 'SpatialPoints' | class(xy) == 'SpatialPointsDataFrame') {
-		x <- xy at points[,1]
-		y <- xy at points[,2]
+		x <- coordinates(xy)[,1]
+		y <- coordinates(xy)[,2]
 	} else if (is.null(dim(xy))) { 
 		x <- xy[1]
 		y <- xy[2] 
@@ -74,9 +72,6 @@
 	return(cell)
 }
 
-
-
-
 cellFromRowCol <- function(object, rownr, colnr) {
 	if (.isSPgrid(object)) { object <- asRasterLayer(object, FALSE) }
 	rownr <- round(rownr)



More information about the Raster-commits mailing list