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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 11 17:03:37 CET 2009


Author: rhijmans
Date: 2009-01-11 17:03:37 +0100 (Sun, 11 Jan 2009)
New Revision: 116

Added:
   pkg/raster/man/compare.Rd
Modified:
   pkg/raster/R/set.R
   pkg/raster/R/standard.generic.functions.R
   pkg/raster/man/classes.Rd
   pkg/raster/man/generic.read.Rd
   pkg/raster/man/set.Rd
   pkg/raster/man/utils.Rd
Log:


Modified: pkg/raster/R/set.R
===================================================================
--- pkg/raster/R/set.R	2009-01-11 15:33:21 UTC (rev 115)
+++ pkg/raster/R/set.R	2009-01-11 16:03:37 UTC (rev 116)
@@ -83,10 +83,15 @@
 
 roundCoords <- function(object, digits=0) {
 	digits <- max(0, digits)
-	object at bbox@xmin <- round(object at bbox@xmin, digits)
-	object at bbox@xmax <- round(object at bbox@xmax, digits)
-	object at bbox@ymin <- round(object at bbox@ymin, digits)
-	object at bbox@ymax <- round(object at bbox@ymax, digits)
+	b <- getBbox(object)
+	b at xmin <- round(b at xmin, digits)
+	b at xmax <- round(b at xmax, digits)
+	b at ymin <- round(b at ymin, digits)
+	b at ymax <- round(b at ymax, digits)
+	if (class(object) == 'BoundingBox') {
+		return(b)
+	}
+	object <- setBbox(object, b)
 	return(object)
 }
 

Modified: pkg/raster/R/standard.generic.functions.R
===================================================================
--- pkg/raster/R/standard.generic.functions.R	2009-01-11 15:33:21 UTC (rev 115)
+++ pkg/raster/R/standard.generic.functions.R	2009-01-11 16:03:37 UTC (rev 116)
@@ -5,7 +5,17 @@
 # Licence GPL v3
 
 
+setMethod ('show' , 'BoundingBox', 
+	function(object) {
+		cat('class       :' , class(object), '\n')
+		cat('xmin        :' , xmin(object), '\n')
+		cat('xmax        :' , xmax(object), '\n')
+		cat('ymin        :' , ymin(object), '\n')
+		cat('ymax        :' , ymax(object), '\n')
+	}
+)	
 	
+	
 setMethod ('show' , 'RasterLayer', 
 	function(object) {
 		cat('class       :' , class(object), '\n')

Modified: pkg/raster/man/classes.Rd
===================================================================
--- pkg/raster/man/classes.Rd	2009-01-11 15:33:21 UTC (rev 115)
+++ pkg/raster/man/classes.Rd	2009-01-11 16:03:37 UTC (rev 116)
@@ -5,7 +5,7 @@
 \alias{RasterLayer-class}
 \alias{RasterStack-class}
 \alias{RasterBrick-class}
-
+\alias{show,BoundingBox-method}
 \alias{show,RasterLayer-method}
 \alias{show,RasterStack-method}
 \alias{show,RasterBrick-method}

Added: pkg/raster/man/compare.Rd
===================================================================
--- pkg/raster/man/compare.Rd	                        (rev 0)
+++ pkg/raster/man/compare.Rd	2009-01-11 16:03:37 UTC (rev 116)
@@ -0,0 +1,37 @@
+\name{utilities}
+\alias{compare}
+
+  
+\title{ Compare rasters }
+\description{
+  compare evaluates whether a list of rasters has the same origin, resolution, number of rows and columns, and projection (or a subset thereof).
+}
+
+\usage{
+compare(objects, bb=TRUE, rowcol=TRUE, prj=TRUE, res=FALSE, orig=FALSE, tolerance=0.05, stopiffalse=TRUE, showwarning=FALSE) 
+}
+
+\arguments{
+  \item{objects}{vector or list of Raster* objects }
+  \item{bb}{logical. If \code{TRUE}, bounding boxes are compared}
+  \item{rowcol}{logical. If \code{TRUE}, number of rows and columns of the objects are compared}
+  \item{prj}{logical. If \code{TRUE} projections are compared.}
+  \item{res}{logical. If \code{TRUE}, resolutions are compared}
+  \item{orig}{logical. If \code{TRUE}, origins are compared}
+  \item{tolerance}{difference permissable (relative to the cell resolution) for objects to be 'equal', for non integer numbers in origin and resolution. See ?all.equal }
+  \item{stopiffalse}{logical. If \code{TRUE}, an error will occur if the objects are not the same}
+  \item{showwarning}{logical. If \code{TRUE}, an warning will be given if objects are not the same. Only relevant when \code{stopiffalse} is \code{TRUE}}
+ }
+  
+\author{Robert J. Hijmans  \email{r.hijmans at gmail.com}}
+\examples{
+	r1 <- newRaster()
+	r2 <- r1
+	compare(c(r1, r2))
+	r3 <- setRowCol(r1, 10)
+#	compare(c(r1, r3))
+	compare(c(r1, r3), stopiffalse=FALSE)
+	compare(c(r1, r3), rowcol=FALSE)
+}
+\keyword{ spatial }
+

Modified: pkg/raster/man/generic.read.Rd
===================================================================
--- pkg/raster/man/generic.read.Rd	2009-01-11 15:33:21 UTC (rev 115)
+++ pkg/raster/man/generic.read.Rd	2009-01-11 16:03:37 UTC (rev 116)
@@ -61,7 +61,6 @@
 
 \note{ After read* the values are accessible with the "values(object)" function }
 
-\references{ ~put references to the literature/web site here ~ }
 \author{Robert J. Hijmans \email{r.hijmans at gmail.com}}
 
 \examples{

Modified: pkg/raster/man/set.Rd
===================================================================
--- pkg/raster/man/set.Rd	2009-01-11 15:33:21 UTC (rev 115)
+++ pkg/raster/man/set.Rd	2009-01-11 16:03:37 UTC (rev 116)
@@ -34,7 +34,7 @@
 }
 
 \arguments{
-  \item{object} {A Raster* object }
+  \item{object}{A Raster* object }
   \item{raster}{ A \code{RasterLayer} object }
   \item{filename}{ filename, can be blank }
   \item{datatype}{ the type of data ('numeric' or 'integer' that will be written to disk }

Modified: pkg/raster/man/utils.Rd
===================================================================
--- pkg/raster/man/utils.Rd	2009-01-11 15:33:21 UTC (rev 115)
+++ pkg/raster/man/utils.Rd	2009-01-11 16:03:37 UTC (rev 116)
@@ -1,32 +1,20 @@
 \name{utilities}
-\alias{compare}
 \alias{roundCoords}
 \alias{newCRS}
 
   
-\title{ Compare rasters }
+\title{ Utility functions }
 \description{
-  compare evaluates whether a list of rasters has the same origin, resolution, number of rows and columns, and projection (or a subset thereof).
   roundCoords rounds the coordinates to a number of digits specified. 
   newCRS is a helper function to create a CRS map projection object.
 }
 
 \usage{
-compare(objects, bb=TRUE, rowcol=TRUE, prj=TRUE, res=FALSE, orig=FALSE, tolerance=0.05, stopiffalse=TRUE, showwarning=FALSE) 
 roundCoords(object, digits=0)
 newCRS(projstring)
 }
 
 \arguments{
-  \item{objects} { vector or list of Raster* objects }
-  \item{bb} { logical. If \code{TRUE}, bounding boxes are compared}
-  \item{rowcol}{logical. If \code{TRUE}, number of rows and columns of the objects are compared}
-  \item{prj}{ logical. If \code{TRUE} projections are compared.}
-  \item{res} { logical. If \code{TRUE}, resolutions are compared}
-  \item{orig} { logical. If \code{TRUE}, origins are compared}
-  \item{tolerance} { difference permissable (relative to the cell resolution) for objects to be 'equal', for non integer numbers in origin and resolution. See ?all.equal }
-  \item{stopiffalse}{logical. If \code{TRUE}, an error will occur if the objects are not the same}
-  \item{showwarning}{logical. If \code{TRUE}, an warning will be given if objects are not the same. Only relevant when \code{stopiffalse} is \code{TRUE}}
   \item{object} { a Raster* object }
   \item{digits} { integer indicating the precision to be used} 
   \item{projstring}{ a PROJ4 type character string describing projection and datum}
@@ -35,13 +23,8 @@
 \author{Robert J. Hijmans  \email{r.hijmans at gmail.com}}
 \examples{
 	crsproj <- newCRS("+proj=longlat +datum=WGS84")
-	r1 <- newRaster()
-	r2 <- r1
-	compare(c(r1, r2))
-	r3 <- setRowCol(r1, 10)
-#	compare(c(r1, r3))
-	compare(c(r1, r3), stopiffalse=FALSE)
-	compare(c(r1, r3), rowcol=FALSE)
+	bb <- newBbox(-179.999999,  180.000011, -60, 60)
+	bb <- roundCoords(bb, 5)
 }
 \keyword{ spatial }
 



More information about the Raster-commits mailing list