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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 2 11:15:48 CEST 2009


Author: rhijmans
Date: 2009-04-02 11:15:48 +0200 (Thu, 02 Apr 2009)
New Revision: 386

Modified:
   pkg/raster/R/stack.R
   pkg/raster/R/stackAdd.R
   pkg/raster/man/Arith-methods.Rd
   pkg/raster/man/Compare-methods.Rd
   pkg/raster/man/Logic-methods.Rd
   pkg/raster/man/RasterLayer-class.Rd
   pkg/raster/man/aggregate.Rd
   pkg/raster/man/changeStack.Rd
   pkg/raster/man/coerce.Rd
   pkg/raster/man/dimensions.Rd
   pkg/raster/man/extent.Rd
   pkg/raster/man/getBbox.Rd
   pkg/raster/man/newBbox.Rd
Log:


Modified: pkg/raster/R/stack.R
===================================================================
--- pkg/raster/R/stack.R	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/R/stack.R	2009-04-02 09:15:48 UTC (rev 386)
@@ -61,7 +61,7 @@
 			stop("Arguments should be Raster* objects or filenames")
 		}	
 	}
-	return(addRasters(new("RasterStack"), r))
+	return(addLayer(new("RasterStack"), r))
 } )
 
 

Modified: pkg/raster/R/stackAdd.R
===================================================================
--- pkg/raster/R/stackAdd.R	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/R/stackAdd.R	2009-04-02 09:15:48 UTC (rev 386)
@@ -25,13 +25,13 @@
 			rasters <- c(rasters, raster(rasterfiles[[i]], FALSE, band=bands[[i]]))
 		}
 	}	
-	rstack <- addRasters(rstack, rasters) 
+	rstack <- addLayer(rstack, rasters) 
 	return(rstack)
 }
 
 
 
-addRasters <- function(rstack, rasters) {
+addLayer <- function(rstack, rasters) {
 #rasters is a list of raster objects
 	if (class(rstack) != "RasterStack") { 
 		stop("rstack should be a RasterStack object") 

Modified: pkg/raster/man/Arith-methods.Rd
===================================================================
--- pkg/raster/man/Arith-methods.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/Arith-methods.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -7,18 +7,19 @@
 \alias{Arith,RasterLayer,numeric-method}
 \alias{Arith,RasterLayer,RasterLayer-method}
 
-\title{arithmic functions}
+\title{Arithmic}
 
 \description{
-  Standard arithmic functions, \code{"+", "-", "*", "/", "^", "\%\%", "\%/\%"}, for computations with RasterLayer objects and numeric values.
-  Functions are applied on a cell by cell basis (single numeric values are recycled). 
+  Standard arithmic operators for computations with RasterLayer objects and numeric values. The following operators are available:
+  \code{ +, -, *, /, ^, \%\%, \%/\% }
+  Operators are applied on a cell by cell basis, and single numeric values are recycled. 
   Input RasterLayers must have the same extent and resolution.
 }
 
 \section{Note}{
+ These are convenient operators/functions that are most usful for relatively small RasterLayers for which all the values can be held in memory. 
  If the values of the output RasterLayer cannot be held in memory, they will be saved to a temporary file. 
- If you want to set the filename (and perhaps filetype and datatype), use \code{\link[raster]{overlay}} 
- or \code{\link[raster]{calc}} instead of the Arith-methods.
+ In that case it could be more efficient to use use \code{\link[raster]{calc}} instead.
 }
 
 \seealso{ \code{\link[raster]{Math-methods}}, \code{\link[raster]{overlay}}, \code{\link[raster]{calc}} }

Modified: pkg/raster/man/Compare-methods.Rd
===================================================================
--- pkg/raster/man/Compare-methods.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/Compare-methods.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -1,15 +1,22 @@
 \name{Compare-methods}
+
 \docType{methods}
+
 \alias{Compare-methods}
 \alias{==,BasicRaster,BasicRaster-method}
 \alias{!=,BasicRaster,BasicRaster-method}
 
-\title{ Methods to compare Raster* objects}
+\title{Compare Raster* objects}
 \description{
  These methods compare the location and resolution of Raster* objects. That is, they compare their bounding boxes, projection, and rows and columns. 
- For BasicRaster objects you can use "==" and "!=", the values returned is a single logical value \code{TRUE} or \code{FALSE}
- For RasterLayer objects, they also compare the values associated with the objects, and the result is a logical (Boolean) RasterLayer object.
- The following methods have been implemented for RasterLayer objects: "==", "!=", ">", "<",  "<=", ">="
+ For BasicRaster objects you can use \code{==} and \code{!=}, the values returned is a single logical value \code{TRUE} or \code{FALSE}
+ 
+ For RasterLayer objects, they also compare the values associated with the objects, and the result is a logical (Boolean) RasterLayer object. And the 
+ value returned is a RasterLayer object, if the location and resolution match, or an error of they do not match.
+ 
+ The following methods have been implemented for RasterLayer objects:
+ 
+ \code{==, !=, >, <,  <=, >=}
 }
 
 \author{Robert J. Hijmans }
@@ -19,12 +26,12 @@
 r1 <- raster()
 r1 <- setValues(r1, round(10 * runif(ncell(r1))))
 r2 <- setValues(r1, round(10 * runif(ncell(r1))))
-as(r1, "BasicRaster") == as(r2, "BasicRaster")
+as(r1, 'BasicRaster') == as(r2, 'BasicRaster')
 r3 <- r1 == r2
 
 b <- newBbox(0, 360, 0, 180)
 r4 <- setExtent(r2, b)
-as(r2, "BasicRaster") != as(r4, "BasicRaster")
+as(r2, 'BasicRaster') != as(r4, 'BasicRaster')
 # The following would give an error. You cannot compare RasterLayer object that do not have the same BasicRaster properties.
 #r3 <- r1 > r4
 }

Modified: pkg/raster/man/Logic-methods.Rd
===================================================================
--- pkg/raster/man/Logic-methods.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/Logic-methods.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -1,5 +1,7 @@
 \name{Logic-methods}
+
 \docType{methods}
+
 \alias{Logic-methods}
 \alias{Logic,RasterLayer,RasterLayer-method}
 \alias{is.na,RasterLayer-method}
@@ -9,10 +11,15 @@
 \alias{!,RasterLayer-method}
 
 
-\title{ Methods for logical functions for RasterLayers' }
+\title{Logical operators and functions}
 \description{
-The following logical (boolean) operators are available for computations with RasterLayer objects: \code{"&", "|", and "!"}
-These functions are also available with a RasterLayer argument: \code{is.na}, \code{is.nan}, \code{is.finite}, \code{is.infinite}
+The following logical (boolean) operators are available for computations with RasterLayer objects: 
+
+\code{&, |, and !}
+
+These functions are also available with a RasterLayer argument: 
+
+\code{is.na}, \code{is.nan}, \code{is.finite}, \code{is.infinite}
 }
 
 \value{
@@ -21,8 +28,9 @@
 
 
 \section{Note}{
+ These are convenient operators/functions that are most usful for relatively small RasterLayers for which all the values can be held in memory. 
  If the values of the output RasterLayer cannot be held in memory, they will be saved to a temporary file. 
- If you want to set the filename (and perhaps filetype and datatype), use \code{\link[raster]{calc-methods}} instead.
+ In that case it could be more efficient to use use \code{\link[raster]{calc}} instead.
 }
 
 \seealso{ \code{\link[raster]{Math-methods}}, \code{\link[raster]{overlay}}, \code{\link[raster]{calc}} }
@@ -39,6 +47,10 @@
 r4 <- r2 == r3
 r[r>3] <- NA
 r5 <- is.na(r)
+r[1:5]
+r1[1:5]
+r2[1:5]
+r3[1:5]
 
 }
 

Modified: pkg/raster/man/RasterLayer-class.Rd
===================================================================
--- pkg/raster/man/RasterLayer-class.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/RasterLayer-class.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -17,31 +17,33 @@
 
 \description{ \code{RasterLayer} and \code{RasterStack} (Raster* in short) are classes for handling spatial raster (grid) data.
 
- RasterLayer represents a single layer raster.  RasterStack represents a collection of RasterLayers with the same extent and resolution; for example a multi-band remote sensing image. 
+RasterLayer represents a single layer raster.  RasterStack represents a collection of RasterLayers with the same extent and resolution;
+for example a multi-band remote sensing image. 
  
-A RasterStack is that it typically points to several seperate data files on disk, but it could also point to different bands from a single file (or not not point to any file at all)
+Objects can be created with the following helper functions: \code{\link[raster]{raster} and \link[raster]{stack}}  
  
-Apart from with the normal new(" ") method, objects can be created with the following functions (among others)
-\code{raster(), stack(),  StackFromRasters(), StackFromFiles()}
+RasterLayer and RasterStack objects can also be created from SpatialPixels* and SpatialGrid* objects from the sp package using \code{as}
+or the explicit function \code{\link[raster]{asRasterLayer}}. 
+Vice versa, Raster* objects can be coerced into a sp type oject with \code{as( , )} and with \code{asSpGrid()}. 
  
- RasterLayer and RasterStack objects can also be created from SpatialPixels* and SpatialGrid* objects from the sp package using \code{as}
- or the explicit functions \code{asRasterLayer()} and \code{asRasterStack()}
- Vice versa, Raster* objects can be coerced into a sp type oject with \code{asSpGrid()}. 
+Common generic methods implemented for these classes include: 
  
- generic methods implemented for these classes include: 
  \code{summary}, \code{show}, \code{dim}, \code{hist},
+ 
  \code{plot} (with a single object as argument, and in the case of hist and plot, with additional ... parameters)
- \code{[} is implemented for RasterLayer. It is equivalent to setValues() 
  
+ \code{[} is implemented for RasterLayer. 
+ 
  These classes inherit from the \code{Raster}, which is a virtual class (objects cannot be created from it). However, many of the generic methods
  in this package are implemented for the Raster class so that they can be used with the other three classes.
 
- In case you really want a Raster object, rather than one of its decendants, to work with you can easily create your own class that is the same (but not virtual) with a command like this:
-\code{setClass ('BasicRaster', contains = 'Raster')}
  Raster includes a slot with an object of the \code{BoundingBox} class )
- RasterLayer includes the classes \code{RasterFile} and \code{SingleLayerData}, whereas RasterStack contains \code{RasterFile} and \code{MultipleLayerData}
+
+ RasterLayer includes the classes \code{RasterFile} and \code{SingleLayerData}, 
+ whereas RasterStack contains \code{RasterFile} and \code{MultipleLayerData}
+ 
  These classes are not further described here because users should not need to directly access these slots. 
- The 'setter' functions such as setValues should be used instead. Using such 'set' functions
+ The 'setter' functions such as \code{setValues} should be used instead. Using such 'setter' functions
  is much safe because a change in one slot should often affect the values in other slots. 
  }
 
@@ -49,6 +51,7 @@
 \section{Objects from the Class}{
 Objects can be created by calls of the form \code{new("RasterLayer", ...)}, or with the helper functions such as \code{raster}.
 }
+
 \section{Slots}{
 Slots for RasterLayer and RasterStack objects
 
@@ -60,56 +63,29 @@
     \item{\code{bbox}:}{Object of class \code{"BoundingBox"} }
     \item{\code{ncols}:}{Object of class \code{"integer"} }
     \item{\code{nrows}:}{Object of class \code{"integer"} }
-    \item{\code{crs}:}{Object of class \code{"CRS"} }
+    \item{\code{crs}:}{Object of class \code{"CRS"}, i.e. the coordinate reference system }
   }
 }
 \section{Extends}{
 Classes \code{RasterLayer} and \code{RasterStack} extend class \code{"\linkS4class{Raster}"}, directly.
 Classes \code{RasterLayer} and \code{RasterStack} extend class \code{"\linkS4class{BasicRaster}"}, by class "Raster", distance 2.
 }
+
 \section{Methods}{
   \describe{
-    \item{!}{\code{signature(x = "RasterLayer")}: ... }
+  
     \item{[}{\code{signature(x = "RasterLayer", i = "ANY", j = "ANY")}: ... }
     \item{[<-}{\code{signature(x = "RasterLayer", i = "ANY", j = "ANY")}: ... }
-    \item{aggregate}{\code{signature(x = "RasterLayer")}: ... }
-    \item{calc}{\code{signature(x = "RasterLayer", fun = "function")}: ... }
-    \item{cellValues}{\code{signature(object = "RasterLayer", cells = "vector")}: ... }
-    \item{is.finite}{\code{signature(x = "RasterLayer")}: ... }
-    \item{is.infinite}{\code{signature(x = "RasterLayer")}: ... }
-    \item{is.na}{\code{signature(x = "RasterLayer")}: ... }
-    \item{is.nan}{\code{signature(x = "RasterLayer")}: ... }
-    \item{merge}{\code{signature(x = "RasterLayer", y = "RasterLayer")}: ... }
-    \item{overlay}{\code{signature(x = "RasterLayer", y = "RasterLayer")}: ... }
     \item{plot}{\code{signature(x = "RasterLayer", y = "RasterLayer")}: ... }
-    \item{readAll}{\code{signature(object = "RasterLayer")}: ... }
-    \item{readBlock}{\code{signature(object = "RasterLayer")}: ... }
-    \item{readPartOfRow}{\code{signature(object = "RasterLayer")}: ... }
-    \item{readRow}{\code{signature(object = "RasterLayer")}: ... }
-    \item{readRows}{\code{signature(object = "RasterLayer")}: ... }
-    \item{setValues}{\code{signature(object = "RasterLayer")}: ... }
     \item{show}{\code{signature(object = "RasterLayer")}: ... }
-    \item{stack}{\code{signature(x = "RasterLayer")}: ... }
     \item{summary}{\code{signature(object = "RasterLayer")}: ... }
-    \item{xyValues}{\code{signature(object = "RasterLayer", xyCoords = "matrix")}: ... }
 	
-	
     \item{asRasterLayer}{\code{signature(object = "RasterStack")}: ... }
-    \item{calc}{\code{signature(x = "RasterStack", fun = "function")}: ... }
-    \item{calc}{\code{signature(x = "RasterStack", fun = "list")}: ... }
-    \item{cellValues}{\code{signature(object = "RasterStack", cells = "vector")}: ... }
-    \item{nlayers}{\code{signature(object = "RasterStack")}: ... }
-    \item{overlay}{\code{signature(x = "RasterStack", y = "missing")}: ... }
-    \item{readAll}{\code{signature(object = "RasterStack")}: ... }
-    \item{readPartOfRow}{\code{signature(object = "RasterStack")}: ... }
-    \item{readRow}{\code{signature(object = "RasterStack")}: ... }
-    \item{setValues}{\code{signature(object = "RasterStack")}: ... }
     \item{show}{\code{signature(object = "RasterStack")}: ... }
     \item{summary}{\code{signature(object = "RasterStack")}: ... }
-    \item{xyValues}{\code{signature(object = "RasterStack", xyCoords = "matrix")}: ... }
-    \item{xyValues}{\code{signature(object = "RasterStack", xyCoords = "SpatialPoints")}: ... }
 	
-	 }
+	And many other methods (see the other entries in this help file)
+	}
 }
 
 \author{ Robert J. Hijmans }

Modified: pkg/raster/man/aggregate.Rd
===================================================================
--- pkg/raster/man/aggregate.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/aggregate.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -10,7 +10,7 @@
 \description{
 Aggregate a RasterLayer to create a new RasterLayer with a lower resolution (larger cells). 
 Aggregation groups rectangular areas of RasterLayer cells to create a new RasterLayer with larger cells. 
-A new value is computed for the resulting cells according to a user specified function (default value = \code{mean}). 
+A new value is computed for the resulting cells according to a specified function (default value = \code{mean}). 
 }
 
 \usage{
@@ -52,13 +52,14 @@
  If two numbers are supplied, e.g., \code{fact=c(2,3)}, the first will be used for aggregating in the horizontal direction, 
  and the second for aggregating in the vertical direction, and the new RasterLayer will have \code{2*3=6} times fewer cells.  
  
- If the input RasterLayer has 100 columns, and \code{fact=12}, the output RasterLayer will have either 8 columns (\code{expand=FALSE}) or 
- 9 columns (\code{expand=TRUE}). The maximum x coordinate of the output RasterLayer will, of course, also be affected.
+ Aggregation starts at the upper-left end of a raster. If a division of the number of columns or rows with \code{factor} does not 
+ return an integer, the extent of the resulting RasterLayer will either be somewhat smaller or somewhat larger then the original RasterLayer.
+ For example, the input RasterLayer has 100 columns, and \code{fact=12}, the output RasterLayer will have either 8 columns (\code{expand=FALSE}) 
+ (using \code{8 x 12 = 96} of the original columns) or 9 columns (\code{expand=TRUE}). The maximum x coordinate of the output RasterLayer will, 
+ of course, also be adjusted.
+  
+ The function \code{fun} should take multiple numbers, and return a single number. For example \code{mean}, \code{modal}, \code{min} or \code{max}. 
  
- Aggregation starts at the upper-left end of a raster.
- 
- The function \code{fun} should take multiple numbers, and return a single number. For example \code{mean}, \code{min} or \code{max}. 
- 
  If no filename is specified, and the resulting RasterLayer is too large to hold in memory, it is saved to a temporary file.  
 }
 

Modified: pkg/raster/man/changeStack.Rd
===================================================================
--- pkg/raster/man/changeStack.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/changeStack.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -3,27 +3,27 @@
 \alias{stackFromFiles}
 
 \alias{addFiles}
-\alias{addRasters}
+\alias{addLayer}
 \alias{dropLayer}
 
-\title{ Change a RasterStack }
+\title{Change a RasterStack}
 
 \description{
-  A RasterStack is a collection of rasters with the same spatial extent and resolution. 
-  With these functions, you can add raster to or remove raster from a rasterstack. 
+  A RasterStack is a collection of RasterLayers with the same spatial extent and resolution. 
+  With these functions, you can add a RasterLayer to, or remove a RasterLayer from, a RasterStack object. 
 }
 
 \usage{
 addFiles(rstack, rasterfiles, bands= rep(1, length(rasterfiles))) 
-addRasters(rstack, rasters) 
+addLayer(rstack, rasters) 
 dropLayer(rstack, indices) 
 }
 
 \arguments{
+  \item{rstack}{ a RasterStack object }
   \item{rasterfiles}{ Filename(s) of (a) raster dataset(s) }
+  \item{bands}{ a vector or list of bands of raster data files (default values = 1)}
   \item{rasters}{ a list of RasterLayer objects }
-  \item{bands}{ a vector or list of bands of raster data files (default values = 1)}
-  \item{rstack}{ a RasterStack object }
   \item{indices}{ a vector of the indices of the raster(s) to remove from a RasterStack }  
 }
 
@@ -42,9 +42,10 @@
 # this generates warnings, but it is not an error
   st <- addFiles(st, c(rasterfile, rasterfile))
   rs <- raster(rasterfile)
-  st <- addRasters(st, c(rs, rs))
+  st <- addLayer(st, c(rs, rs))
   st
   st <- dropLayer(st, c(3, 5))
   nlayers(st)
 }
+
 \keyword{ spatial }

Modified: pkg/raster/man/coerce.Rd
===================================================================
--- pkg/raster/man/coerce.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/coerce.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -5,7 +5,7 @@
 \alias{asRasterLayer,SpatialGridDataFrame-method}
 \alias{asRasterLayer}
 
-\title{ Coercion to RasterLayer }
+\title{Coercion}
 
 \description{  
 Functions to coerce a SpatialGridDataFrame, SpatialPixelsDataFrame, and RasterStack objects to a RasterLayer object. 

Modified: pkg/raster/man/dimensions.Rd
===================================================================
--- pkg/raster/man/dimensions.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/dimensions.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -4,6 +4,7 @@
 \alias{nrow}
 \alias{nrow,BasicRaster-method}
 \alias{ncol,BasicRaster-method}
+\alias{dim}
 \alias{dim,BasicRaster-method}
 \alias{ncell}
 \alias{ncell,ANY-method}
@@ -29,6 +30,7 @@
 \usage{
 ncol(x)
 nrow(x)
+dim(x)
 ncell(x)
 xres(object)
 yres(object)

Modified: pkg/raster/man/extent.Rd
===================================================================
--- pkg/raster/man/extent.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/extent.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -1,4 +1,4 @@
-\name{extentMinMax}
+\name{coordinates}
 
 \alias{xmin}
 \alias{xmax}
@@ -7,9 +7,13 @@
 \alias{origin}
 
   
-\title{Raster extent}
+\title{coordinates}
+
 \description{
-Extent and projection of Raster* objects
+These functions return the extreme coordinates of a Raster* object. 
+
+Origin returns the coordinates of the point of origin of a Raster* object. This is the point closest to (0, 0) 
+that you could get if you moved towards that point in steps of the x and y resolution.
 }
 
 \usage{
@@ -29,17 +33,20 @@
 }
 
 \value{
-  varies
+  a single number or (for \code{origin}, a vector of two numbers.
 }
 
 \author{Robert J. Hijmans }
 
 \examples{
-r <- raster()
+
+r <- raster(xmn=-0.5, xmx = 9.5, ncols=10)
 xmin(r)
 xmax(r)
 ymin(r)
 ymax(r)
+origin(r)
+
 }
 
 \keyword{spatial}

Modified: pkg/raster/man/getBbox.Rd
===================================================================
--- pkg/raster/man/getBbox.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/getBbox.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -9,10 +9,12 @@
 \alias{bbox,Raster-method}
 
   
-\title{Get a BoundingBox}
+\title{Extent}
+
 \description{
-extent returns the extent, as a BoundingBox object, for a Raster* or Spatial* object (or from a BoundingBox object). 
+This function returns the extent, as a BoundingBox object, of a Raster* or Spatial* object (or a BoundingBox object). 
 It will also create a BoundingBox object from a matrix (2x2; rows=minx, maxx; cols=miny, maxy) or vector (length=4; order= xmin, xmax, ymin, ymax)
+
 \code{bbox(x)} returns a SP type bbox object (a matrix)
 }
 
@@ -40,8 +42,6 @@
 newBbox(0, 20, 0, 20)
 
 extent(matrix(c(0, 0, 20, 20), nrow=2))
-
-
 }
 
 \keyword{spatial}

Modified: pkg/raster/man/newBbox.Rd
===================================================================
--- pkg/raster/man/newBbox.Rd	2009-03-29 04:05:01 UTC (rev 385)
+++ pkg/raster/man/newBbox.Rd	2009-04-02 09:15:48 UTC (rev 386)
@@ -8,8 +8,8 @@
 \description{
 
 newBbox creates a new BoundingBox object
+
 alignBbox aligns a bounding box with the cells of a Raster* object
-
 }
 
 \usage{
@@ -38,6 +38,10 @@
 r <- raster()
 bb <- newBbox(-10.1, 10.1, -20.1, 20.1)
 bba <- alignBbox(bb, r)
+bb
+extent(r)
+bba
+
 }
 
 \keyword{spatial}



More information about the Raster-commits mailing list