[Raster-commits] r143 - pkg/raster/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jan 16 04:53:19 CET 2009
Author: rhijmans
Date: 2009-01-16 04:53:19 +0100 (Fri, 16 Jan 2009)
New Revision: 143
Modified:
pkg/raster/R/get.R
Log:
Modified: pkg/raster/R/get.R
===================================================================
--- pkg/raster/R/get.R 2009-01-15 23:28:00 UTC (rev 142)
+++ pkg/raster/R/get.R 2009-01-16 03:53:19 UTC (rev 143)
@@ -129,9 +129,18 @@
endrow <- rowFromY(object, ymin(bbox))
startcol <- colFromX(object, xmin(bbox))
endcol <- colFromX(object, xmax(bbox))
- cols <- rep(startcol:endcol, times=(endrow - startrow))
- rows <- rep(startrow:endrow, each=(endcol - startcol))
- cells <- cellFromRowCol(object, rows, cols)
+
+# cols <- rep(startcol:endcol, times=(endrow - startrow))
+# rows <- rep(startrow:endrow, each=(endcol - startcol))
+# cells <- cellFromRowCol(object, rows, cols)
+
+ # RH: ouch. Use Apply instead:
+ cells <- vector("integer", length=0)
+ for (i in startrow:endrow) {
+ firstcell <- (i-1) * ncol(object) + startcol
+ lastcell <- (i-1) * ncol(object) + endcol
+ cells <- c(cells, c(firstcell:lastcell))
+ }
return(cells)
}
More information about the Raster-commits
mailing list