  This paper investigates the relationship between the rank weight distribution
of a linear code and that of its dual code. The main result of this paper is
that, similar to the MacWilliams identity for the Hamming metric, the rank
weight distribution of any linear code can be expressed as an analytical
expression of that of its dual code. Remarkably, our new identity has a similar
form to the MacWilliams identity for the Hamming metric. Our new identity
provides a significant analytical tool to the rank weight distribution analysis
of linear codes. We use a linear space based approach in the proof for our new
identity, and adapt this approach to provide an alternative proof of the
MacWilliams identity for the Hamming metric. Finally, we determine the
relationship between moments of the rank distribution of a linear code and
those of its dual code, and provide an alternative derivation of the rank
weight distribution of maximum rank distance codes.
