AnsweredAssumed Answered

Change pixel values using the nearest neighbor value

Question asked by alex_braian on Jul 14, 2016
Latest reply on Jul 14, 2016 by abdallah_91@yahoo.com

Hello Everyone. I am having some trouble when I convert the raster properties because I am using the resample tool to change the resolution and the number of columns/rows to match with another raster, so I can combine them after the conversion. However, after using the tool, the raster doesn't match, which was expected because some values were created to change its resolution.

 

I came up with the following idea, I can Extract by Mask using the original file as mask and those values I don't want in my output I can try to change them getting the nearest neighbor value; however, I didn't find one tool that could do that for me. In addition, I tried Majority Filter, but it changes values that I don't want to change and also do not eliminate all unwanted values.

 


The grid below is just an example of my whole grid and what I am trying to do is substitute the -1 values with the nearest value except for the -9999 (NoData value)

 

 

 0.48 1.16 1.9 
0.28 1.02 1.53 
1.82 2.08 1.86 
0.16 2.42 2.14 
 2.41 2.43 2.1 
 2.45 2.44 2.43
6 2.55 2.45 2.4
2.59 2.59 2.56 
2.61 -1 -1 -9999
67 2.66 2.63 -1
2.79 2.79 2.79 
 2.85 2.83 2.82
0.88 2.84 -1 -1 

 

Any help is welcome and I have some knowledge with python too, if that would be that only option.

 

 

Thank you.

Outcomes