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.
I think Con has been mentioned to you before, which can be done in the raster calculator of with the Con tool. Just query the raster for values equal to -1, assign those locations/values some other value, then keep the remaining values intact.
The exact syntax depends on which approach you are using, in pseudo code,
'raster' == -1, 'value if true', 'value if 'false'
'raster' == -1, -88, 'raster'
But as you can see, there are different values that -1 has to be switched with. The way you stated all -1 values will be replaced to the true statement and it's not what I want here.
I am not sure what you want for the nearest value
1 2 3
4 -1 -9999
7 8 9
3 can be don't by producing a mean raster, then using its value in the Con statement
'raster' == -1, 'mean_raster', raster in pseudo code
1, 2, 5 and 6 can be done with numpy
Yes, I would say the number one. Or if it is possible do the same thing as the Majority Filter Tool does but just for the -1 values.
use resampling with nearest neighbor.... there should be no new values introduced to the raster
if there are, stop
you should be done.
As an alternative, arrays can be used to simplify this if you have too many classes to deal with in a simple con statement or multiple nested boolean or's and/or and's
ps for resampling, use nearest neighbour or majority ... if you don't want your values to change, then you wouldn't have this problem Resample—Help | ArcGIS for Desktop
and if it is a float raster you are trying to resample, scale up by a factor of 10, take the integer of that, do the NN or majority resample, convert back to float
I used Resample Tool with nearest neighboor. The problem is I am trying to create new rows and columns to match the other raster. I have a 516 x 510 raster and I am trying to convert it to 1024x1024. Some values will be created and I have no control about it.
Is your raster is DEM?