[Raster-commits] r335 - in pkg/raster: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Mar 9 13:30:14 CET 2009
Author: rhijmans
Date: 2009-03-09 13:30:14 +0100 (Mon, 09 Mar 2009)
New Revision: 335
Added:
pkg/raster/R/writeRasterHdr.R
pkg/raster/R/writeRasterRow.R
pkg/raster/R/writeRasterSparse.R
pkg/raster/man/changeExtent.Rd
pkg/raster/man/intersectBbox.Rd
pkg/raster/man/polygonFromBbox.Rd
Modified:
pkg/raster/DESCRIPTION
pkg/raster/R/Merge.R
pkg/raster/R/cellsFromBbox.R
pkg/raster/R/read.raster.R
pkg/raster/R/setBbox.R
pkg/raster/R/writeRaster.R
pkg/raster/man/cellsFromBbox.Rd
pkg/raster/man/click.Rd
pkg/raster/man/getBbox.Rd
pkg/raster/man/overlay.Rd
pkg/raster/man/pointsToRaster.Rd
pkg/raster/man/setExtent.Rd
pkg/raster/man/unionBbox.Rd
Log:
Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/DESCRIPTION 2009-03-09 12:30:14 UTC (rev 335)
@@ -2,7 +2,7 @@
Type: Package
Title: Raster data handling for geographic data analysis and modeling
Version: 0.8.9-5
-Date: 8-March-2009
+Date: 9-March-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/Merge.R
===================================================================
--- pkg/raster/R/Merge.R 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/R/Merge.R 2009-03-09 12:30:14 UTC (rev 335)
@@ -5,7 +5,6 @@
# Version 0.8
# Licence GPL v3
-
setMethod('merge', signature(x='RasterLayer', y='RasterLayer'),
function(x,y,...,tolerance=0.05, filename="", overwrite=FALSE, filetype='raster', track=-1 ){
Modified: pkg/raster/R/cellsFromBbox.R
===================================================================
--- pkg/raster/R/cellsFromBbox.R 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/R/cellsFromBbox.R 2009-03-09 12:30:14 UTC (rev 335)
@@ -8,28 +8,65 @@
-cellsFromBbox <- function(object, bndbox) {
+cellsFromBbox <- function(object, bndbox, expand=FALSE) {
bndbox <- getBbox(bndbox)
# bndbox at xmax - 0.01 * xres(object)
# bndbox at ymin - 0.01 * yres(object)
- srow <- rowFromY(object, bndbox at ymax)
+
+ innerBox <- intersectBbox(getBbox(object), bndbox)
+
+ srow <- rowFromY(object, innerBox at ymax)
+
if (trunc((ymin(object) - bndbox at ymin)/yres(object)) == (ymin(object) - bndbox at ymin)/yres(object)) {
bndbox at ymin <- bndbox at ymin + 0.5 * yres(object)
}
- erow <- rowFromY(object, bndbox at ymin)
- scol <- colFromX(object, bndbox at xmin)
+ erow <- rowFromY(object, innerBox at ymin)
+
+ scol <- colFromX(object, innerBox at xmin)
if (trunc((xmax(object) - bndbox at xmax)/xres(object)) == (xmax(object) - bndbox at xmax)/xres(object)) {
bndbox at xmax <- bndbox at xmax - 0.5 * xres(object)
}
- ecol <- colFromX(object, bndbox at xmax)
- cell <- cellFromRowCol(object, srow, scol):cellFromRowCol(object, srow, ecol)
+ ecol <- colFromX(object, innerBox at xmax)
+
+ if (expand) {
+ addrowstop <- as.integer(round((bndbox at ymax - innerBox at ymax) / yres(object)))
+ addrowsbot <- as.integer(round((innerBox at ymin - bndbox at ymin) / yres(object)))
+ addcolsleft <- as.integer(round((innerBox at xmin - bndbox at xmin) / xres(object)))
+ addcolsright <- as.integer(round((bndbox at xmax - innerBox at xmax) / xres(object)))
+ nc <- ecol-scol+1+addcolsleft+addcolsright
+ }
+
+ cell <- vector()
+
+ if (expand && addrowstop > 0) {
+ cell <- rep(NA, nc * addrowstop)
+ }
+
if (erow > srow) {
+ if (expand && max( addcolsleft, addcolsright) > 0) {
+ for (r in (srow):erow) {
+ cell2 <- cellFromRowCol(object, r, scol):cellFromRowCol(object, r, ecol)
+ if (addcolsleft > 0) {
+ cell2 <- c(rep(NA, addcolsleft), cell2)
+ }
+ if (addcolsright > 0) {
+ cell2 <- c(cell2, rep(NA, addcolsright))
+ }
+ cell <- c(cell, cell2)
+ }
+ } else {
# ouch, vectorize, please
- for (r in (srow+1):erow) {
- cell2 <- cellFromRowCol(object, r, scol):cellFromRowCol(object, r, ecol)
- cell <- c(cell, cell2)
+ for (r in (srow):erow) {
+ cell2 <- cellFromRowCol(object, r, scol):cellFromRowCol(object, r, ecol)
+ cell <- c(cell, cell2)
+ }
}
}
+
+ if (expand && addrowsbot > 0) {
+ cell <- c(cell, rep(NA, nc * addrowsbot))
+ }
+
return(cell)
}
Modified: pkg/raster/R/read.raster.R
===================================================================
--- pkg/raster/R/read.raster.R 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/R/read.raster.R 2009-03-09 12:30:14 UTC (rev 335)
@@ -206,10 +206,10 @@
dtype <- .shortDataType(raster at file@datanotation)
for (i in 1:length(cells)) {
seek(con, (cells[i]-1) * dsize)
- if (dtype == "INT") {
- dtype <- integer
+ if (dtype == "FLT") {
+ dtype <- "numeric"
} else {
- dtype <- numeric
+ dtype <- "integer"
}
res[i] <- readBin(con, what=dtype, n=1, size=dsize, endian=raster at file@byteorder)
}
Modified: pkg/raster/R/setBbox.R
===================================================================
--- pkg/raster/R/setBbox.R 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/R/setBbox.R 2009-03-09 12:30:14 UTC (rev 335)
@@ -32,9 +32,13 @@
newobj at bbox@ymax <- newobj at bbox@ymin + nrow(newobj) * yrs
if (dataContent(x) == 'all') {
- indices <- cellsFromBbox(x, bb)
- newobj <- setValues(newobj, values(x)[indices])
+ indices <- cellsFromBbox(x, bb, expand=TRUE)
+ v <- vector(length=length(indices))
+ v[] <- NA
+ v[!is.na(indices)] <- values(x)[!is.na(indices)]
+ newobj <- setValues(newobj, v)
}
+
} else if (class(x) != "BasicRaster") {
if (ncol(x)==ncol(newobj) & nrow(x)==nrow(newobj)) {
if (dataContent(x) == 'all') {
Modified: pkg/raster/R/writeRaster.R
===================================================================
--- pkg/raster/R/writeRaster.R 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/R/writeRaster.R 2009-03-09 12:30:14 UTC (rev 335)
@@ -84,141 +84,5 @@
-
- .startRowWriting <- function(raster, overwrite) {
- filename(raster) <- trim(filename(raster))
- if (filename(raster) == "") {
- stop('first provide a filename. E.g.: raster <- setFilename(raster, "c:/myfile")')
- }
-
- raster <- setFilename(raster, .setFileExtensionHeader(filename(raster)))
-
- if (!overwrite & file.exists(filename(raster))) {
- stop(paste(filename(raster),"exists.","use 'overwrite=TRUE' if you want to overwrite it"))
- }
- raster at file@name <- .setFileExtensionHeader(filename(raster))
- binraster <- .setFileExtensionValues(filename(raster))
-
- attr(raster at file, "con") <- file(binraster, "wb")
- attr(raster at file, "dsize") <- dataSize(raster at file@datanotation)
- attr(raster at file, "dtype") <- .shortDataType(raster at file@datanotation)
-
- raster at data@min <- Inf
- raster at data@max <- -Inf
- raster at data@haveminmax <- FALSE
- raster at file@driver <- 'raster'
- raster at file@gdalhandle <- list()
- return(raster)
-}
-.stopRowWriting <- function(raster) {
- .writeRasterHdr(raster)
- close(raster at file@con)
- raster at data@haveminmax <- TRUE
- raster at data@source <- 'disk'
- raster at data@content <- 'nodata'
- raster at data@values <- vector(length=0)
- return(raster)
-}
-
-
-.writeRasterRow <- function(raster, overwrite=FALSE) {
-# if (dataContent(raster) != 'row') {
-# stop('raster does not contain a row')
-# }
- if (dataIndices(raster)[1] == 1) {
- raster <- .startRowWriting(raster, overwrite=overwrite)
- }
-
- raster at data@values[is.nan(raster at data@values)] <- NA
- raster at data@values[is.infinite(raster at data@values)] <- NA
- if (raster at file@dtype == "INT" || raster at file@dtype =='LOG' ) {
- values <- as.integer(round(raster at data@values))
- values[is.na(values)] <- as.integer(raster at file@nodatavalue)
- } else {
- values <- as.numeric( raster at data@values )
- }
-
- rsd <- na.omit(raster at data@values) # min and max values
- if (length(rsd) > 0) {
- raster at data@min <- min(raster at data@min, min(rsd))
- raster at data@max <- max(raster at data@max, max(rsd))
- }
-
- writeBin(values, raster at file@con, size = raster at file@dsize )
-
- if (dataIndices(raster)[2] >= ncell(raster)) {
- raster <- .stopRowWriting(raster)
- if (dataIndices(raster)[2] > ncell(raster)) {
- warning(paste('You have written beyond the end of file. last cell:', dataIndices(raster)[2], '>', ncell(raster)))
- }
- }
- return(raster)
-}
-
-
-
-.writeSparse <- function(raster, overwrite=FALSE) {
-
- raster at file@driver <- 'raster'
- raster at file@gdalhandle <- list()
- raster <- setFilename(raster, .setFileExtensionHeader(filename(raster)))
- if (!overwrite & file.exists(filename(raster))) {
- stop(paste(filename(raster), "exists. Use 'overwrite=TRUE' if you want to overwrite it"))
- }
-
- raster at data@values[is.nan(values(raster))] <- NA
-
- dtype <- .shortDataType(raster at data@datanotation)
- if (dtype == "integer") {
- raster at data@values <- as.integer(values(raster))
- }
- if (class(values(raster))=='integer') {
- raster <- setDatatype(raster, 'INT4S')
- }
- raster <- setMinMax(raster)
-
- binraster <- .setFileExtensionValues(filename(raster))
- con <- file(binraster, "wb")
- writeBin( as.vector(dataIndices(raster)), con, size = as.integer(4))
- writeBin( as.vector(values(raster)), con, size = dataSize(raster at file@datanotation) )
- close(con)
-
- # add the 'sparse' key word to the hdr file!!!
- .writeRasterHdr(raster)
- return(raster)
-}
-
-
-.writeRasterHdr <- function(raster) {
- rastergrd <- .setFileExtensionHeader(filename(raster))
- thefile <- file(rastergrd, "w") # open an txt file connectionis
- cat("[general]", "\n", file = thefile)
- cat("creator=R package:raster", "\n", file = thefile)
- cat("created=", format(Sys.time(), "%Y-%m-%d %H:%M:%S"), "\n", file = thefile)
- cat("title=", raster at file@shortname, "\n", file = thefile)
- cat("[georeference]", "\n", file = thefile)
- cat("nrows=", nrow(raster), "\n", file = thefile)
- cat("ncols=", ncol(raster), "\n", file = thefile)
- cat("xmin=", xmin(raster), "\n", file = thefile)
- cat("ymin=", ymin(raster), "\n", file = thefile)
- cat("xmax=", xmax(raster), "\n", file = thefile)
- cat("ymax=", ymax(raster), "\n", file = thefile)
- cat("xres=", xres(raster), "\n", file = thefile)
- cat("yres=", yres(raster), "\n", file = thefile)
- cat("projection=", projection(raster), "\n", file = thefile)
- cat("[data]", "\n", file = thefile)
- cat("DataType=", raster at file@datanotation, "\n", file = thefile)
- cat("ByteOrder=", .Platform$endian, "\n", file = thefile)
- cat("nbands=", nbands(raster), "\n", file = thefile)
- cat("bandOrder=", raster at file@bandorder, "\n", file = thefile)
- cat("minValue=", minValue(raster), "\n", file = thefile)
- cat("maxValue=", maxValue(raster), "\n", file = thefile)
- cat("NoDataValue=", .nodatavalue(raster), "\n", file = thefile)
-# cat("Sparse=", raster at sparse, "\n", file = thefile)
-# cat("nCellvals=", raster at data@ncellvals, "\n", file = thefile)
- close(thefile)
-}
-
-
Added: pkg/raster/R/writeRasterHdr.R
===================================================================
--- pkg/raster/R/writeRasterHdr.R (rev 0)
+++ pkg/raster/R/writeRasterHdr.R 2009-03-09 12:30:14 UTC (rev 335)
@@ -0,0 +1,37 @@
+# Author: Robert J. Hijmans, r.hijmans at gmail.com
+# International Rice Research Institute
+# Date : June 2008
+# Version 0.8
+# Licence GPL v3
+
+
+.writeRasterHdr <- function(raster) {
+ rastergrd <- .setFileExtensionHeader(filename(raster))
+ thefile <- file(rastergrd, "w") # open an txt file connectionis
+ cat("[general]", "\n", file = thefile)
+ cat("creator=R package:raster", "\n", file = thefile)
+ cat("created=", format(Sys.time(), "%Y-%m-%d %H:%M:%S"), "\n", file = thefile)
+ cat("title=", raster at file@shortname, "\n", file = thefile)
+ cat("[georeference]", "\n", file = thefile)
+ cat("nrows=", nrow(raster), "\n", file = thefile)
+ cat("ncols=", ncol(raster), "\n", file = thefile)
+ cat("xmin=", xmin(raster), "\n", file = thefile)
+ cat("ymin=", ymin(raster), "\n", file = thefile)
+ cat("xmax=", xmax(raster), "\n", file = thefile)
+ cat("ymax=", ymax(raster), "\n", file = thefile)
+ cat("xres=", xres(raster), "\n", file = thefile)
+ cat("yres=", yres(raster), "\n", file = thefile)
+ cat("projection=", projection(raster), "\n", file = thefile)
+ cat("[data]", "\n", file = thefile)
+ cat("DataType=", raster at file@datanotation, "\n", file = thefile)
+ cat("ByteOrder=", .Platform$endian, "\n", file = thefile)
+ cat("nbands=", nbands(raster), "\n", file = thefile)
+ cat("bandOrder=", raster at file@bandorder, "\n", file = thefile)
+ cat("minValue=", minValue(raster), "\n", file = thefile)
+ cat("maxValue=", maxValue(raster), "\n", file = thefile)
+ cat("NoDataValue=", .nodatavalue(raster), "\n", file = thefile)
+# cat("Sparse=", raster at sparse, "\n", file = thefile)
+# cat("nCellvals=", raster at data@ncellvals, "\n", file = thefile)
+ close(thefile)
+}
+
Added: pkg/raster/R/writeRasterRow.R
===================================================================
--- pkg/raster/R/writeRasterRow.R (rev 0)
+++ pkg/raster/R/writeRasterRow.R 2009-03-09 12:30:14 UTC (rev 335)
@@ -0,0 +1,79 @@
+# Author: Robert J. Hijmans, r.hijmans at gmail.com
+# International Rice Research Institute
+# Date : June 2008
+# Version 0.8
+# Licence GPL v3
+
+
+ .startRowWriting <- function(raster, overwrite) {
+ filename(raster) <- trim(filename(raster))
+ if (filename(raster) == "") {
+ stop('first provide a filename. E.g.: raster <- setFilename(raster, "c:/myfile")')
+ }
+
+ raster <- setFilename(raster, .setFileExtensionHeader(filename(raster)))
+
+ if (!overwrite & file.exists(filename(raster))) {
+ stop(paste(filename(raster),"exists.","use 'overwrite=TRUE' if you want to overwrite it"))
+ }
+ raster at file@name <- .setFileExtensionHeader(filename(raster))
+ binraster <- .setFileExtensionValues(filename(raster))
+
+ attr(raster at file, "con") <- file(binraster, "wb")
+ attr(raster at file, "dsize") <- dataSize(raster at file@datanotation)
+ attr(raster at file, "dtype") <- .shortDataType(raster at file@datanotation)
+
+ raster at data@min <- Inf
+ raster at data@max <- -Inf
+ raster at data@haveminmax <- FALSE
+ raster at file@driver <- 'raster'
+ raster at file@gdalhandle <- list()
+ return(raster)
+}
+
+.stopRowWriting <- function(raster) {
+ .writeRasterHdr(raster)
+ close(raster at file@con)
+ raster at data@haveminmax <- TRUE
+ raster at data@source <- 'disk'
+ raster at data@content <- 'nodata'
+ raster at data@values <- vector(length=0)
+ return(raster)
+}
+
+
+.writeRasterRow <- function(raster, overwrite=FALSE) {
+# if (dataContent(raster) != 'row') {
+# stop('raster does not contain a row')
+# }
+
+ if (dataIndices(raster)[1] == 1) {
+ raster <- .startRowWriting(raster, overwrite=overwrite)
+ }
+
+ raster at data@values[is.nan(raster at data@values)] <- NA
+ raster at data@values[is.infinite(raster at data@values)] <- NA
+ if (raster at file@dtype == "INT" || raster at file@dtype =='LOG' ) {
+ values <- as.integer(round(raster at data@values))
+ values[is.na(values)] <- as.integer(raster at file@nodatavalue)
+ } else {
+ values <- as.numeric( raster at data@values )
+ }
+
+ rsd <- na.omit(raster at data@values) # min and max values
+ if (length(rsd) > 0) {
+ raster at data@min <- min(raster at data@min, min(rsd))
+ raster at data@max <- max(raster at data@max, max(rsd))
+ }
+
+ writeBin(values, raster at file@con, size = raster at file@dsize )
+
+ if (dataIndices(raster)[2] >= ncell(raster)) {
+ raster <- .stopRowWriting(raster)
+ if (dataIndices(raster)[2] > ncell(raster)) {
+ warning(paste('You have written beyond the end of file. last cell:', dataIndices(raster)[2], '>', ncell(raster)))
+ }
+ }
+ return(raster)
+}
+
Added: pkg/raster/R/writeRasterSparse.R
===================================================================
--- pkg/raster/R/writeRasterSparse.R (rev 0)
+++ pkg/raster/R/writeRasterSparse.R 2009-03-09 12:30:14 UTC (rev 335)
@@ -0,0 +1,36 @@
+# Author: Robert J. Hijmans, r.hijmans at gmail.com
+# International Rice Research Institute
+# Date : June 2008
+# Version 0.8
+# Licence GPL v3
+
+.writeSparse <- function(raster, overwrite=FALSE) {
+
+ raster at file@driver <- 'raster'
+ raster at file@gdalhandle <- list()
+ raster <- setFilename(raster, .setFileExtensionHeader(filename(raster)))
+ if (!overwrite & file.exists(filename(raster))) {
+ stop(paste(filename(raster), "exists. Use 'overwrite=TRUE' if you want to overwrite it"))
+ }
+
+ raster at data@values[is.nan(values(raster))] <- NA
+
+ dtype <- .shortDataType(raster at data@datanotation)
+ if (dtype == "integer") {
+ raster at data@values <- as.integer(values(raster))
+ }
+ if (class(values(raster))=='integer') {
+ raster <- setDatatype(raster, 'INT4S')
+ }
+ raster <- setMinMax(raster)
+
+ binraster <- .setFileExtensionValues(filename(raster))
+ con <- file(binraster, "wb")
+ writeBin( as.vector(dataIndices(raster)), con, size = as.integer(4))
+ writeBin( as.vector(values(raster)), con, size = dataSize(raster at file@datanotation) )
+ close(con)
+
+ # add the 'sparse' key word to the hdr file!!!
+ .writeRasterHdr(raster)
+ return(raster)
+}
Modified: pkg/raster/man/cellsFromBbox.Rd
===================================================================
--- pkg/raster/man/cellsFromBbox.Rd 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/man/cellsFromBbox.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -1,39 +1,38 @@
-\name{fromBbox}
+\name{cellsFromBbox}
+
\alias{cellsFromBbox}
-\alias{polygonFromBbox}
-\title{Additional BoundingBox functions}
+\title{Cells from BoundingBox}
+
\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)
+cellsFromBbox(object, bndbox, expand=FALSE)
}
\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}
+ \item{expand}{Logical. If \code{TRUE}, \code{NA} is returned for (virtual) cells implied by \code{bndbox},
+ that are outside the RasterLayer (\code{object}). If \code{FALSE}, only cell numbers for the area where \code{object} and \code{bndbox}
+ overlap are returned (see \link[raster]{intersectBbox} }
}
\value{
-a vector of cell numbers of a SpatialPolygons object
+a vector of cell numbers
}
\author{Robert J. Hijmans}
-\seealso{ \code{\link[raster]{newBbox}}, \code{\link[sp]{SpatialPolygons}} }
+\seealso{ \code{\link[raster]{polygonFromBbox}}, \code{\link[raster]{newBbox}}, \code{\link[sp]{SpatialPolygons}} }
\examples{
r <- raster()
bb <- newBbox(-10, 10, -20, 20)
cells <- cellsFromBbox(r, bb)
-pol <- polygonFromBbox(bb)
}
\keyword{spatial}
Added: pkg/raster/man/changeExtent.Rd
===================================================================
--- pkg/raster/man/changeExtent.Rd (rev 0)
+++ pkg/raster/man/changeExtent.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -0,0 +1,43 @@
+\name{changeExtent}
+
+\alias{changeExtent}
+
+\title{Change the extent of a RasteLayer}
+
+\description{
+
+changeExtent changes the extent (the bounding box) of a Raster* object
+
+the extent can also be changed by assignment functions (e.g. \code{xmin(x) <- -180}).
+}
+
+\usage{
+changeExtent(x, xmn=xmin(x), xmx=xmax(x), ymn=ymin(x), ymx = ymax(x), keepres=FALSE)
+}
+
+\arguments{
+ \item{x}{A Raster* object}
+ \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{xmn}{the minimum x coordinate of the object}
+ \item{xmx}{the maximum x coordinate of the object}
+ \item{ymn}{the minimum y coordinate of the object}
+ \item{ymx}{the maximum y coordinate of the object}
+
+}
+
+\value{
+a Raster* object
+}
+
+\author{Robert J. Hijmans}
+
+\seealso{ \code{\link[raster]{setExtent}}, \code{\link[raster]{BoungingBox-class}} }
+
+\examples{
+r <- raster()
+r <- changeExtent(r, xmn=1, xmx=50)
+xmin(r) <- -30
+ymax(r) <- 60
+}
+
+\keyword{spatial}
Modified: pkg/raster/man/click.Rd
===================================================================
--- pkg/raster/man/click.Rd 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/man/click.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -2,10 +2,12 @@
\alias{click}
\title{ Click }
+
\description{
Click on a plot (map) to get values of a Raster* object at a location; and optionally the coordinates for the location.
Multiple locations can be clicked on by specifying \code{n=}.
}
+
\usage{
click(object, n=1, xy=FALSE, type = "n", ...)
}
@@ -27,7 +29,15 @@
The value(s) of \code{object} at the point(s) clicked on; and the coordinates if \code{xy==TRUE}.
}
+\seealso{ \code{\link[raster]{drawBbox}} }
+
\author{ Robert J. Hijmans }
+\examples{
+ r <- rasterFromFile(system.file("external/test.ag", package="sp"))
+#plot(r)
+#click(r)
+#now click on the plot (map)
+}
\keyword{ spatial }
Modified: pkg/raster/man/getBbox.Rd
===================================================================
--- pkg/raster/man/getBbox.Rd 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/man/getBbox.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -1,4 +1,4 @@
-\name{getBBox}
+\name{getBbox}
\alias{getBbox}
\alias{getBbox,BoundingBox-method}
@@ -30,7 +30,7 @@
\author{Robert J. Hijmans}
-\seealso{ \code{\link[raster]{setBoungingBox}}, \code{\link[raster]{clickBbox}} }
+\seealso{ \code{\link[raster]{setBoungingBox}}, \code{\link[raster]{drawBbox}} }
\examples{
r <- raster()
Added: pkg/raster/man/intersectBbox.Rd
===================================================================
--- pkg/raster/man/intersectBbox.Rd (rev 0)
+++ pkg/raster/man/intersectBbox.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -0,0 +1,35 @@
+\name{intersectBbox}
+
+\alias{intersectBbox}
+
+\title{BoundingBox intersection}
+
+\description{
+intersectBbox returns the instersection of multiple bounding boxes
+}
+
+\usage{
+intersectBbox(x, ...)
+}
+
+\arguments{
+ \item{x}{A BoundingBox or Raster* object }
+ \item{...}{ additional BoundingBox or Raster* objects }
+}
+
+\value{
+a BoundingBox object
+}
+
+\author{Robert J. Hijmans}
+
+\seealso{ \code{\link[raster]{unionBbox}}, \code{\link[raster]{getBoungingBox}}, \code{\link[raster]{setBoungingBox}} }
+
+\examples{
+r <- raster()
+b1 <- newBbox(-10, 10, -20, 20)
+b2 <- newBbox(0, 20, -40, 5)
+i <- intersectBbox(b1, b2)
+}
+
+\keyword{spatial}
Modified: pkg/raster/man/overlay.Rd
===================================================================
--- pkg/raster/man/overlay.Rd 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/man/overlay.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -35,11 +35,13 @@
}
\details{
-In stead of the overlay function you can also use normal artimic functions such as *, /, +, - with RasterLayer objects (see examples), but then you cannot specifiy an output filename, filetype or datatype.
+In stead of the overlay function you can also use normal artimic functions such as *, /, +, - with RasterLayer objects (see examples),
+but then you cannot specifiy an output filename, filetype or datatype.
}
\value{
-a new RasterLayer object (and in some cases, if a filename is provided or the output values cannot be stored in memory, the side effect of a file on disk)
+a new RasterLayer object and in some cases, if a filename is provided or the output values cannot be stored in memory,
+the side effect of a file on disk
}
\seealso{ \code{\link[raster]{Arith-methods}} }
Modified: pkg/raster/man/pointsToRaster.Rd
===================================================================
--- pkg/raster/man/pointsToRaster.Rd 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/man/pointsToRaster.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -28,7 +28,7 @@
Each point is assinged to a grid cell. The value of a grid cell is determined by the values associated with the points and function fun.
If you want the count of points in each grid cell, use the (default) \code{length} function. I.e. for each cell it computes the length of the vector of points.
If you want the sum of the values, use \code{sum} for the sum.
-If you want a yes/no result, you can use fun=function(x){if(lenght(x)>0 {r<-1} else {r<-0}; return(r)}
+If you want a yes/no result, you can use "fun=function(x)\{if(lenght(x)>0 \{r<-1\} else \{r<-0\}; return(r)\}"
}
\value{
a RasterLayer object
Added: pkg/raster/man/polygonFromBbox.Rd
===================================================================
--- pkg/raster/man/polygonFromBbox.Rd (rev 0)
+++ pkg/raster/man/polygonFromBbox.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -0,0 +1,36 @@
+\name{polygonFromBbox}
+\alias{polygonFromBbox}
+
+
+\title{Polygon from BoundingBox}
+
+\description{
+polygonFromBbox creates a SpatialPolygon object from a BoundingBox object (or a Raster*) object
+}
+
+\usage{
+polygonFromBbox(bndbox, sp=TRUE)
+}
+
+\arguments{
+ \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{
+a matrix or a SpatialPolygons object
+}
+
+\author{Robert J. Hijmans}
+
+\seealso{ \code{\link[raster]{cellsFromBbox}}, \code{\link[raster]{newBbox}}, \code{\link[sp]{SpatialPolygons}} }
+
+\examples{
+r <- raster()
+b <- getBbox(r)
+pol <- polygonFromBbox(b)
+}
+
+\keyword{spatial}
+
+
Modified: pkg/raster/man/setExtent.Rd
===================================================================
--- pkg/raster/man/setExtent.Rd 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/man/setExtent.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -1,26 +1,20 @@
\name{setExtent}
\alias{setExtent}
-\alias{changeExtent}
\alias{xmin<-}
\alias{xmax<-}
\alias{ymin<-}
\alias{ymax<-}
-\title{change extent of a RasteLayer}
+\title{Set the extent of a RasteLayer}
\description{
-setExtent sets a new bounding box of a RasterLayer
-
-changeExtent changes the bounding box of a Raster* object
-
-the extent can also be changed by assignment functions (e.g. \code{xmin(x) <- -180}).
+setExtent sets the extent (bounding box) of a RasterLayer
}
\usage{
setExtent(x, bndbox, keepres=FALSE, snap=FALSE)
-changeExtent(x, xmn=xmin(x), xmx=xmax(x), ymn=ymin(x), ymx = ymax(x), keepres=FALSE)
}
\arguments{
@@ -28,10 +22,6 @@
\item{bndbox}{An object of class BoundingBox (which you can create with newBbox() )}
\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}{logical. If \code{TRUE}, the object's BoundingBox is adjusted so that the cells of the output RasterLayer are aligned with those of the input RasterLayer }
- \item{xmn}{the minimum x coordinate of the object}
- \item{xmx}{the maximum x coordinate of the object}
- \item{ymn}{the minimum y coordinate of the object}
- \item{ymx}{the maximum y coordinate of the object}
}
@@ -41,15 +31,12 @@
\author{Robert J. Hijmans}
-\seealso{ \code{\link[raster]{getBbox}}, \code{\link[raster]{BoungingBox-class}}, \code{\link[raster]{clickBbox}} }
+\seealso{ \code{\link[raster]{changeExtent}}, \code{\link[raster]{BoungingBox-class}} }
\examples{
r <- raster()
bb <- newBbox(-10, 10, -20, 20)
r <- setExtent(r, bb, keepres=TRUE)
-r <- changeExtent(r, xmn=xmin(r)+1, xmx=xmax(r)+1)
-xmin(r) <- -30
-ymax(r) <- 60
}
\keyword{spatial}
Modified: pkg/raster/man/unionBbox.Rd
===================================================================
--- pkg/raster/man/unionBbox.Rd 2009-03-09 09:03:41 UTC (rev 334)
+++ pkg/raster/man/unionBbox.Rd 2009-03-09 12:30:14 UTC (rev 335)
@@ -1,18 +1,15 @@
-\name{unionBoundingBox}
+\name{unionBbox}
\alias{unionBbox}
-\alias{intersectBbox}
-\title{BoundingBox union and intersection}
+\title{BoundingBox union}
\description{
unionBbox returns the union of multiple bounding boxes
-intersectBbox returns the instersection of multiple bounding boxes
}
\usage{
unionBbox(x, ...)
-intersectBbox(x, ...)
}
\arguments{
@@ -26,14 +23,13 @@
\author{Robert J. Hijmans}
-\seealso{ \code{\link[raster]{getBoungingBox}}, \code{\link[raster]{setBoungingBox}} }
+\seealso{ \code{\link[raster]{intersectBbox}}, \code{\link[raster]{getBbox}}, \code{\link[raster]{setExtent}} }
\examples{
r <- raster()
b1 <- newBbox(-10, 10, -20, 20)
b2 <- newBbox(0, 20, -40, 5)
u <- unionBbox(b1, b2)
-i <- intersectBbox(b1, b2)
}
\keyword{spatial}
More information about the Raster-commits
mailing list