distance: Distance from one quadrat to a second quadrat.

Description Usage Arguments Value Examples

Description

Calculates the distance from one quadrat to a second quadrat, where quadrats are designated by their indices, as created by gxgy.to.index. The two quadrats can be vectors, but must be of the same length (or one of the two can be atomic).

Usage

1
distance(quad1, quad2, gridsize = 20, plotdim = c(1000, 500))

Arguments

gridsize

Side of the square quadrate.

plotdim

The x and y dimensions of the plot.

Value

A vector of distances same length as input vectors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
bad1=pt1$gx<0 | pt1$gy<0 
bad2=pt2$gx<0 | pt2$gy<0
xdist=pt1$gx-pt2$gx
ydist=pt1$gy-pt2$gy
dist=sqrt(xdist^2+ydist^2)
if(length(pt1)==1 & bad1==T) dist=rep(-1,length(pt2))
else if(length(pt2)==1 & bad2==T) dist=rep(-1,length(pt1)) 
dist[bad1]=(-1)
dist[bad2]=(-1)
return(dist)

## End(Not run)

forestgeo/ctfs documentation built on May 3, 2019, 6:44 p.m.