I have a raster image with some values are nan and these are supposed to be filled by the valid values. These valid values should meet two conditions: within a certain distance