terrainData.GetHeights wrong x and z cordinates

Hi everyone. I’m having a very frustrating problem.

I want to get an array of the heights of the terrain so I can compare them to other terrains and connect them. I have used heights = terr.terrainData.GetHeights (0, 0, xRes, zRes); to do this. however when the values are put into my array heights. the x and z values are different on each piece of terrain.
for example when I say float vert = heights[0,0] this should always be the bottom left corner in global space, but it is always a different corner depending on which terrain the script is applied to. I know you can use Terrain.GetInterpolatedHeight(); but this only gets one point and there is also no set height. If you have a solution please let me know It would be greatly appreciated.

OK it turns out terrainData.GetHeights (); seems to dump z into the first key of the array and x into the second making all the coordinates backwards when trying to use the array. Everything is functioning right now since I flipped the values.