QGIS Script · Python
Buffer Active Layer
Expands every feature in the active layer outward by a configurable radius in metres. Place points at tree trunk locations and run this script to get circular crown polygons — ready to feed into the Tree Height Extractor and Canopy NDVI Calculator. Also works on polygon layers for boundary buffer zones. Automatically picks the right UTM zone for accurate metric distances anywhere in the world.
What you get
buffer_active_layer.pyWhat it does
Points → crown polygons
Place points at tree trunk locations — manually in QGIS or from a GPS field collection. Run with your estimated crown radius and each point becomes a circular polygon. These polygons define the spatial extent per tree and serve as the vector input for Tree Height Extractor and Canopy NDVI Calculator.
Polygons → expanded outlines
Each polygon boundary is pushed outward by the radius with rounded corners. Useful for buffer zones around field boundaries, exclusion rings around structures, or expanding estate polygons.
Accurate metric buffer worldwide
Automatically detects the correct UTM zone from the layer's centroid when the CRS is geographic (degrees). If the layer is already in a projected metric CRS, the buffer is applied directly with no reprojection.
Any vector format, any CRS
Works with GeoJSON, shapefiles, GeoPackages, and any QGIS-supported format. Original attributes are preserved on every output feature.
Tree annotation workflow: GPS points → crown polygons → height + NDVI per tree
- 1. Collect or place a point layer at trunk locations. Run this script with your crown radius → one circular polygon per tree.
- 2. Run Canopy Mask Generator on your multispectral raster → binary raster that marks only vegetated pixels.
- 3. Run Canopy NDVI Calculator — takes the crown polygons (where to sample) + canopy mask (only vegetated pixels) → adds
NDVI_medianper tree. - 4. Run Tree Height Extractor on the same polygon layer → adds
height_mfrom DSM/DTM.
How to use it
- 1
Load your vector layer and click it to make it the active layer in the Layers panel.
- 2
Open Plugins → Python Console → Show Editor.
- 3
Paste the script. At the bottom, set
buffer_radiusin metres. - 4
Click Run.
Requirements
- QGIS 3.28 or newer
- QGIS processing framework — bundled
- Any active point or polygon vector layer
Also in the GIS Utilities Pack
Get all 4 GIS utility scripts for $49 — save $29 vs buying individually.