Learn R Programming

StratigrapheR (version 1.3.1)

octashift: Shifts the order of polygon points

Description

Shifts the order of polygon points based on octagon-like reference

Usage

octashift(x, y, i, pos, clockwise = NA)

Value

a data frame with $x, $y and $i of the polygons as columns

Arguments

x, y

the coordinates of the polygons

i

the identification of the polygons if there are multiple ones

pos

an integer from 1 to 8 identifying a points, based on the formalism of the octapos function

clockwise

whether to have the points in the polygon be ordered clockwise (T), counterclockwise (F). If NA (which is the default), this will not be addressed

Examples

Run this code
xy <- c(-3,-4,-3,0,-1,-2,-1,0,1,2,1,3,4,5,4,3)
dt <- c(1,1.5,2,1,1,1.5,2,2,1,1.5,2,1,1,1.5,2,2)
id <- c(rep("B1",3), rep("B2",5), rep("B3",3), rep("B4",5))

out <- octashift(xy, dt, id, pos = 3, clockwise = TRUE)

par(mfrow = c(2,1))

plot.new()
plot.window(xlim = range(xy) + c(-1, 1), ylim = range(dt) + 0.5 * c(-1, 1))

axis(1)
axis(2)

multilines(i = id, x = xy, y = dt)

plot.new()
plot.window(xlim = range(xy) + c(-1, 1), ylim = range(dt) + 0.5 * c(-1, 1))

axis(1)
axis(2)

multilines(i = out$i, x = out$x, y = out$y)

Run the code above in your browser using DataLab