Extract a rectangular perimeter
rectPERIM(x, y = 1, pct = 0)
x
: x values or a list include x, y membersy
: y values, if missing, x must be a listpct
: Percent expansion, based on range of x and y values. If pct>1 it is divided by 100 to get a fractional percent expansion.The rectangular box will be expanded based on the percent pct.
list of x, y values from lower left corner counter clockwise around perimeter
Jonathan M. Leesjonathan.lees@unc.edu
getGEOperim
fx =rnorm(20) fy = rnorm(20) plot(fx, fy, xlim=c(-4, 4), ylim=c(-4,4)) rp = rectPERIM(fx, fy) polygon(rp) text(rp, labels=1:4, pos=c(1,1,3,3), font=2, cex=2) fx2 =rnorm(20, m=-1) fy2 = rnorm(20, m=-1) Fx = list(x=fx2, y=fy2) points(Fx$x, Fx$y, col='red') rp = rectPERIM(Fx) polygon(rp, border='red') ######## try expanding the perim: plot(fx, fy, xlim=c(-4, 4), ylim=c(-4,4), asp=1) rp = rectPERIM(fx, fy, pct=0.1) polygon(rp) rp = rectPERIM(fx, fy, pct=0.2) polygon(rp)
Useful links