[Raster-commits] r313 - in pkg/raster: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Mar 5 09:26:03 CET 2009
Author: rhijmans
Date: 2009-03-05 09:26:03 +0100 (Thu, 05 Mar 2009)
New Revision: 313
Modified:
pkg/raster/R/Artith.R
pkg/raster/R/Math.R
pkg/raster/R/addToStack.R
pkg/raster/R/aggregate.R
pkg/raster/R/calc.R
pkg/raster/R/compare.logical.functions.R
pkg/raster/R/cover.R
pkg/raster/R/expand.R
pkg/raster/R/inifile.R
pkg/raster/R/mCalc.R
pkg/raster/R/map.R
pkg/raster/R/overlay.R
pkg/raster/R/plot.R
pkg/raster/R/readRandom.R
pkg/raster/R/readSkip.R
pkg/raster/R/summary.R
pkg/raster/man/aggregate-methods.Rd
pkg/raster/man/crop.Rd
pkg/raster/man/iniFile.Rd
pkg/raster/man/raster-package.Rd
pkg/raster/man/sample.Rd
Log:
Modified: pkg/raster/R/Artith.R
===================================================================
--- pkg/raster/R/Artith.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/Artith.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -29,7 +29,7 @@
setMethod("Arith", signature(e1='RasterLayer', e2='numeric'),
function(e1, e2){
- if (.CanProcessInMemory(e1, 3)) {
+ if (.CanProcessInMemory(e1, 4)) {
return(setRaster(e1, values=callGeneric(as.numeric(.getRasterValues(e1)), e2) ) )
} else {
raster <- setRaster(e1, filename=tempfile())
@@ -47,7 +47,7 @@
setMethod("Arith", signature(e1='numeric', e2='RasterLayer'),
function(e1, e2){
- if (.CanProcessInMemory(e2, 3)) {
+ if (.CanProcessInMemory(e2, 4)) {
return(setRaster(e2, values=callGeneric(as.numeric(e1), .getRasterValues(e2))))
} else {
raster <- setRaster(e2, filename=tempfile())
Modified: pkg/raster/R/Math.R
===================================================================
--- pkg/raster/R/Math.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/Math.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -36,7 +36,7 @@
setMethod("Math2", signature(x='RasterLayer'),
function (x, digits=0) {
digits <- max(0, digits)
- if (.CanProcessInMemory(x, 1)) {
+ if (.CanProcessInMemory(x, 3)) {
x <- setValues(x, callGeneric(values(x), digits))
if (digits == 0) {
x <- setDatatype(x, 'INT4S')
Modified: pkg/raster/R/addToStack.R
===================================================================
--- pkg/raster/R/addToStack.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/addToStack.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -36,11 +36,11 @@
if (class(rstack) != "RasterStack") {
stop("rstack should be a RasterStack object")
}
- if (length(rasters) == 1 & class(rasters) == 'RasterLayer') {
+ if (class(rasters) == 'RasterLayer') {
rasters <- list(rasters)
}
- for (i in 1 : length(rasters)) {
+ for (i in 1:length(rasters)) {
raster <- rasters[[i]]
if (dataContent(raster) != 'all' & dataSource(raster) == 'ram') {
Modified: pkg/raster/R/aggregate.R
===================================================================
--- pkg/raster/R/aggregate.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/aggregate.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -59,7 +59,7 @@
}
} else if ( dataSource(x) == 'disk') {
- if (!.CanProcessInMemory(x, 2) && filename == '') {
+ if (!.CanProcessInMemory(x, 3) && filename == '') {
filename <- tempfile()
outraster <- setFilename(outraster, filename )
if (options('verbose')[[1]]) { cat('writing raster to:', filename(raster)) }
Modified: pkg/raster/R/calc.R
===================================================================
--- pkg/raster/R/calc.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/calc.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -33,7 +33,7 @@
outraster <- writeRaster(outraster, overwrite=overwrite, filetype=filetype)
}
} else if (dataSource(x) == 'disk') {
- if (!.CanProcessInMemory(x, 2) & filename == '') {
+ if (!.CanProcessInMemory(x, 3) & filename == '') {
filename <- tempfile()
outraster <- setFilename(outraster, filename )
}
Modified: pkg/raster/R/compare.logical.functions.R
===================================================================
--- pkg/raster/R/compare.logical.functions.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/compare.logical.functions.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -42,7 +42,7 @@
setMethod('!', signature(x='RasterLayer'),
function(x){
- if (.CanProcessInMemory(x, 2)) {
+ if (.CanProcessInMemory(x, 3)) {
return(setValues(x, !values(x)))
} else {
raster <- setRaster(x, filename=tempfile())
Modified: pkg/raster/R/cover.R
===================================================================
--- pkg/raster/R/cover.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/cover.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -35,7 +35,7 @@
stop('values for y are not available')
}
- if (!.CanProcessInMemory(x, 2) && filename == '') {
+ if (!.CanProcessInMemory(x, 4) && filename == '') {
filename <- tempfile()
outraster <- setFilename(outraster, filename )
if (options('verbose')[[1]]) { cat('writing raster to:', filename(raster)) }
Modified: pkg/raster/R/expand.R
===================================================================
--- pkg/raster/R/expand.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/expand.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -44,7 +44,7 @@
}
} else if ( dataSource(raster) == 'disk' ) {
- if (!.CanProcessInMemory(outraster, 2) && filename == '') {
+ if (!.CanProcessInMemory(outraster, 4) && filename == '') {
filename <- tempfile()
outraster <- setFilename(outraster, filename )
if (options('verbose')[[1]]) { cat('writing raster to:', filename(raster)) }
Modified: pkg/raster/R/inifile.R
===================================================================
--- pkg/raster/R/inifile.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/inifile.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -5,11 +5,6 @@
# Version 0.8
# Licence GPL v3
-# Read inifile into a matrix of 'section', 'name', value'
-# this function allows for using inistrings that have "=" in the value
-# e.g. "projection = +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"
-
-
readIniFile <- function(filename) {
strSplitOnFirstToken <- function(s, token="=") {
Modified: pkg/raster/R/mCalc.R
===================================================================
--- pkg/raster/R/mCalc.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/mCalc.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -22,7 +22,7 @@
}
} else {
starttime <- proc.time()
- if (!.CanProcessInMemory(x, 2) & filename == '') {
+ if (!.CanProcessInMemory(x, 4) & filename == '') {
filename=tempfile()
outraster <- setFilename(outraster, filename )
}
Modified: pkg/raster/R/map.R
===================================================================
--- pkg/raster/R/map.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/map.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -52,7 +52,7 @@
}
else {
if (subsample) {
- object <- readSkip(object, maxdim=maxdim, asRaster=TRUE)
+ object <- sampleSkip(object, maxdim=maxdim, asRaster=TRUE)
} else {
object <- readAll(object)
}
Modified: pkg/raster/R/overlay.R
===================================================================
--- pkg/raster/R/overlay.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/overlay.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -68,7 +68,7 @@
} else {
if (filename(outraster) == "") {
- if (!.CanProcessInMemory(outraster, 2)) {
+ if (!.CanProcessInMemory(outraster, 4)) {
filename <- tempfile()
outraster <- setFilename(outraster, filename )
} else {
Modified: pkg/raster/R/plot.R
===================================================================
--- pkg/raster/R/plot.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/plot.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -48,8 +48,8 @@
function(x, y, maxdim=1000, cex=0.1, ...) {
comp <- compare(c(x, y), bb=TRUE, rowcol=TRUE, prj=FALSE, tolerance=0.0001, stopiffalse=TRUE)
nc <- ncell(x)
- x <- readSkip(x, maxdim=maxdim)
- y <- readSkip(y, maxdim=maxdim)
+ x <- sampleSkip(x, maxdim=maxdim)
+ y <- sampleSkip(y, maxdim=maxdim)
if (length(x) < nc) {
warning(paste('plot used a sample of ', round(100*length(x)/nc), "% of the cells", sep=""))
}
@@ -68,7 +68,7 @@
if (ncell(x) <= maxsamp) {
values <- na.omit(values(readAll(x)))
} else {
- values <- readRandom(x, maxsamp)
+ values <- sampleRandom(x, maxsamp)
msg <- paste(round(100 * maxsamp / ncell(x)), "% of the raster cells were used", sep="")
if (maxsamp > length(values)) {
msg <- paste(msg, " (of which ", 100 - round(100 * length(values) / maxsamp ), "% were NA)", sep="")
Modified: pkg/raster/R/readRandom.R
===================================================================
--- pkg/raster/R/readRandom.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/readRandom.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -8,7 +8,7 @@
#sample while reading and return matrix (for plotting )
-readRandom <- function(raster, n=500, na.rm = TRUE) {
+sampleRandom <- function(raster, n=500, na.rm = TRUE) {
if (dataContent(raster) == 'all') {
values <- values(raster)
if (na.rm) { values <- na.omit(values) }
@@ -46,7 +46,7 @@
-readSkip <- function(raster, maxdim=500, bndbox=NA, asRaster=FALSE) {
+sampleSkip <- function(raster, maxdim=500, bndbox=NA, asRaster=FALSE) {
if (!(is.na(bndbox))) {
rcut <- crop(raster, bndbox)
warning('bndbox option has not been implemented yet')
Modified: pkg/raster/R/readSkip.R
===================================================================
--- pkg/raster/R/readSkip.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/readSkip.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -6,7 +6,7 @@
-readSkip <- function(raster, maxdim=500, bndbox=NA, asRaster=FALSE) {
+sampleSkip <- function(raster, maxdim=500, bndbox=NA, asRaster=FALSE) {
if (!(is.na(bndbox))) {
rcut <- crop(raster, bndbox)
warning('bndbox option has not been implemented yet')
Modified: pkg/raster/R/summary.R
===================================================================
--- pkg/raster/R/summary.R 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/R/summary.R 2009-03-05 08:26:03 UTC (rev 313)
@@ -7,7 +7,7 @@
.summaryRasters <- function(rasters, fun, funname, na.rm) {
- if (!.CanProcessInMemory(rasters[[1]], 2)) {
+ if (!.CanProcessInMemory(rasters[[1]], 4)) {
filename <- tempfile()
raster <- setRaster(rasters[[1]], filename)
} else {
Modified: pkg/raster/man/aggregate-methods.Rd
===================================================================
--- pkg/raster/man/aggregate-methods.Rd 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/man/aggregate-methods.Rd 2009-03-05 08:26:03 UTC (rev 313)
@@ -8,12 +8,24 @@
\title{Aggregate}
\description{
-Aggregate a RasterLayer to create a new raster with a lower resolution (larger cells). Aggregation groups rectangular areas of RasterLayer cells to create a new RaterLayer with larger cells.
+Aggregate a RasterLayer to create a new raster with a lower resolution (larger cells). Aggregation groups rectangular areas of RasterLayer cells to create a new RasterLayer with larger cells.
A new value is computed for the resulting cells according to a user specified function (default value = \code{mean}).
}
+\usage{
+aggregate(x, ...)
+}
+
+
+\arguments{
+ \item{x}{A RasterLayer object}
+ \item{...}{Additional arguments. See below, under Methods}
+}
+
\section{Methods}{
\describe{
+A full call to the aggregate method is:
+
\code{aggregate(x, fact=2, fun=mean, expand=TRUE, na.rm=TRUE, filename=NULL, filetype='raster', datatype='FLT4S', overwrite=FALSE, track=-1) }
\item{\code{x}}{a RasterLayer object}
Modified: pkg/raster/man/crop.Rd
===================================================================
--- pkg/raster/man/crop.Rd 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/man/crop.Rd 2009-03-05 08:26:03 UTC (rev 313)
@@ -1,11 +1,13 @@
\name{crop}
\alias{crop}
-\title{Crop a RasterLayer}
+\title{Crop}
+
\description{
-crop returns a subset of the input RasterLayer as specified by a bounding box (or object that has a bounding box).
+crop returns a geographic subset of the input RasterLayer as specified by a bounding box (or object that has a bounding box).
Areas in the bounding box outside of the intput RasterLayer are ignored, and the BoundingBox is aligned to the cells of the input RasterLayer.
}
+
\usage{
crop(raster, bndbox, filename="", overwrite=FALSE, filetype='raster', track=-1)
}
Modified: pkg/raster/man/iniFile.Rd
===================================================================
--- pkg/raster/man/iniFile.Rd 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/man/iniFile.Rd 2009-03-05 08:26:03 UTC (rev 313)
@@ -1,19 +1,28 @@
\name{inifile}
+
\alias{readIniFile}
-\title{Miscellaneous functions}
+\title{read ini file}
+
\description{
- Read ini files
+This function reads '.ini' files. These are text file databases that are orginized in [sections] pairs of "name = value".
}
+
\usage{
readIniFile(filename)
}
+
\arguments{
\item{filename}{filename of the .ini file}
}
+\details{
+This function allows for using inistrings that have "=" as part of a value
+}
+
+
\value{
- readIniFile reads "ini-files". I.e. text file databases that are orginized in [sections] and "name = value" pairs.
+ a n*3 matrix of characters with columns: section, name, value
}
\author{Robert J. Hijmans}
Modified: pkg/raster/man/raster-package.Rd
===================================================================
--- pkg/raster/man/raster-package.Rd 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/man/raster-package.Rd 2009-03-05 08:26:03 UTC (rev 313)
@@ -1,24 +1,29 @@
\name{raster-package}
\alias{raster-package}
\docType{package}
+
\title{
-Analysis and modeling of geographic (spatial) raster data.
+Analysis and modeling of raster data.
}
+
\description{
-This packages provides classes and functions to manipulate spatial data in 'raster' (also called 'grid') form.
+This packages provides classes and functions to manipulate geographic (spatial) data in 'raster' form.
+Raster data divides the world in cells (rectangles; pixels) of equal size (in units of the projection).
+Such data are also referred to as 'grid' data.
+The package should be particularly useful when using very large datasets that can not be loaded into the computer's memory. Functions will
+work correctly, because they will read, process, and write blocks of data, without loading all values into memory.
}
+
\details{
\tabular{ll}{
Package: \tab raster\cr
Type: \tab Package\cr
Version: \tab 0.8\cr
-Date: \tab 2009-02-21\cr
+Date: \tab 2009-03-5\cr
License: \tab GPL-3\cr
LazyLoad: \tab yes\cr
}
-This package should be particularly useful when using rather large datasets, as it can
-use datasources that are stored on disk without loading them into memory.
}
\author{
Modified: pkg/raster/man/sample.Rd
===================================================================
--- pkg/raster/man/sample.Rd 2009-03-04 16:22:44 UTC (rev 312)
+++ pkg/raster/man/sample.Rd 2009-03-05 08:26:03 UTC (rev 313)
@@ -1,7 +1,7 @@
\name{Sample}
-\alias{readRandom}
-\alias{readSkip}
+\alias{sampleRandom}
+\alias{sampleSkip}
\title{Sample values of a RasterLayer}
@@ -10,8 +10,8 @@
}
\usage{
-readSkip(raster, maxdim=500, bndbox=NA, asRaster=FALSE)
-readRandom(raster, n=500, na.rm = TRUE)
+sampleSkip(raster, maxdim=500, bndbox=NA, asRaster=FALSE)
+sampleRandom(raster, n=500, na.rm = TRUE)
}
\arguments{
@@ -27,7 +27,8 @@
\author{Robert J. Hijmans}
\examples{
- rs <- rasterFromFile(system.file("external/test.ag", package="sp"))
+ r <- rasterFromFile(system.file("external/test.ag", package="sp"))
+ v <- sampleSkip(r, 10)
}
\keyword{spatial}
More information about the Raster-commits
mailing list