QGIS Script · Python
Tree Attribute Histograms
Reads height and NDVI_median from a polygon layer, groups by tree_type, and generates side-by-side distribution histograms for each species or variety group. Saves a PNG per group and displays each chart on screen.
What you get
plot_tree_attributes_histograms.pyWhat it does
Grouped by tree_type
Reads the tree_type field and generates a separate chart for each distinct value — one per species or variety group in your dataset.
Side-by-side histograms
Each chart shows height distribution on the left and NDVI_median distribution on the right, making cross-attribute comparison immediate.
PNG export
Each chart is saved as {tree_type}_distribution.png alongside the source layer file — ready to drop into a report or presentation.
Displayed on screen
Charts also pop up during the run so you can review them without opening the exported PNG.
How to use it
- 1
Ensure your polygon layer has
height,NDVI_median, andtree_typefields (generated by the tree height and NDVI scripts). - 2
Click the polygon layer to make it the active layer.
- 3
Open Plugins → Python Console → Show Editor.
- 4
Paste the script and click Run.
Requirements
- QGIS 3.28 or newer
- matplotlib — install via OSGeo4W Shell if not present
- Active polygon layer with height, NDVI_median, and tree_type fields
Also in the Vegetation & Field Analysis Pack
Get all 6 vegetation scripts for $40 — save $20 vs buying individually.