kasc2spixdf            package:adehabitat            R Documentation

_C_o_n_v_e_r_s_i_o_n _o_f _m_a_p_s _f_r_o_m/_t_o _t_h_e _p_a_c_k_a_g_e "_s_p"

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

     These functions convert maps of classes available in adehabitat
     toward classes available in the package 'sp' and conversely.

      'kasc2spixdf' converts an object of class 'kasc' into an object
     of class 'SpatialPixelsDataFrame'.

      'asc2spixdf' converts an object of class 'asc' into an object of
     class 'SpatialGridDataFrame'.

      'spixdf2kasc' converts an object of class
     'SpatialPixelsDataFrame' or 'SpatialGridDataFrame' into an object
     of class 'asc' or 'kasc'.

      'area2sr' converts an object of class 'area' into an object of
     class 'SpatialRings'.

      'sr2area' converts an object of class 'SpatialRings' or
     'SpatialRingsDataFrame' into anobject of class 'area'.

      'attsr2area' gets the data attribute of an object of class
     'SpatialRingsDataFrame' and stores is into a data frame.

      'traj2spdf' converts an object of class 'traj' into an object of
     class 'SpatialPointsDataFrame'.

      'traj2sldf' converts an object of class 'traj' into an object of
     class 'SpatialLinesDataFrame'.

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

     kasc2spixdf(ka)
     asc2spixdf(a)
     spixdf2kasc(sg)
     area2sr(ar)
     sr2area(sr)
     attsr2area(srdf)
     traj2spdf(tr)
     traj2sldf(tr, byid = FALSE)

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

      ka: an object of class 'kasc'.

       a: an object of class 'asc'.

      sg: an object of class 'SpatialPixelsDataFrame' or
          'SpatialGridDataFrame'.

      ar: an object of class 'area'.

      sr: an object of class 'SpatialRings' or 'SpatialRingsDataFrame'.

    srdf: an object of class 'SpatialRingsDataFrame'.

      tr: an object of class 'traj'.

    byid: logical.  If 'TRUE', one objects of class 'Slines' correspond
          to one animal.  if 'FALSE', one object of class 'Slines'
          correspond to one burst.

_D_e_t_a_i_l_s:

     We describe here more in detail the functions 'sr2area' and
     'attsr2area'.  Objects of class 'area' do not deal with holes in
     the polygons, whereas the objects of class 'SpatialRings' do. 
     Therefore, when holes are present in the 'SpatialRings' object
     passed as argument, the function 'sr2area' ignore them and returns
     only the external contour of the polygon (though a warning is
     returned, see example).

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

     Clment Calenge calenge@biomserv.univ-lyon1.fr

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

     'import.asc' for information on objects of class 'asc', 'as.kasc'
     for info on objects of class 'kasc', 'as.area' for info on objects
     of class 'area', 'as.traj' for objects of class 'traj'.

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

     ## Not run: 
     if (require(sp) {

     #########################################
     ##
     ## Conversion kasc -> SpatialPixelsDataFrame
     ##

     data(puechabon)
     toto <- kasc2spixdf(puechabon$kasc)
     image(toto)
     summary(toto)

     #### and conversely
     toto <- spixdf2kasc(toto)
     image(toto)
     hist(toto)

     data(meuse.grid)
     m <- SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")],
                                data = meuse.grid)
     i <- spixdf2kasc(m)
     image(i)

     ### conversion asc -> SpatialPixelsDataFrame
     cuicui <- asc2spixdf(getkasc(toto,1))
     image(cuicui)

     #########################################
     ##
     ## Conversion area -> SpatialRings
     ##

     data(elec88)
     ar <- as.area(elec88$area)
     plot(ar)
     toto <- area2sr(ar)
     plot(toto)

     #########################################
     ##
     ## Conversion SpatialRings -> area
     ##

     ## First create an object of class "SpatialRingsDataFrame"
     data(ncshp)
     nc1 <- as.SpatialRings.Shapes(nc.shp$Shapes, as.character(nc.shp$att.data$FIPS))
     plotSpatialRings(nc1)
     df <- nc.shp$att.data
     rownames(df) <- as.character(nc.shp$att.data$FIPS)
     ncSRDF <- SpatialRingsDataFrame(nc1, df)

     ## and then conversion:
     coincoin <- sr2area(ncSRDF)
     ## please note the warnings

     plot(coincoin)
     ## gets the attributes
     haha <- attsr2area(ncSRDF)
     area.plot(coincoin, values = df$SID74/df$BIR74)

     #########################################
     ##
     ## Conversion traj -> SpatialPointsDataFrame
     ##

     data(puechcirc)
     plot(puechcirc)

     toto <- traj2spdf(puechcirc)
     plot(toto)

     #########################################
     ##
     ## Conversion traj -> SpatialLinesDataFrame
     ##

     data(puechcirc)
     plot(puechcirc)

     toto <- traj2sldf(puechcirc)
     plot(toto)

     }
     ## End(Not run)

