I hope I understand now what you want: In my example screenshot, there is a square plane surrounded by its neighbors in X and Y directions (for simplicity the neighbors are not rotated). If you now calculate vectors from the neighbors X1 to X2 and from Y1 to Y2 and generate a plane aligned with those two vectors, this should be the orientation of the target plane in the center of those neighbors?
The maths isn't actually too complicated. As you said in your question, you can look up the neighbors of the values, this would be no issue - so in my example I simply get them from the location of the neighbor planes. The important point is, you have the XYZ values of all neighbors.
At first you calculate the vectors between X1 and X2 as well as Y1 and Y2 by simply subtracting them with Vector Math nodes. To get an orientation out of those vectors you can work with, you plug the vectors into the Vector inputs of Align Euler to Vector nodes. The node for the X vector has to be set to X axis, the one for the Y vector to Y axis.
Now that you have a Euler rotation for the X and the Y axis you simply need to add them together in another Vector Math node and plug them (in my case) into a Transform node. This works because I use a single plane, when you have multiple rotations for multiple instances of an object you should be using a Rotate Instances node.
But the resulting orientation of the plane aligned to the vectors will not keep it in shape with the grid if that is what's expected. Here is a comparison between the top views of the real resulting of aligning a square plane with the vectors on the left (which can be more extreme depending on the neighbors' height differences), then in the middle what one might expect when having a grid of square planes/objects. On the right then is the actual shape of the plane when the rotation is reset to 0°, it needs to be distorted to fit the square shape when aligned with the normal. That's what I meant in the comments when saying you cannot simply achieve the result without warping or distorting the objects. A bump map keeps all square shapes of the pixels when viewed from above - but this doesn't work with a rigid object.
//EDIT: A simpler setup would be to take the cross product of the X and Y vectors and plug them into the Align Vector to Euler node. The cross product calculates the vector that is perpendicular to both of the input vectors, which makes it the normal of a plane containing those vectors.
If you then set the Align Vector to Euler node to align the Z axis, you will get a slightly different result than before - both planes have the same X and Y orientation, but the second method will also rotate the plane on the Z axis, which in top view results in the plane no longer being aligned with neither X nor Y axis. So it depends on what you want.
With the cross product you can achieve the same result like the first method by multiplying the Align Vector to Euler output with a vector set to [1, 1, 0] and thus eliminating the Z rotation.
And this is the top view of the cross product method. As you can see, now there is no edge aligned with any axis.