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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 11 04:33:30 CET 2009


Author: rhijmans
Date: 2009-02-11 04:33:30 +0100 (Wed, 11 Feb 2009)
New Revision: 271

Added:
   pkg/raster/man/cellsFromBbox.Rd
   pkg/raster/man/draw.Rd
Modified:
   pkg/raster/DESCRIPTION
   pkg/raster/R/drawPoly.R
   pkg/raster/man/bbox.Rd
   pkg/raster/man/click.Rd
Log:


Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-02-10 16:28:58 UTC (rev 270)
+++ pkg/raster/DESCRIPTION	2009-02-11 03:33:30 UTC (rev 271)
@@ -1,8 +1,8 @@
 Package: raster
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
-Version: 0.8.8-2
-Date: 9-Feb-2009
+Version: 0.8.8-3
+Date: 11-Feb-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/drawPoly.R
===================================================================
--- pkg/raster/R/drawPoly.R	2009-02-10 16:28:58 UTC (rev 270)
+++ pkg/raster/R/drawPoly.R	2009-02-11 03:33:30 UTC (rev 271)
@@ -7,25 +7,38 @@
 # Licence GPL v3
 
 
-drawPoly <- function(col='red') {
+drawPoly <- function(sp=TRUE, col='red') {
 	xy <- locator(n=10000, type="l", col=col)
 	xy <- cbind(xy$x, xy$y)
 	xy <- rbind(xy, xy[1,])
 	lines(xy[(length(xy[,1])-1):length(xy[,1]),], col=col)
-	return( SpatialPolygons(list(Polygons(list(Polygon(xy)), 1))) )
+	if (sp) {
+		return( SpatialPolygons(list(Polygons(list(Polygon(xy)), 1))) )
+	} else {
+		return(xy)
+	}
+	
 }
 
 
-drawLine <- function(col='red') {
+drawLine <- function(sp=TRUE, col='red') {
 	xy <- locator(n=10000, type="l", col=col)
 	xy <- cbind(xy$x, xy$y)
-	return( SpatialLines(list(Lines(list(Line(xy)), "1"))) )
+	if (sp) {
+		return( SpatialLines(list(Lines(list(Line(xy)), "1"))) )
+	} else {
+		return(xy)
+	}
 }
 
 
-polygonFromBbox <- function(bndbox) {
+polygonFromBbox <- function(bndbox, sp=TRUE) {
 	bb <- getBbox(bndbox)
 	p <- rbind(c(bb at xmin, bb at ymin), c(bb at xmin, bb at ymax), c(bb at xmax, bb at ymax), c(bb at xmax, bb at ymin), c(bb at xmin, bb at ymin) )
-	return( SpatialPolygons(list(Polygons(list(Polygon(p)), 1))) )
+	if (sp) {
+		return( SpatialPolygons(list(Polygons(list(Polygon(p)), 1))) )
+	} else {
+		return(p)
+	}
 }
 

Modified: pkg/raster/man/bbox.Rd
===================================================================
--- pkg/raster/man/bbox.Rd	2009-02-10 16:28:58 UTC (rev 270)
+++ pkg/raster/man/bbox.Rd	2009-02-11 03:33:30 UTC (rev 271)
@@ -1,4 +1,4 @@
-\name{box}
+\name{BoundingBox}
 \alias{getBbox}
 \alias{getBbox,BoundingBox-method}
 \alias{getBbox,BasicRaster-method}
@@ -10,8 +10,6 @@
 \alias{newBbox}
 \alias{setBbox}
 \alias{changeBbox}
-\alias{cellsFromBbox}
-\alias{polygonFromBbox}
 
 \alias{xmin<-}
 \alias{xmax<-}
@@ -24,17 +22,13 @@
 newBbox creates a new bounding box (as in the "Spatial" object from the SP package)
 setBbox sets the bounding box of a Raster* object
 changeBbox changes the bounding box of a Raster* object
-polygonFromBbox creates a SpatialPolygon object from a BoundingBox object (or a Raster*) object
-You can also use bbox(object) to get a sp type bbox (a 2 x 2 matrix), but such an object cannot be used with the other functon described here as it returns a matrix, and not a BoundingBox object.
 }
 
 \usage{
-getBbox(object)
 newBbox(xmn, xmx, ymn, ymx)
+getBbox(object)
 setBbox(object, bndbox, keepres=FALSE, snap=FALSE)
 changeBbox(object, xmn=xmin(object), xmx=xmax(object), ymn=ymin(object), ymx = ymax(object), keepres=FALSE) 
-cellsFromBbox(object, bndbox)
-polygonFromBbox(bndbox)
 }
 
 \arguments{
@@ -47,6 +41,10 @@
   \item{keepres}{logical. If \code{TRUE}, the resolution of the cells will stay the same after adjusting the bounding box (by adjusting the number of rows and columns). if \code{FALSE}, the number of rows and columns will stay the same, and the resolution will be adjusted}
   \item{snap}{Adjust the bounding box so that the new raster is aligned with the old raster }
 }
+ 
+\value{
+in most cases a BoundingBox object
+}
   
 \author{Robert J. Hijmans}
 

Added: pkg/raster/man/cellsFromBbox.Rd
===================================================================
--- pkg/raster/man/cellsFromBbox.Rd	                        (rev 0)
+++ pkg/raster/man/cellsFromBbox.Rd	2009-02-11 03:33:30 UTC (rev 271)
@@ -0,0 +1,41 @@
+\name{box}
+\alias{cellsFromBbox}
+\alias{polygonFromBbox}
+
+
+\title{Additional BoundingBox functions}
+\description{
+cellsFromBbox returns the cellnumbers or a RasterLayer within a BoundingBox (rectangular area).
+polygonFromBbox creates a SpatialPolygon object from a BoundingBox object (or a Raster*) object
+You can also use bbox(object) to get a sp type bbox (a 2 x 2 matrix), but such an object cannot be used with the other functon described here as it returns a matrix, and not a BoundingBox object.
+}
+
+\usage{
+cellsFromBbox(object, bndbox)
+polygonFromBbox(bndbox, sp=TRUE)
+}
+
+\arguments{
+  \item{object}{A Raster* object}
+  \item{bndbox}{An object of class BoundingBox (which you can create with newBbox() )}  
+  \item{sp}{logical. If \code{TRUE}, the output will be a SpatialPolygons object (sp package). Otherwise a matrix of coordinates is returned}    
+}
+
+\value{
+in most cases a BoundingBox object
+}  
+  
+\author{Robert J. Hijmans}
+
+\seealso{ \code{\link[raster]{newBbox}} }
+
+\examples{
+r <- raster()
+bb <- newBbox(-10, 10, -20, 20)
+cells <- cellsFromBbox(r, bb)
+pol <- polygonFromBbox(bb)
+}
+
+\keyword{spatial}
+
+

Modified: pkg/raster/man/click.Rd
===================================================================
--- pkg/raster/man/click.Rd	2009-02-10 16:28:58 UTC (rev 270)
+++ pkg/raster/man/click.Rd	2009-02-11 03:33:30 UTC (rev 271)
@@ -21,6 +21,10 @@
   \item{col}{the color of the bounding box lines}    
  }
  
+\value{
+click: the value of \code{object} at the point clicked on; and the coordinates if \code{xy==TRUE}.
+clickBbox: a BoundingBox object
+} 
 
 \author{ Robert J. Hijmans }
 

Added: pkg/raster/man/draw.Rd
===================================================================
--- pkg/raster/man/draw.Rd	                        (rev 0)
+++ pkg/raster/man/draw.Rd	2009-02-11 03:33:30 UTC (rev 271)
@@ -0,0 +1,27 @@
+\name{draw}
+\alias{drawPoly}
+\alias{drawLine}
+
+\title{ Draw a line or polygon on a map }
+\description{
+  Draw a line or polygon on a map and save it for later use
+}
+\usage{
+drawPoly(sp=TRUE, col='red')
+drawLine(sp=TRUE, col='red')
+}
+
+\arguments{
+  \item{sp}{logical. If \code{TRUE}, the output will be a sp object (SpatialPolygons or SpatialLines). Otherwise a matrix of coordinates is returned}  
+  \item{col}{the color of the lines to be drawn}    
+ }
+ 
+\value{
+If \code{sp==TRUE} a sp object (SpatialPolygons or SpatialLines)
+otherwise a matrix of coordinates
+}
+ 
+\author{ Robert J. Hijmans }
+
+
+\keyword{ spatial }



More information about the Raster-commits mailing list