How to assign to each pixel of a raster value of the biggest difference between values of all pixels around it to a mask on 1 picture (red pixels and everything that after them is not included, black pixels and everything that inside of them are included).
Here is an example of how it works on 2 picture. I wrote such pseudo-code with Python assuming that as input i get list with all closest pixels using as a Central pixel lower left a corner 2 pictures of the. I do not understand how this can be transformed into a script for QGIS or Raster Calculator.
I tried in R the neighbour's module, but every time I set a radius greater than or less than 3 it throws an error. Also, you can take pixels not only for this mask but also for a circular radius of 128 meters. (For images of Landsat with a spatial resolution of 30x30). With what should I implement this?
near_pixels_list = [4,
1, 3, 3, 5,
8, 4, 1, 3,
0, 0, 7, 7,
4, 3, 0, 2, 1]
center_pixel = 4
output = max(list(map(lambda x: max(center_pixel, x) - min(center_pixel, x), near_pixels_list)))
Answer
I think you first need Maximum and Minimum values from focal statistics in the 128m-radius window.
Only tool which supports circle window (as far as I know) is SAGA Residual analysis tool in Processing Toolbox > SAGA > Geostatistics
. Settings are:
- Search Mode:
[1] circle
- Radius (Cells) :
4
( 4 * 30m = 120m, which is equivalent to your 128m radius) - Include Center Cell: Leave it on (it does not work... and has no effect on the result)
- Distance Weighting:
[0] no distance weighting
You will have many outputs, but you just need Maximum and Minimum. Then subtract Minimum from Maximum raster to get the desired result.
No comments:
Post a Comment