Your standard fare in raster world
Fill in some holes … 'buffer' a line... allocate space to stuff in space... identify unique regions
Fancy names. Nibble, Euclidean distance, Euclidean allocation, Regiongroup
---- (1) The task ----
Start with a raster or array. Fancy labels in the top left, some random-ish color scheme with values noted in the middle.
Now, zero ( 0 ) we will say is nodata. The other numbers represent some class value.
Fill in the 'gaps'... aka, nodata, with the value of a cell with data based on the closest distance. Euclidean, crow flies, for our purposes, but it need not be.
Go!
What did you get for cells A04, H01 and H02? What about cell D07 and H08?

---- (1) The reveal ----
Let's see how we did
A04 - 2 can't be 1 because the diagonal to '1' is 1.414*cell width, so 2 it is
H01 - 2 could have been a 2 or a 3, because both are 3 cells away from cells with values
H02 - 3 no brainer
D07 - 3 could have been 3 or 4, but 3 wins
H08 -3 3 is 2 cells away and 1 and 5 are a greater distance on an angle

---- (3) The distances ----
Pretty boring and obvious... but for completeness.

I don't do maps, but the dominant colors are 0 or root 2 as you can see from the spiffy ArcGIS Pro symbology tab.So no big surprises

---- (4) Allocation around linear features ----
Yes, that is possible too, sort of like a variable buffer, trade area, but currently just a simple Euclidean spatial allocation.

---- (5) The references ----
Euclidean distance
Euclidean Allocation
NumPy/SciPy/ plus Arcpy stuff solution is what I used
<SPAN class="keyword token">import</SPAN> sys
<SPAN class="keyword token">import</SPAN> numpy <SPAN class="keyword token">as</SPAN> np
<SPAN class="keyword token">from</SPAN> scipy <SPAN class="keyword token">import</SPAN> ndimage <SPAN class="keyword token">as</SPAN> nd
<SPAN class="keyword token">from</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>geoprocessing <SPAN class="keyword token">import</SPAN> env
<SPAN class="keyword token">from</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>arcobjects <SPAN class="keyword token">import</SPAN> Point
<SPAN class="keyword token">from</SPAN> arcgisscripting <SPAN class="keyword token">import</SPAN> NumPyArrayToRaster<SPAN class="punctuation token">,</SPAN> RasterToNumPyArray
env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">euclid_calc</SPAN><SPAN class="punctuation token">(</SPAN>a<SPAN class="punctuation token">,</SPAN> mask_vals<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> dist<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> alloc<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="string token">"""Calculate the euclidean distance and/or allocation
Parameters:
a : array
numpy float or integer array
mask_vals : number, list or tuple
If a single number is provided, a `mask` will be created using it. A
list or tuple of values can be used to provide multiple value masking.
dist : boolean
True, the distance of the closest non-masked value to the masked cell
alloc : boolean
True, the value of the closest non-masked value to the masked cell
"""</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="operator token">not</SPAN> dist<SPAN class="punctuation token">:</SPAN>
dist <SPAN class="operator token">=</SPAN> None
<SPAN class="keyword token">if</SPAN> <SPAN class="operator token">not</SPAN> alloc<SPAN class="punctuation token">:</SPAN>
alloc <SPAN class="operator token">=</SPAN> None
m <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>isin<SPAN class="punctuation token">(</SPAN>a<SPAN class="punctuation token">,</SPAN> mask_vals<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>astype<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'int'</SPAN><SPAN class="punctuation token">)</SPAN>
dist<SPAN class="punctuation token">,</SPAN> idx <SPAN class="operator token">=</SPAN> nd<SPAN class="punctuation token">.</SPAN>distance_transform_edt<SPAN class="punctuation token">(</SPAN>m<SPAN class="punctuation token">,</SPAN> return_distances<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN>
return_indices<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
alloc <SPAN class="operator token">=</SPAN> a<SPAN class="punctuation token">[</SPAN>tuple<SPAN class="punctuation token">(</SPAN>idx<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">return</SPAN> dist<SPAN class="punctuation token">,</SPAN> alloc
<SPAN class="comment token"># ----------------------------------------------------------------------</SPAN>
<SPAN class="comment token"># .... final code section</SPAN>
<SPAN class="keyword token">if</SPAN> len<SPAN class="punctuation token">(</SPAN>sys<SPAN class="punctuation token">.</SPAN>argv<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN>
testing <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
r_in <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\GIS\A_Tools_scripts\Raster_tools\Data\poly.tif"</SPAN>
a <SPAN class="operator token">=</SPAN> RasterToNumPyArray<SPAN class="punctuation token">(</SPAN>r_in<SPAN class="punctuation token">)</SPAN>
dist<SPAN class="punctuation token">,</SPAN> alloc <SPAN class="operator token">=</SPAN> euclid_calc<SPAN class="punctuation token">(</SPAN>a<SPAN class="punctuation token">,</SPAN> mask_vals<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> dist<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> alloc<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
testing <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">False</SPAN>
r_in <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>argv<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN>
r_out <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>argv<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN>
LLx <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>argv<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN>
LLy <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>argv<SPAN class="punctuation token">[</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">]</SPAN>
cell_sze <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>argv<SPAN class="punctuation token">[</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">]</SPAN>
a <SPAN class="operator token">=</SPAN> RasterToNumPyArray<SPAN class="punctuation token">(</SPAN>r_in<SPAN class="punctuation token">)</SPAN>
dist<SPAN class="punctuation token">,</SPAN> alloc <SPAN class="operator token">=</SPAN> euclid_calc<SPAN class="punctuation token">(</SPAN>a<SPAN class="punctuation token">,</SPAN> mask_vals<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> dist<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> alloc<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#</SPAN>
<SPAN class="comment token"># specify a, dist or alloc below... this could be a tool choice if needed</SPAN>
<SPAN class="comment token">#</SPAN>
r0 <SPAN class="operator token">=</SPAN> NumPyArrayToRaster<SPAN class="punctuation token">(</SPAN>a<SPAN class="punctuation token">,</SPAN> Point<SPAN class="punctuation token">(</SPAN>LLx<SPAN class="punctuation token">,</SPAN> LLy<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> cell_sze<SPAN class="punctuation token">)</SPAN>
r0<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN>r_out<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Of course, when run from within the amazing Spyder python IDE, you can simply skip saving to output raster if needed, or try various other options from with the scipy slate other than the distance_transform_edt

On to other "special analyst" tools soon.