Topic: CTFS Plot Maps
Topic Description:
Functions for maps of CTFS plot data. The file map.r has functions for tree distribution maps, including overlays of elevation contours. The file mapresponse.r has functions for creating color or contour maps of any numerical responses, based on the R functions image, contour, and filled.contour.
File: map/map.r
| View File Source | Download File | No help file available |
Function: map1species
Function Description: map1species
This does the mapping for a single species, called from map() but also useful on its own. With add=TRUE, points are added to an existing map. All other parameters are described with map().Function Arguments:
| Argument | Default Value |
|---|---|
| sppdata | |
| plotdim | c(1000,500) |
| xrange | c(0,plotdim[1]) |
| yrange | c(0,plotdim[2]) |
| color | "black" |
| bgcolor | "white" |
| symbol | 16 |
| size | rep(-1 |
| 3) | |
| cutoff | c(10,100,300,3000) |
| axisdiv | 100 |
| plotside | 4 |
| add | FALSE |
Function Source:
map1species=function(sppdata,plotdim=c(1000,500),xrange=c(0,plotdim[1]),yrange=c(0,plotdim[2]),color
="black",bgcolor="white",
xaxis=TRUE,yaxis=TRUE,symbol=16,size=rep(-1,3),cutoff=c(10,100,300,3000),axisdi
v=100,plotside=4,add=FALSE) {
xdim=diff(xrange)
ydim=diff(yrange)
aspect=xdim/ydim
nogrp=length(cutoff)-1
grp=matrix(FALSE,nrow=nogrp,ncol=dim(sppdata)[1])
if(size[1]<0) size=setsize(nogrp,length(sppdata$gx))
for(i in 1:nogrp) grp[i,]=(sppdata$dbh>=cutoff[i] & sppdata$dbh
if(add)
{
points(sppdata$gx[grp[1,]],sppdata$gy[grp[1,]],cex=size[1],col=color,pch=symbol)
if(nogrp>1)
for(i in 2:nogrp) points(sppdata$gx[grp[i,]],sppdata$gy[grp[i,]],cex=size[i],col=color,pch=sym
bol) return(0)
}
graphsize=c(plotside,plotside/aspect)
oldpar=par(pch=symbol,col=color,col.main="black",bg=bgcolor,pin=graphsize,col.axis="black")
plot(sppdata$gx[grp[1,]],sppdata$gy[grp[1,]],xlim=xrange,ylim=yrange,axes=F,xlab="",ylab="",cex=si
ze[1],col=color)
if(nogrp>1) for(i in 2:nogrp) points(sppdata$gx[grp[i,]],sppdata$gy[grp[i,]],cex=size[i],col=color
) # browser()
atx=c(seq(xrange[1],xrange[2]-.5,by=axisdiv),xrange[2])
aty=c(seq(yrange[1],yrange[2]-.5,by=axisdiv),yrange[2])
if(xaxis) axis(side=1,pos=xrange[1],at=atx,cex.axis=1.75)
if(yaxis) axis(side=2,pos=yrange[1],at=aty,cex.axis=1.75)
if(xaxis) axis(side=3,at=atx,labels=FALSE,pos=yrange[2])
if(yaxis) axis(side=4,at=aty,labels=FALSE,pos=xrange[2])
# par(oldpar)
# browser()
}