readShapeLines           package:maptools           R Documentation

_R_e_a_d _a_r_c _s_h_a_p_e _f_i_l_e_s _i_n_t_o _S_p_a_t_i_a_l_L_i_n_e_s_D_a_t_a_F_r_a_m_e _o_b_j_e_c_t_s

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

     The 'readShapeLines' function reads data from an arc/line
     shapefile into a 'SpatialLinesDataFrame' object; the shapefile may
     be of type polygon, but for just plotting for example coastlines,
     a SpatialLines object is sufficient. The 'writeLinesShape'
     function writes data from a 'SpatialLinesDataFrame' object to a
     shapefile.

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

     readShapeLines(fn, proj4string=CRS(as.character(NA)), verbose=FALSE,
      repair=FALSE)
     writeLinesShape(x, fn, factor2char = TRUE, max_nchar=254)

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

      fn: shapefile layer name, when writing omitting the extensions
          *.shp, *.shx and *.dbf, which are added in the function

proj4string: Object of class 'CRS'; holding a valid proj4 string

 verbose: default TRUE - report type of shapefile and number of shapes

  repair: default FALSE: some shapefiles provided by Geolytics Inc.
          have values of object sizes stored in the *.shx index file
          that are eight bytes too large, leading the function to try
          to read past the end of file. If repair=TRUE, an attempt is
          made to repair the internal values, permitting such files to
          be read.

       x: a 'SpatialLinesDataFrame' object

factor2char: logical, default TRUE, convert factor columns to character

max_nchar: default 254, may be set to a higher limit and passed through
          to the DBF writer, please see Details in 'write.dbf'

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

     The shpID values of the shapefile will be used as 'Lines' ID
     values; when writing shapefiles, the object data slot rownames are
     added to the DBF file as column SL_ID.

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

     a SpatialLinesDataFrame object

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

     Roger Bivand

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

     xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
      proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
     plot(xx, col="blue")
     summary(xx)
     xxx <- xx[xx$LENGTH > 30000,]
     plot(xxx, col="red", add=TRUE)
     tmpfl <- paste(tempdir(), "xxline", sep="/")
     writeLinesShape(xxx, tmpfl)
     getinfo.shape(paste(tmpfl, ".shp", sep=""))
     axx <- readShapeLines(tmpfl, proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
     plot(xxx, col="black", lwd=4)
     plot(axx, col="yellow", lwd=1, add=TRUE)
     unlink(paste(tmpfl, ".*", sep=""))
     xx <- readShapeLines(system.file("shapes/sids.shp", package="maptools")[1],
      proj4string=CRS("+proj=longlat +datum=NAD27"))
     plot(xx, col="blue")

