I want to calculate % forest cover, % pastures and % crop land for multiple points within my study area. These points are camera traps. I have a raster layer with land use. Could anybody tell me the best way to do this in GQIS?
Calculating forest cover for specific points in QGIS requires a two-step process since a single point has no area.
Buffer the Points: Create a buffer (a defined circular area) around each point. The size of the buffer determines the area you'll be analysing.
Use Zonal Statistics: Use the Zonal Statistics tool with a raster layer that identifies forest areas. This tool will calculate the number of "forest" pixels within each buffer.
Once you have the count of forest pixels, you can use the Field Calculator to determine the percentage of forest cover within each buffer using a simple formula:
(Number of Forest Pixels * Pixel Area) / Total Buffer Area * 100
The most efficient way in QGIS is to create a buffer around each point and then use the Zonal Histogram tool.
This process calculates the exact number of pixels for each land cover type within a defined radius of your points, which you can then easily convert to percentages.
Data preparations:
Load Layers: Add both your camera trap points (vector layer) and your land use map (raster layer) to your QGIS project.
Check CRS: Ensure both layers are in the same projected Coordinate Reference System (CRS), like a UTM zone.
Raster Values: Your land use raster should have integer values that represent distinct categories (e.g., 1 = Forest, 2 = Pasture, 10 = Cropland).
Step 1: Create Buffers Around Your Points
First, you need to define the analysis area around each camera trap. A circular buffer is the standard method.
Go to the main menu and select Vector -> Geoprocessing Tools -> Buffer.
In the Buffer window: Input layer: Select your camera trap points layer. Distance: This is the radius of your analysis circle. For example, enter 500 for a 500-meter radius. The unit depends on your layer's CRS. Output layer: Choose where to save the new buffer layer. It's good practice to save it as a file rather than a temporary layer.
Click Run. You will now have a new polygon layer, with a circle around each of your original points.
Step 2: Calculate Pixel Counts with Zonal Histogram
This is the core step. The Zonal Histogram tool counts the number of pixels for each unique value in your raster layer that falls within each buffer polygon.
Open the Processing Toolbox panel (View -> Panels -> Processing Toolbox).
In the toolbox's search bar, type zonal histogram.
Double-click the Zonal Histogram tool to open it.
In the Zonal Histogram window: Input layer (Zones): Select your newly created buffer layer. Raster Layer: Select your land use raster layer. Raster band: Band 1 (unless your raster has multiple bands). Histogram column prefix: Leave this as HISTO_. The output columns will be named this prefix followed by the raster value (e.g., HISTO_1, HISTO_2, HISTO_10). Output Layer: Choose a location to save the results. This will be a copy of your buffer layer but with new attribute columns containing the pixel counts.
Click Run.
Step 3: Calculate Percentages with Field Calculator
Your output layer from the previous step now has the raw pixel counts for each land cover type. The final step is to convert these counts into percentages.
Open the Attribute Table of the output layer from Step 2 (right-click the layer and select "Open Attribute Table").
You will see columns like HISTO_1, HISTO_2, etc. These contain the number of pixels for each land cover class.
Click the Open field calculator button (the abacus icon 🧮).
First, you need to create a field for the total number of pixels within each buffer. Output field name: total_pixels Output field type: Decimal number (real) Expression: Add up all your histogram columns. For example, if your classes are 1 (Forest), 2 (Pasture), and 10 (Cropland), the expression would be:"HISTO_1" + "HISTO_2" + "HISTO_10" Click OK.
Now, create a new field for the percentage of forest. Open the Field Calculator again. Output field name: pct_forest Output field type: Decimal number (real) Expression: Divide the forest pixel count by the total pixel count and multiply by 100.("HISTO_1" / "total_pixels") * 100 Click OK.
Repeat step 5 for your other land cover types (pastures, cropland, etc.), changing the output field name and the histogram column in the formula accordingly.
You will have an attribute table where each row represents a camera trap location, and the columns show the percentage of each land cover type within your specified buffer distance.