coerce op to integer
[gpclib.git] / man / polyfile.Rd
blob670b98a5519375773ea7abf3fc7e9cfc7e52fc84
1 \name{polyfile}
2 \alias{polyfile}
3 \alias{read.polyfile}
4 \alias{write.polyfile}
6 \title{Read/Write polygon data}
7 \description{
8   Read/Write polygon and contour information from/to a text file.  
10 \usage{
11 read.polyfile(filename, nohole = TRUE)
12 write.polyfile(poly, filename = "GPCpoly.txt")
14 \arguments{
15   \item{filename}{the name of the file (a character string) from/to which
16     data should be read/written.}
17   \item{nohole}{Is this a polygon without holes?}
18   \item{poly}{an object of class \code{"gpc.poly"}}
20 \details{
21   The text file representation of a polygon is of the following format:
23   <number of contours>\cr
24   <number of points in first contour>\cr
25   x1  y1\cr
26   x2  y2\cr
27   ...\cr
28   <number of points in second contour>\cr
29   x1  y1\cr
30   x2  y2\cr
31   ...\cr
33   For example, a data file for a polygon with 2 contours (a four-sided
34   object and a triangle) might look like:
36   2\cr
37   4\cr
38   1.0 1.0\cr
39   1.0 2.0\cr
40   3.4 3.21\cr
41   10 11.2\cr
42   3\cr
43   21.0 11.2\cr
44   22.3 99.2\cr
45   4.5 5.4\cr
47   The vertices of the polygon can be ordered either clockwise or
48   counter-clockwise.
50   If a polygon has contours which are holes, then the format is slightly
51   different.  Basically, a flag is set to indicate that a particular
52   contour is a hole.  The format is
54   <number of contours>\cr
55   <number of points in first contour>\cr
56   <hole flag>\cr
57   x1  y1\cr
58   x2  y2\cr
59   ...\cr
60   <number of points in second contour>\cr
61   <hole flag>\cr
62   x1  y1\cr
63   x2  y2\cr
64   ...\cr
66   The hole flag is either 1 to indicate a hole, or 0 for a regular
67   contour.  For example, a four-sided polygon with a triangular hole
68   would be written as:
70   2\cr
71   3\cr
72   1\cr
73   4.0   4.0\cr
74   6.0   5.0\cr
75   5.0   6.0\cr
76   4\cr
77   0\cr
78   2.0   1.0\cr
79   8.0   2.0\cr
80   7.0   9.0\cr
81   1.0   7.0\cr
84 \value{
85   If \code{nohole} is \code{TRUE} (the default) \code{read.polyfile}
86   returns an  object of class \code{"gpc.poly.nohole"}.  This object has
87   the hole flag set to \code{FALSE} for all contours.  If \code{nohole} is
88   \code{FALSE}, then an object of class \code{"gpc.poly"} is
89   returned.
90   
91   \code{write.polyfile} does not return anything useful.
93 \author{Roger D. Peng}
95 \seealso{
96   \code{\link{gpc.poly-class}}, \code{\link{gpc.poly.nohole-class}}
99 \examples{
100 ## None right now.
102 \keyword{IO}