getascattr            package:adehabitat            R Documentation

_C_o_p_y _t_h_e _A_t_t_r_i_b_u_t_e_s _o_f _a_n _O_b_j_e_c_t _o_f _C_l_a_s_s '_a_s_c' _o_r '_k_a_s_c'
_t_o _a_n_o_t_h_e_r _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     'getascattr' copies the attributes of an object of class 'asc' to
     another matrix of the same size.
      'getkascattr' performs the same operation for objects of class
     'kasc'.

_U_s_a_g_e:

     getascattr(xfrom, xto, type = c("numeric", "factor"), lev = NULL)
     getkascattr(xkfrom, xkto)

_A_r_g_u_m_e_n_t_s:

   xfrom: an object of class 'asc'

     xto: a matrix with the same number of rows and columns as 'xfrom'

    type: a character string giving the type of the map ('"factor"' for
          maps of categorical  variables, and '"numeric"' otherwise)

     lev: if 'type = "factor"', a character vector giving the levels of
          the mapped variable (see 'help(import.asc)')

  xkfrom: an object of class 'kasc'

    xkto: a data frame with the same number of rows and columns as
          'xkfrom'

_V_a_l_u_e:

     'getascattr' returns a raster matrix of class 'asc',
      'getkascattr' returns a data frame of class 'kasc'

_A_u_t_h_o_r(_s):

     Clment Calenge calenge@biomserv.univ-lyon1.fr

_S_e_e _A_l_s_o:

     'import.asc', 'as.kasc'

_E_x_a_m_p_l_e_s:

     data(puechabon)

     ## my.map is a map of elevation
     my.map <- getkasc(puechabon$kasc, "Elevation")
     sl <- getkasc(puechabon$kasc, "Slope")
     attributes(sl) <- NULL
     sl <- matrix(sl, ncol = ncol(my.map))

     ## sl is a matrix with the same size as my.map
     toto <- getascattr(my.map, sl)
     image(toto)

     ## same rationale with aspect
     asp <- getkasc(puechabon$kasc, "Aspect")
     le <- levels(asp)
     attributes(asp) <- NULL
     asp <- matrix(asp, ncol = ncol(my.map))

     ## asp is now a matrix with the same size as my.map
     tutu <- getascattr(my.map, asp, typ = "factor", lev = le)
     cl <- colasc(tutu, NorthEast = "blue", SouthEast = "red", 
                SouthWest = "orange", NorthWest = "green")
     image(tutu, clfac = cl)

