## Percent Stocking

In imperial units:

$$\%s = tpa * ( b_0 + b_1 * \bar{D} + b_2 * \bar{D}_q^2 )$$

where: $\%s$ is the percent stocking, $\bar{D}$ is the arithmetic mean in inches, $\bar{D}_q$ is the Quadratic Mean Diameter in inches, $ba$ is the basal area in square feet per acre, $tpa$ is the trees per acre, and 0.005454154 is a constant.

### Example

Imperial units
ba = 100 ft2/ac
tpa = 200
foresttype = "upland.oak"

ba = 50 ft2/ac
tpa = 100
foresttype = "northern.red.oak"

### Code

#### Visual Basic

 
Function percentStocking(ba As Single, tpa As Single, Optional foresttype As String = "upland.oak") As Double
' Function to calculate Percent Stocking from basal area per acre and trees per acre
' by David R. Larsen, Copyright November 16, 2012

dq = Math.Sqr((ba / tpa) / 0.005454154)
amd = (-0.259 + (0.973 * dq))
If (foresttype = "upland.oak") Then
percentStocking = (tpa * (-0.00507 + 0.01698 * amd + 0.00307 * dq ^ 2))
ElseIf (foresttype = "northern.red.oak") Then
percentStocking = (tpa * (0.02476 + 0.004182 * amd + 0.00267 * dq ^ 2))
ElseIf (foresttype = "sugar.maple") Then
percentStocking = (tpa * (-0.003082 + 0.006272 * amd + 0.00469 * dq ^ 2))
ElseIf (foresttype = "black.cherry") Then
percentStocking = (tpa * (0.02794 + 0.01545 * amd + 0.000871 * dq ^ 2))
ElseIf (foresttype = "red.maple") Then
percentStocking = (tpa * (-0.01798 + 0.02143 * amd + 0.001711 * dq ^ 2))
ElseIf (foresttype = "black.walnut") Then
percentStocking = (tpa * (0.01646 + 0.01347 * amd + 0.002757 * dq ^ 2))
ElseIf (foresttype = "shortleaf.pine") Then
percentStocking = (tpa * (0.008798 + 0.009435 * amd + 0.00253 * dq ^ 2))
ElseIf (foresttype = "cottonwood.silver.maple") Then
percentStocking = (tpa * (-0.0685724 + 0.0010125 * amd + 0.0023656 * dq ^ 2))
Else
percentStocking = 0#
MsgBox ("Unknown forest type, options are: upland.oak, northern.red.oak, sugar.maple, black.cherry, red.maple, black.walnut, shortleaf.pine, cottonwood.silver.maple")
End If
If (percentStocking < 0#) Then
percentStocking = 0#
End If

End Function


Excel® Visual Basic Code

#### R Statistical Package Code

 
percent.stocking = function( tpa, ba, b = c(-0.00507, 0.01698, 0.00317), adj=1 )
{
#
#  Routine to calculate the percent stocking from tpa and ba
#
# these equations have only been developed in imperial units.
#
#  by David Larsen, Copyright January 20, 1999
#
dia <- qmd( tpa=tpa, ba=ba )
amd <- -0.259+.973*dia
percent <- (tpa*(b[1]+b[2]*amd+b[3]*dia^2))
if( percent < 0.0 ) percent = 0.0
percent
}

qmd = function( ba, tpa, unittype="imperial" )
{
# Function to calculate the quadratic mean diameter from basal area and tree per acre
# by David R. Larsen, Copyright October 9, 2012

if (unittype == "imperial"){
qmd = sqrt((ba / tpa) / 0.005454154)
}else if (unitype == "metric"){
qmd = sqrt((ba / tpa) / 0.00007854)
}else{
qmd = 0
}
qmd
}

upland.oak <- c(-0.00507, 0.01698, 0.00317)
northern.red.oak <- c(-0.02476, 0.004182, 0.00267)
sugar.maple <- c(-0.003082, 0.006272, 0.00469)
black.cherry <- c(-0.002794, 0.01545, 0.000871)
red.maple <- c(-0.01798, 0.02143, 0.001711)
black.walnut <- c(0.01646, 0.01347, 0.002757)
shortleaf.pine <- c(0.008798, 0.009435, 0.00253)
R Statistical Package Code

#### Python Code

 
#!/usr/local/bin/python
#
# Function to calculate percent stocking
# from basal area per acre and tree per acre
#
# by David R. Larsen, November 16, 2012

import math

#
# Percent stocking has only been worked out for imperial measurements
#

def parameters(type="upland.oak"):
if( type == "upland.oak" ):
value = [-0.00507,0.01698,0.00307]
elif( type == "northern.red.oak" ):
value = [0.02476,0.006272,0.00469]
else:
value = [-0.00507,0.01698,0.00307]
return value

#
# qmd is a function to return the quadratic mean diameter
# given basal area per acre and trees per acre
#

def qmd( ba, tpa):
value = math.sqrt( ((ba/tpa)/0.005454154) )
return value
#
# percentStocking is a function that return the percent stocking using a Gingrich style tree area equation
#

def percentStocking( ba, tpa, type="upland.oak" ):
dia = qmd( ba, tpa )
amd = -0.259 + 0.973 * dia
b = parameters( type )
percent = (b[0] + b[1] * amd + b[2] * dia**2 ) * tpa
if( percent < 0.0 ):
percent = 0.0
return percent

# testing
print "      percent stocking( 55, 100, \"upland.oak\") = ", percentStocking( 55.0, 100.0, type="upland.oak")
print "     percent stocking( 100, 200, \"upland.oak\") = ", percentStocking( 100.0, 200.0, type="upland.oak")
print "percent stocking( 50, 100, \"northern.red.oak\") = ", percentStocking( 50.0, 100.0, type="northern.red.oak")
print "      percent stocking( 100, 50, \"upland.oak\") = ", percentStocking( 100.0, 50.0, type="upland.oak")
print "      percent stocking( 50, 400, \"upland.oak\") = ", percentStocking( 50.0, 400.0, type="upland.oak")

Python Code

Note the python file has a extra "txt" at the end to allow the files to be viewed in a web browser.

#### Go Code

 
// Function to calculate percent stocking
// from basal area  and tree per acre
// by David R. Larsen, September 12, 2013
package main

import (
"fmt"
"math"
"strings"
)

//  Percent stocking has only been worked out for imperial measurements

func parameters(group string) []float64 {
value := []float64{ -0.00507, 0.01698, 0.00307 }
if strings.Contains( group, "northern.red.oak" ) {
value = []float64{ 0.02476, 0.006272, 0.00469 }
}
return value
}

// Function to calculate a quadratic mean
func qmd(ba float64, tpa float64) float64 {
val := math.Sqrt( ((ba / tpa) / 0.005454154) )
return val
}

// percentStocking is a function that return the percent stocking
// using a Gingrich style tree area equation
func percentStocking(ba float64, tpa float64, group string) float64 {
var percent float64
dia := qmd( ba, tpa )
amd := -0.259 + 0.973 * dia
b := parameters( group )
percent = (b[0] + b[1] * amd + b[2] * math.Pow(dia, 2.0)) * tpa
if percent < 0.0 {
percent = 0.0
}
return percent
}

func main() {
fmt.Println("percent stocking( 55, 100, \"upland.oak\") = ", percentStocking(55.0, 100.0, "upland.oak"))
fmt.Println("percent stocking( 100, 200, \"upland.oak\") = ", percentStocking(100.0, 200.0, "upland.oak"))
fmt.Println("percent stocking( 50, 100, \"northern.red.oak\") = ", percentStocking(50.0, 100.0, "northern.red.oak"))
fmt.Println("percent stocking( 100, 50, \"upland.oak\") = ", percentStocking(100.0, 50.0, "upland.oak"))
fmt.Println("percent stocking( 50, 400, \"upland.oak\") = ", percentStocking(50.0, 400.0, "upland.oak"))

}


Run code in the Go Playground
Go Code

Note the go file has a extra "txt" at the end to allow the files to be viewed in a web browser.