[Raster-commits] r140 - pkg/raster/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 15 18:12:58 CET 2009
Author: rhijmans
Date: 2009-01-15 18:12:57 +0100 (Thu, 15 Jan 2009)
New Revision: 140
Added:
pkg/raster/R/click.R
Log:
click on map helper function
Added: pkg/raster/R/click.R
===================================================================
--- pkg/raster/R/click.R (rev 0)
+++ pkg/raster/R/click.R 2009-01-15 17:12:57 UTC (rev 140)
@@ -0,0 +1,28 @@
+# R function for the raster package
+# Author: Robert J. Hijmans
+# International Rice Research Institute. Philippines
+# contact: r.hijmans at gmail.com
+# Date : January 2009
+# Version 0.8
+# Licence GPL v3
+
+
+
+click <- function(object, n=1, xy=FALSE, type = "n", ...) {
+ loc <- locator(n)
+ x <- loc$x
+ y <- loc$y
+ xy <- cbind(x, y)
+ if (dataContent(object) != 'all') {
+ if (dataSource(object) != 'disk') {
+ stop('no data associated with this RasterLayer object')
+ } else {
+ return(xyValues(object, xy))
+ }
+ } else {
+ cell <- cellFromXY(object, xy)
+ value <- values(object)[cell]
+ return(cbind(xy, value))
+ }
+}
+
More information about the Raster-commits
mailing list