3

I have 50m (shape file) buffers around (shape file) data points. I have another layer with the raster of the vegetation (indicated by different colours) in that land. I can easily extract the raster data of the data points using the Point Sampling Tool, but I wanted to find out the percentage of vegetation types within each buffer, using the raster layer.

The drop down menu in the Point Sampling Tool for 'layer containing sampling points' doesn't let me choose the buffer layer. Is there a different tool/method I should use?

Image of buffer and raster layer

1
  • 1
    Zonal histogram works perfectly! Thank you! Sep 10, 2021 at 7:23

2 Answers 2

0

I will convert the raster file to polygon file and I will use intercept within buffer circles and polygons to calculate each percentage. Shapes must be in projected coordinates.

0

Starting with a simple polygon table with one id column. If you dont have a unique id column, create it using Field Calculator.

enter image description here

Execute Zonal Histogram, prefix pixelcount_. Each column will be named after the pixel value, and the value will be the number of pixels with that value: enter image description here

Modify (add any additional fields you want to keep in addition to id, and modify all the raster column names) and execute the SQL query:

WITH total AS (SELECT   id, pixelcount_2+pixelcount_42+pixelcount_53+
                        pixelcount_61+pixelcount_111+pixelcount_112+
                        pixelcount_113+pixelcount_114+pixelcount_115+
                        pixelcount_118+pixelcount_121+pixelcount_122+
                        pixelcount_123+pixelcount_124+pixelcount_125 AS tot
                        FROM zonal_histogram_output)
SELECT a.id, 
        100.0*pixelcount_2 /   b.tot AS prc_2,   100.0*pixelcount_42 / b.tot as prc_42,    100.0*pixelcount_2 / b.tot AS prc_53,
        100.0*pixelcount_61 /  b.tot AS prc_61,  100.0*pixelcount_111 / b.tot as prc_111,  100.0*pixelcount_112 / b.tot AS prc_112,
        100.0*pixelcount_113 / b.tot AS prc_113, 100.0*pixelcount_114 / b.tot as prc_114,  100.0*pixelcount_115 / b.tot AS prc_115,
        100.0*pixelcount_118 / b.tot as prc_118, 100.0*pixelcount_121 / b.tot as prc_121,  100.0*pixelcount_122 / b.tot AS prc_122,
        100.0*pixelcount_123 / b.tot AS prc_123, 100.0*pixelcount_124 / b.tot as prc_124 , 100.0*pixelcount_125 / b.tot AS prc_125,
        geometry

FROM input1 AS a
join total AS b
ON a.id = b.id

Result is a table where each column is the percentage of that pixels value: enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.