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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 7 13:47:17 CET 2009


Author: rhijmans
Date: 2009-03-07 13:47:17 +0100 (Sat, 07 Mar 2009)
New Revision: 322

Modified:
   pkg/raster/R/bilinearValue.R
   pkg/raster/man/Arith-methods.Rd
   pkg/raster/man/writeFormats.Rd
Log:


Modified: pkg/raster/R/bilinearValue.R
===================================================================
--- pkg/raster/R/bilinearValue.R	2009-03-07 09:51:43 UTC (rev 321)
+++ pkg/raster/R/bilinearValue.R	2009-03-07 12:47:17 UTC (rev 322)
@@ -12,8 +12,8 @@
 	cellsXY <- xyFromCell(raster, cells)
 
 	pos <- matrix(-1, ncol=ncol(xy), nrow=nrow(xy))
-	pos[ xy[,1] > cellsXY[,1] ] <- 1
-	pos[ xy[,2] < cellsXY[,2] ] <- 1
+	pos[ xy[,1] > cellsXY[,1], 1 ] <- 1
+	pos[ xy[,2] < cellsXY[,2], 2 ] <- 1
 
 	poscol <- col + pos[,1]
 	poscol[poscol==0] <- 2
@@ -21,13 +21,13 @@
 	posrow <- row + pos[,2]
 	posrow[posrow==0] <- 2
 	posrow[posrow==nrow(raster)+1] <- nrow(raster) - 1
-	
+
 	four <- matrix(ncol=4, nrow=nrow(xy))
 	four[,1] <- cells
 	four[,2] <- cellFromRowCol(raster, posrow, col)
 	four[,3] <- cellFromRowCol(raster, posrow, poscol)
 	four[,4] <- cellFromRowCol(raster, row, poscol)
-		
+
 	#four[is.na(four)] <- rep(four[,1], 4)[is.na(four)]
 	return(four)
 }
@@ -38,7 +38,7 @@
 	if (all(div > 0)) {
 		return( (q11/div)*(x2-x)*(y2-y) + (q21/div)*(x-x1)*(y2-y) + (q12/div)*(x2-x)*(y-y1) + (q22/div)*(x-x1)*(y-y1) )
 	} else {
-		print('it happend')
+		print('oops, it happend')
 		bil <- vector(length=length(div))
 		bil[div>0] <- (q11/div)*(x2-x)*(y2-y) + (q21/div)*(x-x1)*(y2-y) + (q12/div)*(x2-x)*(y-y1) + (q22/div)*(x-x1)*(y-y1) 
 		bil[(x1==x2 && y1==y2)] <- q11
@@ -60,13 +60,15 @@
 function(raster, xyCoords) {
 	four <- .fourCellsFromXY(raster, xyCoords)
 	xy4 <- matrix(xyFromCell(raster, as.vector(four)), ncol=8)
-	x1 <- apply(xy4[,1:4], 1, min)
-	x2 <- apply(xy4[,1:4], 1, max)
-	y1 <- apply(xy4[,5:8], 1, min)
-	y2 <- apply(xy4[,5:8], 1, max)
+	x1 <- apply(xy4[,1:4,drop=FALSE], 1, min)
+	x2 <- apply(xy4[,1:4,drop=FALSE], 1, max)
+	y1 <- apply(xy4[,5:8,drop=FALSE], 1, min)
+	y2 <- apply(xy4[,5:8,drop=FALSE], 1, max)
 	xy4 <- cbind(c(x1, x1, x2, x2), c(y1, y2, y1, y2))
 	cells <- cellFromXY(raster, xy4)
 	v <- matrix(cellValues(raster, cells), ncol=4)
 	return( .bilinear(xyCoords[,1], xyCoords[,2], x1, x2, y1, y2, v[,1], v[,2], v[,3], v[,4]) )
 }
 )
+
+

Modified: pkg/raster/man/Arith-methods.Rd
===================================================================
--- pkg/raster/man/Arith-methods.Rd	2009-03-07 09:51:43 UTC (rev 321)
+++ pkg/raster/man/Arith-methods.Rd	2009-03-07 12:47:17 UTC (rev 322)
@@ -7,7 +7,7 @@
 \alias{Arith,RasterLayer,numeric-method}
 \alias{Arith,RasterLayer,RasterLayer-method}
 
-\title{Methods for arithmic function for RasterLayer objects}
+\title{arithmic functions}
 
 \description{
   Standard arithmic functions, \code{"+", "-", "*", "/", "^", "\%\%", "\%/\%"}, for computations with RasterLayer objects and numeric values.

Modified: pkg/raster/man/writeFormats.Rd
===================================================================
--- pkg/raster/man/writeFormats.Rd	2009-03-07 09:51:43 UTC (rev 321)
+++ pkg/raster/man/writeFormats.Rd	2009-03-07 12:47:17 UTC (rev 322)
@@ -2,10 +2,10 @@
 
 \alias{writeFormats}
 
-\title{List supported file types for writing RasterLayer values to disk}
+\title{File types for writing}
 
 \description{
-xxx
+List supported file types for writing RasterLayer values to disk
 }
 
 \usage{
@@ -37,59 +37,10 @@
 
 \author{Robert J. Hijmans}
 
-\seealso{ \code{\link[rgdal]{readGDAL}} }  
+\seealso{ \code{\link[rgdal]{GDALDriver-class}} }  
 
 \examples{ 
-rs <- rasterFromFile(system.file("external/test.ag", package="sp"))
- 
-#read all data
-rs <- readAll(rs)
-
-# write all to a new binary file
-rs <- setFilename(rs, "binall.grd")
-rs <- writeRaster(rs, overwrite=TRUE)
-
-# write all to a new ERDAS .img file
-rs <- setFilename(rs, "binall.img")
-rs <- writeRaster(rs, filetype="HFA", overwrite=TRUE)
-
- 
-# write all to integer binary file
-rs <- setFilename(rs, "binallint.grd")
-rs <- setDatatype(rs, "INT4S")
-rs <- writeRaster(rs, overwrite=TRUE)
- 
-# write all to ascii file
-rs <- setFilename(rs, "ascall.asc")
-rs <- writeRaster(rs, filetype='ascii', overwrite=TRUE)
- 
-# read and write row by row; write to ascii file
-rs <- rasterFromFile(system.file("external/test.ag", package="sp"))
-ascras <- setRaster(rs, filename="ascrow.asc")
-for (r in 1:nrow(rs)) {
-	rs <- readRow(rs, r)
-	v <- values(rs) * 10
-	ascras <- setValues(ascras, v, r)
-	ascras <- writeRaster(ascras, filetype='ascii', overwrite=TRUE) 
+writeFormats() 
 }
-	
-# read and write row by row; write to binary file
-binras <- setRaster(rs, "binbyrow")
-for (r in 1:nrow(rs)) {
-	rs <- readRow(rs, r)
-	binras <- setValues(binras, values(rs), r)
-	binras <- writeRaster(binras, overwrite=TRUE) 
-}
 
-# read and write row by row; write to GeoTiff binary file
-binras <- setRaster(rs, "binbyrow")
-for (r in 1:nrow(rs)) {
-	rs <- readRow(rs, r)
-	binras <- setValues(binras, values(rs), r)
-	binras <- writeRaster(binras, filetype="GTiff", overwrite=TRUE) 
-}
-  
- 
-}
-
 \keyword{ spatial }



More information about the Raster-commits mailing list