Topic: Species Area

Topic Description:

Functions for calculating species-area curves based on square or rectangular quadrats, using standard R Analytical Tables.



File: speciesarea/spparea.r

View File Source Download File No help file available

Function: selectrandomquad

Function Description: selectrandomquad

Draws rectangular quadrats in a plot at random. Returns a dataframe of coordinates defining the corners of all the quadrats. The variable size is a vector of dimensions; shape allows a rectangle to be drawn; rep is the number of replicated random quadrats per dimension submitted.

Quadrats are chosen simply: a point is chosen by randomly drawing one x and one y coordinates to serve as the lower-left corner. The x is chosen from a uniform distribution between 0 and plotdim[1]-size; y is chosen similarly.

All 3 algorithms for creating random quadrats under sample the plot corners. See selectrandomquad2() and selectrandomquad3(), alternative intended to overcome the bias (but neither does).

Function Arguments:

ArgumentDefault Value
size
shape
rep
plotdimc(1000,500)
graphitFALSE

Arguments Description:

  • censdata: one R Analytical Table, either full or stem
  • size: a vector of quadrat sizes, referring to the x-dimension of a rectangular quadrat
  • shape: the ratio of y to x dimensions of the rectangles; rectdim=1 (the default) for squares
  • plotdim: the x and y dimensions of the entire plot
  • rep: the number of random quadrats to create, of each size
  • graphit: whether to graph the locations of the chosen quadrats on a plot map


    Function Source:

    selectrandomquad=function(size,shape,rep,plotdim=c(1000,500),graphit=FALSE)
    {
    noquad=length(size)
    allsize.x=rep(size,each=rep)
    allsize.y=rep(size*shape,each=rep)
    total=length(allsize.x)

    xlo=runif(total,min=0,max=plotdim[1]-allsize.x)
    ylo=runif(total,min=0,max=plotdim[2]-allsize.y)
    xhi=xlo+allsize.x
    yhi=ylo+allsize.y

    result=data.frame(xlo,ylo,xhi,yhi)
    if(graphit) graph.quadrats(result)

    return(data.frame(xlo,ylo,xhi,yhi,area=(allsize.x*allsize.y)/1e4))
    }