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.

5
  • Related gis.stackexchange.com/questions/74592/… ? Commented Aug 15, 2023 at 3:35
  • 1
    In what format do you want them? As eight columns in the point layer?
    – Bera
    Commented Aug 15, 2023 at 5:26
  • Do you want the sum of surrounding pixels? Average?
    – Joe Be
    Commented Aug 15, 2023 at 8: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? [docs.qgis.org/3.28/en/docs/user_manual/working_with_raster/… Commented Aug 15, 2023 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. Commented Aug 15, 2023 at 22:21

1 Answer 1

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.

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.