polyConstruct {RSurvey} | R Documentation |
Read polygon information from a text file.
polyConstruct(file = NULL, dl = NULL)
file |
either a character string naming a file or a connection. |
dl |
the maximum distance between polygon vertices.
If NULL , no vertices are added. |
The tab delineated text file, ‘*.txt’, adheres to the following 4 column format:
[,1] | integer | an index for vertices within a polygon. |
[,2] | numeric | vertex location in the x-direction. |
[,3] | numeric | vertex location in the y-direction. |
[,4] | integer | a code, see Details. |
The code
argument is used to identify polygons and vertex types.
Letting code = 0
for two sequential vertices will override dl
and
prevent additional vertices from being added between them.
A code < 2
indicates a vertex point is within the outer polygon.
Inner polygons or holes are specified with a code > 1
.
A polygon of class gpc.poly-class
.
Fisher, J. C.
polyfile
f <- system.file("RSurvey-ex/confluence-poly.txt", package = "RSurvey") con <- file(f, open = "r", encoding = "latin1") ply <- polyConstruct(file = con) pts <- get.pts(ply) plot(ply) for(i in 1:length(pts)) points(get.pts(ply)[[i]], col = "red") con <- file(f, open = "r", encoding = "latin1") ply <- polyConstruct(file = con, dl = 1) pts <- get.pts(ply) for(i in 1:length(pts)) points(get.pts(ply)[[i]], col = "green")