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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 14 10:26:54 CET 2009


Author: rhijmans
Date: 2009-01-14 10:26:54 +0100 (Wed, 14 Jan 2009)
New Revision: 135

Modified:
   pkg/raster/R/adjacency.R
   pkg/raster/R/properties.R
   pkg/raster/man/properties.Rd
Log:


Modified: pkg/raster/R/adjacency.R
===================================================================
--- pkg/raster/R/adjacency.R	2009-01-13 16:02:37 UTC (rev 134)
+++ pkg/raster/R/adjacency.R	2009-01-14 09:26:54 UTC (rev 135)
@@ -12,6 +12,14 @@
 }
 
 #Costumized (internal) functions can be created for each number of directions and for upper, middle and lower rows to optimize the code for row-level processing. 32 directions can be created if higher precision is needed.
+#adjraster <- function(raster, directions, outerMeridianConnect) {
+#	adjacency(raster, !is.na(cbind(1:ncells(raster),values(raster)))[,1], 1:ncells(raster), directions, outerMeridianConnect)
+#	v <- vector(length=ncells(raster))
+#	v[adj[,2]] <- 2
+#	v[adj[,1]] <- 1
+#	rs <- setValues(rs, v)
+#	return(raster)
+#}
 
 adjacency <- function(raster, fromCells, toCells, directions, outerMeridianConnect)
 {

Modified: pkg/raster/R/properties.R
===================================================================
--- pkg/raster/R/properties.R	2009-01-13 16:02:37 UTC (rev 134)
+++ pkg/raster/R/properties.R	2009-01-14 09:26:54 UTC (rev 135)
@@ -5,6 +5,31 @@
 # Licence GPL v3
 
 
+if (!isGeneric("isLatLon")) {
+	setGeneric("isLatLon", function(object)
+		standardGeneric("isLatLon"))
+}	
+
+setMethod('isLatLon', signature(object='Raster'), 
+# copied from the SP package (slightly adapted)
+#author:
+# ...
+	function(object){
+		p4str <- projection(object)
+		if (is.na(p4str) || nchar(p4str) == 0) {
+			return(as.logical(NA))
+		} 
+		res <- grep("longlat", p4str, fixed = TRUE)
+		if (length(res) == 0) {
+			return(FALSE)
+		} else {
+			return(TRUE)
+		}
+    }
+)
+
+
+
 filename <- function(object) {
 	if (class(object) == 'RasterStack') { 
 		return(object at filename) 

Modified: pkg/raster/man/properties.Rd
===================================================================
--- pkg/raster/man/properties.Rd	2009-01-13 16:02:37 UTC (rev 134)
+++ pkg/raster/man/properties.Rd	2009-01-14 09:26:54 UTC (rev 135)
@@ -15,6 +15,8 @@
 \alias{ymin}
 \alias{ymax}
 \alias{projection}
+\alias{isLatLon}
+\alias{isLatLon,Raster-method}
 \alias{projection<-}
 \alias{origin}
 \alias{nlayers}
@@ -42,6 +44,7 @@
 ymin(object)
 ymax(object)
 projection(object, asText=TRUE)
+isLatLon(object)
 origin(object)
 nlayers(object)
 layers(object)



More information about the Raster-commits mailing list