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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 25 14:42:06 CET 2009


Author: rhijmans
Date: 2009-02-25 14:42:06 +0100 (Wed, 25 Feb 2009)
New Revision: 300

Modified:
   pkg/raster/R/raster.create.R
   pkg/raster/R/set.R
   pkg/raster/man/raster.Rd
   pkg/raster/man/set.Rd
Log:


Modified: pkg/raster/R/raster.create.R
===================================================================
--- pkg/raster/R/raster.create.R	2009-02-25 09:10:48 UTC (rev 299)
+++ pkg/raster/R/raster.create.R	2009-02-25 13:42:06 UTC (rev 300)
@@ -37,16 +37,13 @@
 
 #setMethod('values', signature(object='Raster'), 
 
-rasterFromBbox <- function(bndbox, nrows=10, ncols=10, nudge=TRUE) {
+
+
+rasterFromBbox <- function(bndbox, nrows=10, ncols=10) {
 	crs <- newCRS('NA')
 	try(crs <- projection(bndbox, asText=F), silent = T)
 	bb <- getBbox(bndbox)
-	if (nudge) {
-		bb at xmin <- floor(bb at xmin)
-		bb at ymin <- floor(bb at ymin)
-		bb at xmax <- ceiling(bb at xmax)
-		bb at ymax <- ceiling(bb at ymax)
-	}
+
 	nr = as.integer(round(nrows))
 	nc = as.integer(round(ncols))
 	if (nc < 1) { stop("ncols should be > 0") }

Modified: pkg/raster/R/set.R
===================================================================
--- pkg/raster/R/set.R	2009-02-25 09:10:48 UTC (rev 299)
+++ pkg/raster/R/set.R	2009-02-25 13:42:06 UTC (rev 300)
@@ -31,7 +31,7 @@
 	return(object)
 }
 
-setRaster <- function(object, filename="", values=NA) {
+setRaster <- function(object, filename="", values=NULL) {
 
 	if (class(object) == 'RasterStack') { object <- asRasterLayer(object, 1) }
 	if (class(object) != 'RasterLayer') { stop('the first argument should be a RasterLayer or a RasterStack object') }
@@ -44,7 +44,7 @@
 	r <- raster(xmn = xmin(object), xmx = xmax(object), ymn = ymin(object), ymx = ymax(object), nrows=nrow(object), ncols=ncol(object), projstring=projection(object))
 	r <- setFilename(r, filename)
 	
-	if ( length(values) != 1 | ( length(values) == 1 & ncell(r) == 1) ) {
+	if (!is.null(values)) {
 		r <- setValues(r, values)
 	}
 	return(r)
@@ -97,6 +97,14 @@
 	return(object)
 }
 
+nudgeCoords <- function(bb){
+	bb <- getBbox(bb)
+	bb at xmin <- floor(bb at xmin)
+	bb at ymin <- floor(bb at ymin)
+	bb at xmax <- ceiling(bb at xmax)
+	bb at ymax <- ceiling(bb at ymax)
+	return(bb)
+}
 
 	
 setMinMax <- function(raster, readfromdisk=FALSE) {

Modified: pkg/raster/man/raster.Rd
===================================================================
--- pkg/raster/man/raster.Rd	2009-02-25 09:10:48 UTC (rev 299)
+++ pkg/raster/man/raster.Rd	2009-02-25 13:42:06 UTC (rev 300)
@@ -10,7 +10,7 @@
 
 \usage{
 raster(xmn = -180, xmx = 180, ymn = -90, ymx = 90, nrows = 180, ncols = 360, projstring = "+proj=longlat +datum=WGS84")
-rasterFromBbox(bndbox, nrows = 10, ncols = 10, nudge=TRUE)
+rasterFromBbox(bndbox, nrows = 10, ncols = 10)
 }
 
 \arguments{
@@ -20,7 +20,6 @@
   \item{ymx}{maximum y coordinate of raster (top border) }
   \item{nrows}{number of rows on raster }
   \item{ncols}{number of columns on raster }
-  \item{nudge}{logical. If \code{TRUE}, the boundingbox is nudged outwards (to the next integer) }
   \item{projstring}{PROJ4 type description of a map projection}
   \item{bndbox}{bounding box used to crop a raster. Any object that is a BoundingBox object or contains one (such as Raster* objects)}
 }

Modified: pkg/raster/man/set.Rd
===================================================================
--- pkg/raster/man/set.Rd	2009-02-25 09:10:48 UTC (rev 299)
+++ pkg/raster/man/set.Rd	2009-02-25 13:42:06 UTC (rev 300)
@@ -19,7 +19,7 @@
 \usage{
 setProjection(object, projstring)
 setFilename(object, filename)
-setRaster(object, filename="", values=NA)
+setRaster(object, filename="", values=NULL)
 setRowCol(raster, nrows=nrow(raster), ncols=ncol(raster)) 
 setRes(object, xres, yres=xres)
 setMinMax(raster, readfromdisk=FALSE)
@@ -29,7 +29,7 @@
 \arguments{
   \item{object}{A Raster* object }
   \item{raster}{ A \code{RasterLayer} object }
-  \item{values}{ Data values to associate with the RasterLayer object}
+  \item{values}{ Data values to associate with the RasterLayer object }
   \item{filename}{ filename, can be blank }
   \item{nrows}{ the new number of rows for the raster }
   \item{ncols}{ the new number of cols for the raster }  



More information about the Raster-commits mailing list