polyfile               package:gpclib               R Documentation

_R_e_a_d/_W_r_i_t_e _p_o_l_y_g_o_n _d_a_t_a

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

     Read/Write polygon and contour information from/to a text file.

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

     read.polyfile(filename, nohole = TRUE)
     write.polyfile(poly, filename = "GPCpoly.txt")

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

filename: the name of the file (a character string) from/to which data
          should be read/written.

  nohole: Is this a polygon without holes?

    poly: an object of class '"gpc.poly"'

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

     The text file representation of a polygon is of the following
     format:

     <number of contours>
      <number of points in first contour>
      x1  y1
      x2  y2
      ...
      <number of points in second contour>
      x1  y1
      x2  y2
      ...

     For example, a data file for a polygon with 2 contours (a
     four-sided object and a triangle) might look like:

     2
      4
      1.0 1.0
      1.0 2.0
      3.4 3.21
      10 11.2
      3
      21.0 11.2
      22.3 99.2
      4.5 5.4

     The vertices of the polygon can be ordered either clockwise or
     counter-clockwise.

     If a polygon has contours which are holes, then the format is
     slightly different.  Basically, a flag is set to indicate that a
     particular contour is a hole.  The format is

     <number of contours>
      <number of points in first contour>
      <hole flag>
      x1  y1
      x2  y2
      ...
      <number of points in second contour>
      <hole flag>
      x1  y1
      x2  y2
      ...

     The hole flag is either 1 to indicate a hole, or 0 for a regular
     contour.  For example, a four-sided polygon with a triangular hole
     would be written as:

     2
      3
      1
      4.0   4.0
      6.0   5.0
      5.0   6.0
      4
      0
      2.0   1.0
      8.0   2.0
      7.0   9.0
      1.0   7.0

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

     If 'nohole' is 'TRUE' (the default) 'read.polyfile' returns an 
     object of class '"gpc.poly.nohole"'.  This object has the hole
     flag set to 'FALSE' for all contours.  If 'nohole' is 'FALSE',
     then an object of class '"gpc.poly"' is returned.

     'write.polyfile' does not return anything useful.

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

     Roger D. Peng

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

     'gpc.poly-class', 'gpc.poly.nohole-class'

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

     ## None right now.

