How to search for the nearest non nan value in 2d xarray dataset
If I were you, I would exclude the NaN values and then perform gridding on the resulting irregularly spaced data.

There are already the tools to perform this in Python and using the library SciPy

https://scipy-cookbook.readthedocs.io/items/Matplotlib_Gridding_irregularly_spaced_data.html

But please document exactly what step you are doing and why. Excluding data is always ... interpreting the data.