2025-08-19

Design Topic

Overview

The website is centered around Urban Tree Inventory and Carbon Sequestration assessment. The main objective is be to provide the user with an easy interface where to load their data, calculate the carbon sequestration estimate for a given tree, and finally display the trees on a web map.

Calculations

The calculation will be done with the below EPA formula:

\(CO_{2} = \frac{\pi*DBH^{2}*h*WD*CF}{4}\)

Where:

  • DBH (Diameter at Breast Height): Diameter in centimeters of the tree trunk measured at approximately 1.3 meters (4.5 feet) above ground level.
  • H (Height): Total height of the tree measured in meters.
  • WD (Wood Density): Measured in kg/m³, varies by tree species. Mass of wood per unit volume.
  • CF (Carbon Fraction): Standard value representing the proportion of carbon in wood. It is assumed that about 50% of the dry weight of wood is carbon, so the carbon fraction is 0.5.

Background Information

Urban Trees are key to residents well being. They are known for reducing harmful pollutants and mitigate summer air temperatures.

They also help offset the carbon footprint of a city.

Having a Urban Tree Inventory of private and public city trees is a great way to inform trends, get to know the carbon sequestered by the city, and also identifying areas lacking of trees.

Data - tree_inventory database

Table 1: Reference table

[1] tree_list:

  • tree_id: The unique identifier for the tree name (PRIMARY KEY)
  • common_name: The common name
  • species: The scientific name
  • type: Tye of wood (hardwood or conifer)
  • growth: Growth rate (Fast, Moderate, or Slow)
  • density: Wood density (float value)

Source: EPA

Table 2: Input table

[2] tree_records

  • record_id: The record unique identifier (PRIMARY KEY)
  • tree_id: The tree species unique identifier (FOREIGN KEY)
  • date: The record date
  • dbh: The diameter at breast height
  • height: The tree height
  • age: The tree age
  • carbon_storage: The carbon storage estimation
  • lat: Latitude
  • lon: Longitude

Table 3: View - Aggregation table

[3] tree_map (table view)

This table view brings together the data recorded by the user, and displays more information about the tree by joining tree_list and tree_records:

  • common_name: The tree common name, from tree_list
  • date: The inventory record date, from tree_record
  • dbh: From tree_record
  • height: From tree_record
  • density: From tree_list
  • type: From tree_list
  • carbon_storage: From tree_record
  • lat/lon: From tree_record

Website Structure

Home: Describes the purpopse of the website and welcomes the user

Tree Form: Allows the user to record the tree

Tree map: Display the trees recorded and allows the user to download the data

Code

PHP sample

The tables were created with SQL queries within PHP.

As an example, the map.php file:

<?php
require_once("db.php");
$ALL = array();
try {
    $sql = "select * from tree_map order by date";
    $result = mysqli_query($conn, $sql);
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        // Push the entire associative array as an object
        array_push($ALL, $row);
    }
    header('Content-Type: application/json');
    echo json_encode($ALL);
} catch (Exception $e) {
    echo $e->getMessage();
}
?>

SQL sample

Below the SQL query to create the tree_map table view:

CREATE VIEW `tree_map` AS 
SELECT 
`tree_list`.`common_name` AS `common_name`,
`tree_records`.`date` AS `date`,
`tree_records`.`dbh` AS `dbh`,
`tree_records`.`height` AS `height`,
`tree_list`.`density` AS `density`,
`tree_list`.`type` AS `type`,
`tree_records`.`carbon_storage` AS `carbon_storage`,
`tree_records`.`lat` AS `lat`,
`tree_records`.`lon` AS `lon` 
FROM (`tree_records` join `tree_list` 
      on((`tree_list`.`tree_id` = `tree_records`.`tree_id`)))

Conclusion

The website is functional and can store user data, quantify the carbon captured, display the data on the map, and allows the user to download the data.

Additional improvements can be done:

  • allowing the user to use non-metric units,
  • attaching pictures, and
  • creating their own personal account to store their trees.