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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 19 18:46:56 CET 2009


Author: rhijmans
Date: 2009-01-19 18:46:56 +0100 (Mon, 19 Jan 2009)
New Revision: 161

Modified:
   pkg/raster/DESCRIPTION
   pkg/raster/R/properties.R
Log:


Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-01-19 17:31:06 UTC (rev 160)
+++ pkg/raster/DESCRIPTION	2009-01-19 17:46:56 UTC (rev 161)
@@ -2,7 +2,7 @@
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
 Version: 0.8.6
-Date: 18-Jan-2009
+Date: 19-Jan-2009
 Depends: methods, sp, rgdal (>= 0.5-33), R (>= 2.8.0)
 Author: Robert J. Hijmans & Jacob van Etten
 Maintainer: Robert J. Hijmans <r.hijmans at gmail.com> 

Modified: pkg/raster/R/properties.R
===================================================================
--- pkg/raster/R/properties.R	2009-01-19 17:31:06 UTC (rev 160)
+++ pkg/raster/R/properties.R	2009-01-19 17:46:56 UTC (rev 161)
@@ -11,14 +11,27 @@
 }	
 
 setMethod('isLatLon', signature(object='Raster'), 
-# from the SP package (slightly adapted)
+# copied from the SP package (slightly adapted)
+#author:
+# ...
 	function(object){
-		return(	!is.projected(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) 
@@ -70,14 +83,25 @@
 	return(c(x, y))
 }
 
-nlayers <- function(object) {
-	if (class(object) == "RasterStack" | class(object) == "RasterBrick") {
-		return(object at data@nlayers)
-	} else {
-		return(1)
-	}	
-}
 
+if (!isGeneric("nlayers")) {
+	setGeneric("nlayers", function(object)
+		standardGeneric("nlayers"))
+}	
+
+setMethod('nlayers', signature(object='Raster'), 
+	function(object){
+		return(1) 
+    }
+)
+
+setMethod('nlayers', signature(object='RasterStackBrick'), 
+	function(object){
+		return(object at data@nlayers) 
+    }
+)
+
+
 layers <- function(object) {
 	if (class(object) == "RasterLayer") {
 		return(filename(object))



More information about the Raster-commits mailing list