Learn R Programming

GEOmap (version 2.5-11)

rectPERIM: Extract a rectangular perimeter

Description

Extract a rectangular perimeter

Usage

rectPERIM(x, y = 1, pct = 0)

Value

list of x, y values from lower left corner counter clockwise around perimeter

Arguments

x

x values or a list include x, y members

y

y values, if missing, x must be a list

pct

Percent expansion, based on range of x and y values. If pct>1 it is divided by 100 to get a fractional percent expansion.

Author

Jonathan M. Lees<jonathan.lees@unc.edu>

Details

The rectangular box will be expanded based on the percent pct.

See Also

getGEOperim

Examples

Run this code

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)



Run the code above in your browser using DataLab