read.ascii.grid {RSAGA} | R Documentation |
These functions provide simple interfaces for reading and writing grids from/to ASCII grids and Rd files. Grids are stored in matrices, their headers in lists.
read.ascii.grid(file, return.header = TRUE, print = 0, nodata.values = c(), at.once = TRUE) read.ascii.grid.header(file, ...) read.sgrd( fname, return.header = TRUE, print = 0, nodata.values = c(), at.once = TRUE, prec = 7, ... ) read.Rd.grid(fname, return.header = TRUE) write.ascii.grid(data, file, header = NULL, write.header = TRUE, digits, dec = ".", georef = "corner") write.ascii.grid.header(file, header, georef, dec = ".") write.Rd.grid(data, file, header = NULL, write.header = TRUE, compress = TRUE)
file |
file name of an ASCII grid (extension defaults to .asc
if not specified), or a connection open for reading or writing,
as required |
fname |
file name of a grid stored as an R (.Rd ) file;
extension defaults to .Rd |
return.header |
logical: should the grid header be returned (default),
or just the grid data matrix? In the former case, read.ascii.grid
returns a list with two components named data and header . |
print |
numeric, specifying how detailed the output reporting the progress should be (currently 0 to 2, 0 being minimum output. |
nodata.values |
optional numeric vector specifying nodata values to
be used in addition to the nodata value specified in the grid
header; nodata values are converted to NA . |
at.once |
logical: if TRUE , read the whole grid with one
scan command; if FALSE , read it row by row
using scan with option nlines=1 . |
data |
grid data: a data matrix, or a list with components data
(the grid data matrix) and header (the grid header information). |
header |
optional list argument specifying the grid header information
as returned by the read.ascii.grid or read.ascii.grid.header
function; see Details |
write.header |
logical: should the header be written with the grid data?
(default: TRUE ) |
digits |
numeric: if not missing, write grid data rounded to this many digits |
dec |
character (default: "." ): decimal mark used in input
or output file |
georef |
character: specifies whether the output grid should be
georeferenced by the "center" or "corner" of its
lower left grid cell; defaults to "corner" . |
compress |
logical: should the .Rd file written
by write.Rd.file be compressed? (default: TRUE ) |
prec |
integer: number of digits of temporary ASCII grid used for importing or exporting a SAGA grid |
... |
read.sgrd , write.sgrd : additional arguments to be
passed to rsaga.geoprocessor |
The read.*
functions return either a list with components
data
(the grid data matrix) and header
(the grid header
information, see below), if return.header=TRUE
, or otherwise
just the grid data matrix return.header=FALSE
.
The grid data matrix is a numeric matrix whose first column corrensponds
to the first (i.e. northernmost) row of the grid. Columns run from
left = West to right = East.
The header information returned by the read.ascii.grid[.header]
functions (if return.header=TRUE
) is a list with the following
components:
ncols |
Number of grid columns. |
nrows |
Number of grid rows. |
xllcorner |
x coordinate of the corner of the lower left grid cell. |
yllcorner |
y coordinate of the corner of the lower left grid cell. |
cellsize |
Single numeric value specifying the size of a grid cell or pixel in both x and y direction. |
nodata_value |
Single numeric value being interpreted as NA
(typically -9999 . |
xllcenter |
x coordinate of the center of the lower left grid cell |
yllcenter |
y coordinate of the center of the lower left grid cell |
Note: The order of the components, especially of ?llcorner
and
?llcenter
, may change, depending on the order in which they appear
in the grid header and on the georeferencing method (center or corner)
used for the grid. The ?llcorner
and ?llcenter
attributes
differ only by cellsize/2
.
The read.Rd.grid
and write.Rd.grid
functions use
the load
and save
commands to store a grid. The variable name
used is data
, which is either a numeric matrix or a list with components
data
(the grid data matrix) and header
(the grid header information).
Alexander Brenning
write.ascii.grid
, write.ascii.grid.header
,
read.Rd.grid