  After a seminal paper by Shekeey (2016), a connection between maximum
$h$-scattered $\mathbb{F}_q$-subspaces of $V(r,q^n)$ and maximum rank distance
(MRD) codes has been established in the extremal cases $h=1$ and $h=r-1$. In
this paper, we propose a connection for any $h\in\{1,\ldots,r-1\}$, extending
and unifying all the previously known ones. As a consequence, we obtain
examples of non-square MRD codes which are not equivalent to generalized
Gabidulin or twisted Gabidulin codes. Up to equivalence, we classify MRD codes
having the same parameters as the ones in our connection. Also, we determine
the weight distribution of codes related to the geometric counterpart of
maximum $h$-scattered subspaces.
