Learn R Programming

adehabitat (version 1.1-1)

as.kasc: Working with Several Raster Maps

Description

as.kasc converts a list of matrices of class asc into a data frame of class kasc. getkasc converts one of the components of a data frame of class kasc into a matrix of class asc. image.kasc displays a image of maps of class kasc.

Usage

as.kasc(l)
getkasc(x, var)
image.kasc(x, mar = c(0, 0, 2, 0), var = names(x), 
           axes = FALSE, clfac = NULL, col = gray((240:1)/256),
           mfrow = NULL, ...)
print.kasc(x, ...)

Arguments

l
a list of objects of class asc
x
an object of class kasc
var
for getkasc, a character string and for image.kasc, a vector of character strings, giving the name of one (or several) variable(s) in x
mar
this parameter is passed as the parameter mar of the function par (see help(par)).
axes
logical. If TRUE, axes are drawn on the maps.
clfac
an optional list of vectors of character strings. Each element of the list is a vector corresponding to one factor in x. Each element of the vector gives the color name associated with each level of the corresponding factor (se
col
a character vector. For numeric maps, the colors to be used
mfrow
A vector of the form c(nr, nc). Subsequent figures will be drawn in an nr-by-nc array on the device by rows
...
additional parameters to be passed to the generic functions image and print

Value

  • as.kasc returns an object of class kasc. The matrices of class asc are converted into vectors and coerced into a data frame of class kasc. This data frame has the following attributes:
  • xllthe X-coordinate of the center of the lower left pixel of the map
  • yllthe Y-coordinate of the center of the lower left pixel of the map
  • cellsizethe size of a pixel
  • nrowthe number of rows of the map. Caution ! the number of rows of the raster map is the number of columns of the matrix of class asc
  • ncolthe number of columns of the map. Caution ! the number of columns of the raster map is the number of rows of the matrix of class asc
  • The different maps in the input list of objects of class asc should describe the same area (same attributes: same cellsize, same xll, same yll, and same dimensions).

See Also

import.asc for additionnal information on objects of class asc

Examples

Run this code
data(puechabon)

## kasc is a list of class kasc
(kasc <- puechabon$kasc)


## Stores two elements of the kasc in objects
## of class asc
(asp <- getkasc(kasc, "Aspect"))
(sl <- getkasc(kasc, "Slope"))


## Displays the slopes on the area (numeric)
image(sl, main = "Aspect", xlab = "Lambert X", ylab = "Lambert Y")


## Aspect is a factor:
## cl is the list of color associated with the levels
## of asp
cl <- colasc(asp, NorthEast = "blue", SouthEast = "red", 
             SouthWest = "orange", NorthWest = "green")
image(asp, clfac = cl, main = "Aspect", xlab = "Lambert X",
      ylab = "Lambert Y")
legend(706500, 3162000, legend=levels(asp), fill=cl, cex=0.7)



## Creation of a new kasc with elevation 
## and slopes
cuicui <- as.kasc(list(Slope = sl, Aspect = asp))

## Displays the kasc object
## with random colors for aspect and grey levels for slopes
image(cuicui)

## with cm.colors for slopes (numeric)
## and cl for aspect (factor)
image(cuicui, col = cm.colors(256), clfac = list(Aspect = cl))

Run the code above in your browser using DataLab