[Raster-commits] r396 - in pkg/raster: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 6 12:02:37 CEST 2009
Author: rhijmans
Date: 2009-04-06 12:02:37 +0200 (Mon, 06 Apr 2009)
New Revision: 396
Added:
pkg/raster/man/origin.Rd
Modified:
pkg/raster/R/copyRaster.R
pkg/raster/R/depracated.R
pkg/raster/R/export.R
pkg/raster/R/filenames.R
pkg/raster/R/raster.R
pkg/raster/R/resetConnection.R
pkg/raster/R/setFilename.R
pkg/raster/R/writeRaster.R
pkg/raster/man/extent.Rd
pkg/raster/man/fileFunctions.Rd
pkg/raster/man/replacement.Rd
pkg/raster/man/setExtent.Rd
pkg/raster/man/setValues.Rd
pkg/raster/man/writeStack.Rd
Log:
Modified: pkg/raster/R/copyRaster.R
===================================================================
--- pkg/raster/R/copyRaster.R 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/R/copyRaster.R 2009-04-06 10:02:37 UTC (rev 396)
@@ -8,10 +8,10 @@
moveRasterFile <- function(raster, filename, overwrite=FALSE) {
r <- copyRasterFile(raster, filename, overwrite)
f <- trim(filename(raster))
- fileext <- toupper(fileExtension(f))
+ fileext <- toupper(ext(f))
if (fileext == ".GRD") {
file.remove(f)
- fileExtension(f) <- '.gri'
+ ext(f) <- '.gri'
file.remove(f)
}
return(r)
@@ -20,12 +20,12 @@
copyRasterFile <- function(raster, filename, overwrite=FALSE) {
f <- trim(filename(raster))
- fileext <- toupper(fileExtension(f))
+ fileext <- toupper(ext(f))
if (fileext == ".GRD") {
fgrd <- filename
- fileExtension(fgrd) <- '.grd'
+ ext(fgrd) <- '.grd'
fgri <- filename
- fileExtension(fgri) <- '.gri'
+ ext(fgri) <- '.gri'
if ( file.exists(fgrd) & !overwrite ) {
stop('file exists & overwrite = FALSE')
}
@@ -34,7 +34,7 @@
}
res <- file.copy(f, fgrd, overwrite)
if (!res) { stop('could not copy grd file') }
- fileExtension(f) <- ".gri"
+ ext(f) <- ".gri"
res <- file.copy(f, fgri, overwrite)
if (!res) { stop('could not copy gri file') }
filename(raster) <- fgrd
Modified: pkg/raster/R/depracated.R
===================================================================
--- pkg/raster/R/depracated.R 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/R/depracated.R 2009-04-06 10:02:37 UTC (rev 396)
@@ -11,17 +11,6 @@
}
-setFilename <- function(x, value) {
- warning('depracated function. Use "filename(x) <- value"')
- filename(x) <- value
- return(x)
-}
-
-
-setFileExtension <- function(x, value) {
- stop('depracated function. Use "fileExtension(x) <- value"')
-}
-
setRaster <- function(object, filename="", values=NULL) {
warning('depracated, use "raster()" instead')
return(raster(x=object, filename=filename, values=values))
Modified: pkg/raster/R/export.R
===================================================================
--- pkg/raster/R/export.R 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/R/export.R 2009-04-06 10:02:37 UTC (rev 396)
@@ -19,7 +19,7 @@
.writeStx <- function(raster) {
if (raster at data@haveminmax) {
stxfile <- filename(raster)
- fileExtension(stxfile) <- ".stx"
+ ext(stxfile) <- ".stx"
thefile <- file(stxfile, "w") # open an txt file connectionis
cat(1, " ", minValue(raster), " ", maxValue(raster), "\n", file = thefile)
close(thefile)
@@ -29,7 +29,7 @@
.writeBilHdr <- function(raster) {
hdrfile <- filename(raster)
- fileExtension(hdrfile) <- ".hdr"
+ ext(hdrfile) <- ".hdr"
thefile <- file(hdrfile, "w") # open an txt file connectionis
cat("NROWS ", nrow(raster), "\n", file = thefile)
cat("NCOLS ", ncol(raster), "\n", file = thefile)
@@ -80,7 +80,7 @@
.writeErdasRawHdr <- function(raster) {
hdrfile <- filename(raster)
- fileExtension(hdrfile) <- ".raw"
+ ext(hdrfile) <- ".raw"
thefile <- file(hdrfile, "w") # open an txt file connectionis
cat("IMAGINE_RAW_FILE\n", file = thefile)
cat("PIXEL_FILES ", .setFileExtensionValues(filename(raster)), "\n", file = thefile)
@@ -126,7 +126,7 @@
worldFile <- function(raster, extension=".wld") {
hdrfile <- filename(raster)
- fileExtension(hdrfile) <- extension
+ ext(hdrfile) <- extension
thefile <- file(hdrfile, "w")
cat(xres(raster), "\n", file = thefile)
cat("0\n", file = thefile)
@@ -142,7 +142,7 @@
.writeENVIHdr <- function(raster) {
hdrfile <- filename(raster)
- fileExtension(hdrfile) <- ".hdr"
+ ext(hdrfile) <- ".hdr"
thefile <- file(hdrfile, "w")
cat("ENVI\n", file = thefile)
cat("description = {", raster at file@shortname, "}", "\n", file = thefile)
Modified: pkg/raster/R/filenames.R
===================================================================
--- pkg/raster/R/filenames.R 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/R/filenames.R 2009-04-06 10:02:37 UTC (rev 396)
@@ -13,7 +13,7 @@
}
-shortFileName <- function(filename) {
+.shortFileName <- function(filename) {
filename <- gsub("\\\\", "/", filename)
if (filename == "") {return(filename)
} else {
@@ -24,15 +24,15 @@
}
}
-filePath <- function(filename) {
+path <- function(filename) {
filename <- gsub("\\\\", "/", filename)
- file <- shortFileName(filename)
+ file <- .shortFileName(filename)
path <- gsub(file, '', filename)
return(path)
}
-fileExtension <- function(filename) {
+ext <- function(filename) {
lfn <- nchar(filename)
extstart <- -1
for (i in lfn : 2) {
@@ -49,7 +49,7 @@
}
-'fileExtension<-' <- function(filename, value) {
+'ext<-' <- function(filename, value) {
lfn <- nchar(filename)
value <- trim(value)
if (value != "" & substr(value, 1, 1) != ".") {
Modified: pkg/raster/R/raster.R
===================================================================
--- pkg/raster/R/raster.R 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/R/raster.R 2009-04-06 10:02:37 UTC (rev 396)
@@ -21,7 +21,7 @@
setMethod('raster', signature(x='character'),
function(x, values=FALSE, band=1) {
- fileext <- toupper(fileExtension(x))
+ fileext <- toupper(ext(x))
if ( fileext == ".GRD" | fileext == ".GRI" ) {
r <- .rasterFromRasterFile(x, band)
} else {
Modified: pkg/raster/R/resetConnection.R
===================================================================
--- pkg/raster/R/resetConnection.R 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/R/resetConnection.R 2009-04-06 10:02:37 UTC (rev 396)
@@ -13,9 +13,9 @@
fn <- trim(filename(object))
if (fn == "") { stop('no file') }
- fileext <- toupper(fileExtension(fn))
+ fileext <- toupper(ext(fn))
if ( fileext == ".GRD" ) {
- fileExtension(fn) <- '.gri'
+ ext(fn) <- '.gri'
attr(object at file, "con") <- file(fn, "rb")
} else {
attr(object at file, "con") <- GDAL.open(fn)
Modified: pkg/raster/R/setFilename.R
===================================================================
--- pkg/raster/R/setFilename.R 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/R/setFilename.R 2009-04-06 10:02:37 UTC (rev 396)
@@ -18,12 +18,12 @@
filename <- ""
}
if (class(x)=='RasterStack') {
- fileExtension(filename) <- ".stk"
+ ext(filename) <- ".stk"
x at filename <- filename
} else {
x at file@name <- filename
- shortname <- shortFileName(filename)
- fileExtension(shortname) <- ""
+ shortname <- .shortFileName(filename)
+ ext(shortname) <- ""
shortname <- gsub(" ", "_", shortname)
if (nbands(x) > 1) {
shortname <- paste(shortname, "_", band(x))
Modified: pkg/raster/R/writeRaster.R
===================================================================
--- pkg/raster/R/writeRaster.R 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/R/writeRaster.R 2009-04-06 10:02:37 UTC (rev 396)
@@ -6,12 +6,12 @@
.setFileExtensionValues <- function(fname) {
- fileExtension(fname) <- ".gri"
+ ext(fname) <- ".gri"
return(fname)
}
.setFileExtensionHeader <- function(fname) {
- fileExtension(fname) <- ".grd"
+ ext(fname) <- ".grd"
return(fname)
}
Modified: pkg/raster/man/extent.Rd
===================================================================
--- pkg/raster/man/extent.Rd 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/man/extent.Rd 2009-04-06 10:02:37 UTC (rev 396)
@@ -4,16 +4,16 @@
\alias{xmax}
\alias{ymin}
\alias{ymax}
-\alias{origin}
+\alias{xmin<-}
+\alias{xmax<-}
+\alias{ymin<-}
+\alias{ymax<-}
-\title{coordinates}
+\title{Coordinates}
\description{
-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.
+These functions return or set the extreme coordinates of a Raster* object.
}
\usage{
@@ -21,22 +21,26 @@
xmax(object)
ymin(object)
ymax(object)
-origin(object)
+
+xmin(x) <- value
+xmax(x) <- value
+ymin(x) <- value
+ymax(x) <- value
+
}
\arguments{
- \item{object}{Raster* object}
+ \item{object}{A Raster* object}
+ \item{x}{A Raster* object}
+ \item{value}{A new x or y coordinate}
}
-\note{
- Some of these functions simply take the values from the data slots in the RasterLayer or RasterStack object. It is advisable to use these and other 'getter' functions rather than dirctly accessing the slots of an object. This will ensure that code will not break in the future, even if the underlying class definitions change.
-}
\value{
- a single number or (for \code{origin}, a vector of two numbers.
+a single number
}
-\seealso{ \code{\link[raster]{dimensions}} }
+\seealso{ \code{\link[raster]{setExtent}}, \code{\link[raster]{dimensions}} }
\author{Robert J. Hijmans }
@@ -48,8 +52,8 @@
xmax(r)
ymin(r)
ymax(r)
-origin(r)
-
+xmin(r) <- -180
+xmax(r) <- 180
}
\keyword{spatial}
Modified: pkg/raster/man/fileFunctions.Rd
===================================================================
--- pkg/raster/man/fileFunctions.Rd 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/man/fileFunctions.Rd 2009-04-06 10:02:37 UTC (rev 396)
@@ -1,13 +1,11 @@
\name{fileFunctions}
-\alias{setFileExtension}
-\alias{fileExtension}
-\alias{fileExtension<-}
-\alias{shortFileName}
-\alias{filePath}
+\alias{ext}
+\alias{ext<-}
+\alias{path}
\alias{trim}
-\title{filename functions}
+\title{Filename manipulation}
\description{
Low level functions for file name handling.
@@ -16,10 +14,9 @@
}
\usage{
-fileExtension(filename)
-fileExtension(filename) <- value
-shortFileName(filename)
-filePath(filename)
+ext(filename)
+ext(filename) <- value
+path(filename)
trim(x)
}
@@ -36,13 +33,12 @@
\author{Robert J. Hijmans }
\examples{
- fn <- " c:/temp folder/filename.extension "
- fn <- trim(fn)
- fileExtension(fn)
- fileExtension(fn) <- ".txt"
- fileExtension(fn)
- shortFileName(fn)
- filePath(fn)
+fn <- " c:/temp folder/filename.exten sion "
+fn <- trim(fn)
+ext(fn)
+ext(fn) <- ".txt"
+ext(fn)
+path(fn)
}
\keyword{file}
Added: pkg/raster/man/origin.Rd
===================================================================
--- pkg/raster/man/origin.Rd (rev 0)
+++ pkg/raster/man/origin.Rd 2009-04-06 10:02:37 UTC (rev 396)
@@ -0,0 +1,38 @@
+\name{origin}
+
+\alias{origin}
+
+
+\title{Origin}
+
+\description{
+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{
+origin(object)
+}
+
+\arguments{
+ \item{object}{Raster* object}
+}
+
+
+\value{
+ A vector of two numbers (x and y coordinates).
+}
+
+\seealso{ \code{\link[raster]{dimensions}}, \code{\link[raster]{coordinates}} }
+
+
+\author{Robert J. Hijmans }
+
+\examples{
+
+r <- raster(xmn=-0.5, xmx = 9.5, ncols=10)
+origin(r)
+
+}
+
+\keyword{spatial}
Modified: pkg/raster/man/replacement.Rd
===================================================================
--- pkg/raster/man/replacement.Rd 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/man/replacement.Rd 2009-04-06 10:02:37 UTC (rev 396)
@@ -38,6 +38,9 @@
}}
+\seealso{ \code{\link[raster]{values}} , \code{\link[raster]{setValues}} }
+
+
\examples{
r <- raster(ncol=10, nrow=5)
r[] <- 1:ncell(r) * 2
Modified: pkg/raster/man/setExtent.Rd
===================================================================
--- pkg/raster/man/setExtent.Rd 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/man/setExtent.Rd 2009-04-06 10:02:37 UTC (rev 396)
@@ -1,10 +1,6 @@
\name{setExtent}
\alias{setExtent}
-\alias{xmin<-}
-\alias{xmax<-}
-\alias{ymin<-}
-\alias{ymax<-}
\title{Set the extent of a RasteLayer}
@@ -15,10 +11,6 @@
\usage{
setExtent(x, bndbox, keepres=FALSE, snap=FALSE)
-xmin(x) <- value
-xmax(x) <- value
-ymin(x) <- value
-ymax(x) <- value
}
\arguments{
@@ -26,14 +18,12 @@
\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 (see Details)}
\item{snap}{logical. If \code{TRUE}, the extent is adjusted so that the cells of the input and output RasterLayer are aligned}
- \item{value}{an extreme x or y coordinate}
}
\details{
If keepres is \code{FALSE},
(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
-
(the RasterLayers get the same origin)
}
Modified: pkg/raster/man/setValues.Rd
===================================================================
--- pkg/raster/man/setValues.Rd 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/man/setValues.Rd 2009-04-06 10:02:37 UTC (rev 396)
@@ -8,11 +8,10 @@
\alias{setValuesSparse}
\alias{clearValues}
-\title{ Set values of a RasterLayer object }
+\title{Set values}
\description{
-Use these functions to assign values ot a RasterLayer object.
-While you can access the slots of the object directly, you would do that at your own peril because when setting values,
+Use these functions to assign values to a RasterLayer object. While you can access the slots of the object directly, you would do that at your own peril because when setting values,
multiple slots need to be changed.
}
@@ -40,6 +39,9 @@
}
+\seealso{ \code{\link[raster]{replacement}} }
+
+
\value{
a Raster* object
}
Modified: pkg/raster/man/writeStack.Rd
===================================================================
--- pkg/raster/man/writeStack.Rd 2009-04-06 08:14:06 UTC (rev 395)
+++ pkg/raster/man/writeStack.Rd 2009-04-06 10:02:37 UTC (rev 396)
@@ -2,10 +2,13 @@
\alias{writeStack}
-\title{Write values of a RasterStack to a file}
+\title{Write RasterStack}
\description{
-xxx
+
+NOT IMPLEMENTED YET
+
+values of a RasterStack to a multi-band RasterFile
}
\usage{
More information about the Raster-commits
mailing list