Learn R Programming

RSurvey (version 0.5.0)

polyTranslate: Translate Alternate Polygon File Format

Description

Reads polygon information from a ASCII file and adds vertices.

Usage

polyTranslate(file = NULL, dl = NULL)

Arguments

file
character; the name of the file which the data are to be read from. Alternatively, file can be a readable text-mode connection (optional).
dl
numeric; the maximum distance between polygon vertices; if NULL, no vertices are added.

Value

  • Returns a polygon of class gpc.poly.

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/PolygonAlternativeFormat.txt", package = "RSurvey")

con <- file(f, open = "r", encoding = "latin1")
ply <- polyTranslate(file = con)
pts <- get.pts(ply)
plot(ply)
for(i in 1:length(pts)) points(get.pts(ply)[[i]], col = "red")
close(con)

con <- file(f, open = "r", encoding = "latin1")
ply <- polyTranslate(file = con, dl = 1)
pts <- get.pts(ply)
for(i in 1:length(pts)) points(get.pts(ply)[[i]], col = "green")
close(con)

Run the code above in your browser using DataLab