Learn R Programming

RSurvey (version 0.4.5)

polyConstruct: Polygon Construction

Description

Read polygon information from a text file.

Usage

polyConstruct(file = NULL, dl = NULL)

Arguments

file
either a character string naming a file or a connection.
dl
the maximum distance between polygon vertices. If NULL, no vertices are added.

Value

  • A polygon of class gpc.poly-class.

format

The tab delineated text file, *.txt, adheres to the following 4 column format: lll{ [,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. }

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.

See Also

polyfile

Examples

Run this code
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")

Run the code above in your browser using DataLab