I don't like messing with formulae, so I like to take the higher view point: In $D^2$ we identify the boundary circle $S^1$ to a point. The open disk, so $D^2\setminus S^1$, is homeomorphic to $\Bbb R^2$. (for this it is easier to give an explicit map, e.g. $x \to \frac{\|x\|}{\|x\|+1}x$ from $\Bbb R^2$ to the open disk). So the resulting quotient space is a copy of $\Bbb R^2$ with an extra point added which makes it compact (as the quotient of a compact space is compact). So it's the one-point compactification of $\Bbb R^2$, which is essentially unique (this is a standard theorem in many text books).
And $S^2$ also is homeomorphic to the one-point compactification of $\Bbb R^2$ via the standard stereographic projection map.
And two spaces homeomorphic to the same space are homeomorphic to each other (to paraphrase Euclid).
We can make this explicit by composing the inverse of the above map between the open disk and the plane and the stereographic formula I found here, e.g. and then we get a rather ugly formula, for $(x,y) \in D^2\setminus S^1$ (so that $\sqrt{x^2+y^2}=\|(x,y)\|<1$):
$$f(x,y) = (\frac{2h_1(x,y)}{1+\|h(x,y)\|^2}, \frac{2h_2(x,y)}{1+\|h(x,y)\|^2}, \frac{-1 + \|h(x,y)\|^2}{1+\|h(x,y)\|^2})$$
where $$h(x,y)=(h_1(x,y), h_2(x,y)) = (\frac{\|(x,y)\|}{1-\|(x,y)\|}x, \frac{\|(x,y)\|}{1-\|(x,y)\|}y)$$
and sending all points $(x,y)$ that have norm $1$ to $(0,0,1)$. Then $f: D^2 \to S^2$ obeys $f(x,y) = f(u,v) \iff (x,y)\sim (u,v)$ etc. The continuity follows from the considerations in the first part.
Best Answer
It is more elegant to regard $S^n$ as a subset of $\mathbb R^n \times \mathbb R$ and to write $$f(x) = \begin{cases} \left(\sin(\pi \lVert x\rVert)\dfrac{x}{\lVert x\rVert},\cos(\pi\lVert x\rVert)\right)& x\neq 0\\ (0,1) & x=0. \end{cases}$$
Now let $(y,t) \in S^n$, i.e. $\lVert y \rVert^2 + t^2 = 1$. This implies
$\lVert y \rVert^2 \le 1$, i.e. $y \in D^n$.
$t^2 \le 1$, i.e. $t \in[-1,1]$ and there exists a unique $s_t \in [0,1]$ such that $\cos (\pi s_t) = t$.
Case 1. $t = 1$. Then $\lVert y \rVert^2 = 0$, i.e. $y = 0$. Thus $f(0) = (0,1) = (y,t)$.
Case 2. $t = -1$. Then $\lVert y \rVert^2 = 0$, i.e. $y = 0$. For any $x \in S^{n-1} \subset D^n$ we have $\lVert x \rVert = 1$ and thus $f(x) = \left(\sin(\pi 1)\dfrac{x}{1},\cos(\pi 1)\right) = (0,-1) = (y,t)$.
Case 3. $-1 < t < 1$. Then $t^2 < 1$ and hence $\lVert y \rVert^2 > 0$, i.e. $y \ne 0$. Let $x = s_t\dfrac{y}{\lVert y \rVert}$. Then $\lVert x \rVert =s_t$. Note that $0 < s_t < 1$ in case 3. We claim that $\sin(\pi \lVert x\rVert)\dfrac{x}{\lVert x\rVert} = y$ which shows that $f(x) = (y,t)$. We have $\sin(\pi \lVert x\rVert)\dfrac{x}{\lVert x\rVert} = \sin(\pi s_t)\dfrac{y}{\lVert y\rVert}$, thus it suffices to show that $\dfrac{\sin(\pi s_t)}{\lVert y\rVert} = 1$. Since $0 < s_t < 1$, we have $\sin(\pi s_t) > 0$, thus it suffices to show $\sin^2(\pi s_t) = \lVert y\rVert^2$. But this is clear since $\lVert y\rVert^2 = 1 - t^2 = 1- \cos^2(\pi s_t) = \sin^2(\pi s_t)$.