[Raster-commits] r486 - in pkg/raster: R inst/doc
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Sep 10 05:08:51 CEST 2009
Author: rhijmans
Date: 2009-09-10 05:08:51 +0200 (Thu, 10 Sep 2009)
New Revision: 486
Removed:
pkg/raster/R/trmm3B43ToRaster.R
Modified:
pkg/raster/inst/doc/vignette.Rnw
Log:
Deleted: pkg/raster/R/trmm3B43ToRaster.R
===================================================================
--- pkg/raster/R/trmm3B43ToRaster.R 2009-09-10 02:03:44 UTC (rev 485)
+++ pkg/raster/R/trmm3B43ToRaster.R 2009-09-10 03:08:51 UTC (rev 486)
@@ -1,37 +0,0 @@
-# Author: Angelo Carlo D. PAcheco and Jorrel Khalil Aunario
-# Date : September 9, 2009
-# Version 0.1
-# Licence GPL v3
-
-
-library(raster)
-
-# Function for converting TRMM 3B43 v6 ascii data to raster
-# Indicate the number of header lines to remove (except column names)
-asciiToRaster<- function(filename, outputFName="trmm.tif", hdrs=5){
-
-
- write.table(readLines(filename)[-(1:hdrs)], "temp.txt", row.names=F, col.names=F, quote=F)
- coor <- read.table("temp.txt", header=T)
-
- y = max(coor[,1]) - min(coor[,1])
- y = y*4
-
- x = max(coor[,2]) - min(coor[,2])
- x = x*4
-
- rast <- raster(nrow=y, ncol=x, xmn=min(coor[,2]), xmx=max(coor[,2]), ymn=min(coor[,1]), ymx=max(coor[,1]) )
- rast[] <- -9999
-
- vec <- 1:length(rast[])
- vec[] <- -9999
-
- c <- cellFromXY(rast, cbind(coor[,2],coor[,1]) )
- vec[c] <- coor[,3]
-
- rast <- setValues(rast, vec)
-
- filename(rast) <- outputFName
- writeRaster(rast, file="GTiff")
-
-}
\ No newline at end of file
Modified: pkg/raster/inst/doc/vignette.Rnw
===================================================================
--- pkg/raster/inst/doc/vignette.Rnw 2009-09-10 02:03:44 UTC (rev 485)
+++ pkg/raster/inst/doc/vignette.Rnw 2009-09-10 03:08:51 UTC (rev 486)
@@ -24,21 +24,17 @@
\section{Abstract}
-This is an vignette for the \verb at raster@ package in R. The \verb at raster@ package deals with basic spatial raster (grid) data access and manipulation. Its principal aims are (1) to provide an easy interface to common 'high level' functions for raster data manipulation and management; (2) that all functions can work with very large raster datasets that are stored on disk as they cannot be loaded into memory; (3) to provide low-level functions on which new functions can be easily developed; and (4) to provide an easy-to-use raster algebra implementation. High level functions include overlay, merge, aggregate, projection, resample, distance, polygon to raster conversion. All these functions work for raster datasets that cannot be loaded into memory. Lower level functions include row by row reading and writing (from and to many different file formats via \verb at rgdal@).
+This is an vignette for the \verb at raster@ package in R. The \verb at raster@ package has functions for with spatial raster (grid) data access and manipulation. The package was developed to (1) provide an easy interface to common 'high level' functions for raster data manipulation and management; (2) assure that all these functions can work with very large raster datasets, that are stored on disk as they cannot be loaded into memory; (3) to provide low-level functions on which new functions can be easily developed; and (4) to provide an easy-to-use raster algebra implementation. High level functions include overlay, merge, aggregate, projection, resample, distance, polygon to raster conversion. All these functions work for raster datasets that cannot be loaded into memory. Lower level functions include row by row reading and writing (from and to many different file formats via \verb at rgdal@).
\section{Introduction}
One of the main reasons for developing this package is that we would like to build a bridge to - the powerful statistics and modeling of - R for the "GIS" community. Our perspective is that standard GIS is too map-centric, and that proper data-analysis needs tools that are more model and data centric.
-
-bla bla bla normally distributed with mean 0 and standard deviation 2.
-
-
\section{Beginning}
-The first thing to do is to install \verb at raster@ package of you have not yet done so. As the package is currently not on CRAN, this takes a tiny bit more effort than installing packages that are on CRAN. \verb at raster@ depends on \verb at rgdal@ so if you do not have that, install it first:
-\verb at install.packages("rgdal")@
+The first thing to do is to install \verb at raster@ package if you have not yet done so. As the package is currently not on CRAN, this takes a tiny bit more effort than installing packages that are on CRAN. \verb at raster@ depends on \verb at sp@ and \verb at rgdal@ so if you do not have these packages, intsall them first:
+\verb at install.packages(c("rgdal", "sp")@
Now install \verb at raster@ from the R-Forge repository
\verb at install.packages("raster", repos="http://R-Forge.R-project.org")@
@@ -47,19 +43,37 @@
library(raster)
r <- raster()
r[] <- 1:ncell(r)
+r[1:10]
plot(r)
@
-Let's use a file, the famous Meuse dataset:
+The command \verb at r <- raster()@ creates a RasterLayer object. RasterLayer objects consist of several parameters describing a raster dataset, such as the number of columns and rows, and the spatial extent. A RasterLayer object does not necessarily contain any raster cell values though. Frequently these values are stored in a file on disk. In this first example we do not have a reference to a file, so we provided some values to the RasterLayer. The values of a RasterLayer are repersented as a (one dimensional) vector, starting in the upper left corner and then increasing to the right and then down row by row untill the last cell in the lower-right corner. An alternative notation for \verb at r[] <- 1:ncell(r)@ is \verb at r <- setValues(r, 1:ncell(r))@.
+It is probably more common to create a RasterLayer from a file. The raster package can read raster files support by rgdal and grid data in netCDF format. Here is an example using the Meuse dataset that comes with the sp package:
+
<<raster-2>>=
r <- raster(system.file("external/test.ag", package="sp"))
r
r <- readRow(r, 50)
values(r)
-s <- sqrt(r)
+s <- sqrt(r) - 5
+plot(s)
@
+The command \verb at r <- raster(filename)@ creates a raster object describing the data on file, but not reading the actual raster cell values. \verb at readRow@ reads the values of a specified row of a raster file into memory. \verb at readAll@ reads all values, but this may not be possible if the file is very large. \verb at values(r)@ returns the values that are currently in memory (i.e. those of row 50). \verb at s <- sqrt(r) - r + 1@ is an example of raster algebra. \verb at s@ is a new RasterLayer, its values are the square root of r minus 5. The computation was done for the entire raster, not just for the values that were in memory. The new values are available in memory and can be inspected via \verb at plot@, @values(r)@, or via indexing, e.g. \verb at r[1:5]@. If the raster file had been very large, the results might have been written to a temporary file.
+
+<<raster-3>>=
+r <- raster()
+r[] <- 1:ncell(r)
+ra <- aggregate(r, 10)
+r1 <- crop(r, newExtent(-180,0,0,30))
+r2 <- crop(r, newExtent(-10,180,-20,10))
+m <- merge(r1, r2)
+o <- overlay(ra, m, fun=sum)
+d <- disaggregate(m, 2)
+f <- focal(d)
+@
+
\begin{itemize}
\item this is a bullet point
\item and so is this
More information about the Raster-commits
mailing list