Hi,
That is how I would have done it as well. If you want something somewhat more compact you can construct a dictionary that maps dims to array of coordinates
dim_to_coords = {key:d.coords[key].to_numpy() for key in d.dims}
Note that this is not much different from the dictionary d.coords, it is essentially a version of with its values changed to arrays. So this would also work if that seems more pleasant:
{key:val.to_numpy() for key,val in d.coords.items()}
That being said, if you really just want to get coordinates by dimension index then this is slightly more compact compared to what you are using:
list(d.coords.values())[0].to_numpy()
Any reason why you are not satisfied with your approach?
Also, if your xarray is two dimensional:
d.to_pandas().index
d.to_pandas().columns
will respectively give you coordinates along in each dimension as well. This won’t work in higher dimensions.