## Basal area per acre

Basal area per acre is the cross-section area of all the trees on an acre.

$$ba = \sum_{i=1}^{n} 0.005454154 * dbh_i^2 * w_i$$

where $ba$ is the basal are per acre, 0.005454154 is a constant, $dbh$ is the diameter at breast height in inches, and $w$ is the expansion factor that converts the sample tree to a per acre basis.

$$ba = \sum_{i=1}^{n} 0.00007854 * dbh_i^2 * w_i$$

where $ba$ is the basal are per hectare, 0.00007854 is a constant, $dbh$ is the diameter at breast height in centimeters, and $w$ is the expansion factor that converts the sample tree to a per hectare basis.

### Example

Imperial Units
dia = 8,6,8,5,4,6,7 in inches
weight = 10,10,10,10,10,10,10
unittype = "imperial"
Answer = 15.8 sq. feet per acre

Metric Units
dia = 8,6,8,5,4,6,7 in centimeters
weight = 25,25,25,25,25,25,25
unittype = "metric"
Answer = 0.56 sq. meters per hectare

### Code

#### Visual Basic

 
Function basalarea(dbh As Range, w As Range, Optional unittype As String = "imperial") As Double
' Function to calculate basal area per acre from diameter at breast height and expansion factor weights
' by David R. Larsen, Copyright October 10, 2012

If (unittype = "imperial") Then
For i = 1 To dbh.Height
basalarea = basalarea + 0.005454154 * dbh(i).Value ^ 2 * w(i).Value
Next i
ElseIf (unittype = "metric") Then
For i = 1 To dbh.Height
basalarea = basalarea + 0.00007854 * dbh(i).Value ^ 2 * w(i).Value
Next i
Else
basalarea = 0#
MsgBox ("Unknown unit type, options are: imperial or metric")
End If

End Function


Excel® Visual Basic Code

#### R Statistical Package Code

 
basalarea = function( dia, weight, unittype="imperial" )
{
# Function to calculate the basal area per unit area
# weight is the expansion factor to convert the sample area number to
# the unit area.
# By David R. Larsen, Copyright, October 9, 2012

if ( unittype == "imperial" ){
bat = 0.005454154 * dia ^ 2 * weight
}else if ( unittype == "metic" ){
bat = 0.00007854 * dia ^ 2 * weight
}else{
bat = rep( 0, length=length(dia) )
}
ba = sum(bat)
ba
}

R Statistical Package Code

#### Python Code

 
#!/usr/local/bin/python
# Function to calculate the basal area per acre
# from diameter and weight
# by David R. Larsen, October 11, 2012

def basalarea( dia=[], weight=[], unittype="imperial"):
idx = 1
value = 0
for d in dia:
if( unittype == "imperial" ):
value = value + 0.005454154 * d**2 * weight[idx]
elif( unittype == "metric"):
value = value + 0.00007854 * d**2 * weight[idx]
else:
print "Unknown unittype, options are imperial or metric"
return
idx = idx + 1
next
return value

print "basalarea =", basalarea(dia=[8,6,8,5,4,6,7],weight=[10,10,10,10,10,10,10] )
print "basalarea =", basalarea(dia=[8,6,8,5,4,6,7],weight=[10,10,10,10,10,10,10], unittype="imperial" )
print "basalarea =", basalarea(dia=[8,6,8,5,4,6,7],weight=[25,25,25,25,25,25,25], unittype="metric" )
print "basalarea =", basalarea([1], [1], "cunits")

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 the basal area per acre
// from diameter and weight
// by David R. Larsen, November 20, 2013

package main

import (
"fmt"
)

func basalarea(dia []float64, wt []float64, unittype string) (ba float64) {
cst := 0.005454154
if unittype == "metric" {
cst = 0.00007856
}

for i := range dia {
ba = ba + cst*dia[i]*dia[i]*wt[i]
}
return
}

func main() {
dia := []float64{8, 6, 8, 5, 4, 6, 7}
wt := []float64{10, 10, 10, 10, 10, 10, 10}
wt2 := []float64{25, 25, 25, 25, 25, 25, 25}
fmt.Println("basalarea imperial =", basalarea(dia, wt, "imperial"))
fmt.Println("basalarea metric =", basalarea(dia, wt2, "metric"))
}

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.