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.
-
Related gis.stackexchange.com/questions/74592/… ?– Michael StimsonCommented Aug 15, 2023 at 3:35
-
1In what format do you want them? As eight columns in the point layer?– BeraCommented Aug 15, 2023 at 5:26
-
Do you want the sum of surrounding pixels? Average?– Joe BeCommented 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/…– Jochen SchwarzeCommented 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.– Zaara KidwaiCommented Aug 15, 2023 at 22:21
Add a comment
|
1 Answer
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.
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:
If you want to do a different operation than the one you've described, you can use a different weights file.