0

I can extract values from raster by "raster to points" tool but I need to find values of surrounding eight pixels to the central pixel. And I need to do this for all pixels so I could put in a formula and create a new raster layer. However, I don't understand how to extract pixel values from the surrounding pixels in QGIS.

Vince
  • 20,017
  • 15
  • 45
  • 64
  • Related https://gis.stackexchange.com/questions/74592/seeking-qgis-equivalent-to-focal-statistics-of-arcgis-spatial-analyst ? – Michael Stimson Aug 15 '23 at 03:35
  • 1
    In what format do you want them? As eight columns in the point layer? – BERA Aug 15 '23 at 05:26
  • Do you want the sum of surrounding pixels? Average? – Joe Be Aug 15 '23 at 08:26
  • Isn't the Raster Calculator exactly what you are looking for? Extracting pixel values and putting them in a formula and creating a new raster? [https://docs.qgis.org/3.28/en/docs/user_manual/working_with_raster/raster_analysis.html#raster-calculator] – Jochen Schwarze Aug 15 '23 at 12:17
  • I want the average value of eight surrounding pixels for each pixel. Raster calculator does give me values but how would I know the surrounding pixels from the sheet? I want them in a format that can copy pasted, So could be in point file with attributes or in a table format. I just don't know an efficient way to extract them in the way I want. – Zaara Kidwai Aug 15 '23 at 22:21

1 Answers1

0

If you're just looking to put the result into a new raster layer, you can do that in one step using (for example) r.neighbors, from the Processing Toolbox.

enter image description here

Use the Neighborhood operation "average" with a weights file of:

1 1 1 
1 0 1
1 1 1

That will compute the average of the 8 cells surrounding each cell and store it in a new raster:

enter image description here -> enter image description here

If you want to do a different operation than the one you've described, you can use a different weights file.

Tom Brennan
  • 4,787
  • 6
  • 26