Can the projection onto a compact set always be taken to be measurable? This may be a very basic question.
Let $X$ be a complete metric space and let $T$ be a compact subset of $X$. Say that a function $\pi: X \to T$ is a projection if
$$
d(x, \pi(x)) = d(x, T) \quad \forall x \in X\,.
$$
If $T$ is a closed convex subset of $\mathbb{R}^d$ then the (unique) projection $\pi$ onto $T$ is always continuous; of course this will not happen in general. I am interested in the following weaker question:
Does there always exist a projection that is Borel measurable?
 A: Consider the closed multimap $\Pi:X\to 2^T$, whose graph is the closed set $\mathrm{graph}(\Pi):=\big\{(x,t)\in X\times T\, : d(x,t)=\min_{s\in T}d(x,s)\big\}\subset X\times T$. You want a measurable selection $\pi:X\to T$ of $\Pi$, that is $\mathrm{graph}(\pi)\subset\mathrm{graph}(\Pi)$. Since $K$ is a compact metric space, thus a Polish space, the classical Kuratowski–Ryll-Nardzewski measurable selection theorem does the job. 
rmk. The Kuratowski–Ryll-Nardzewski measurable selection theorem admits an easy proof in the particular case of a closed, non-empty set valued multimap $\Pi:X\to2^T$ with $T$ a compact metric space. In this case (by the Alexandroff-Hausdorff theorem) $T$ is a continuous image $T=\kappa( C)$ of the Cantor set $C$ via some continuous surjective map $\kappa:C\to T$. The pre-image of the closed set $\mathrm{graph}(\Pi)$ via $\mathrm{id}_X\times\kappa:X\times C\to X\times T$ is therefore the graph of a closed multimap $X\to 2^C$, that is the multimap $x\mapsto \kappa^{-1}\Pi(x)\neq\emptyset;$ a lower semi-continuous, hence measurable  selection of the latter, is $x\mapsto \min\kappa^{-1}\Pi(x) $, and a measurable selection of $\Pi$ is therefore
$$\pi(x):=\kappa\big(\min\kappa^{-1}\Pi(x)\big)\in\Pi(x).$$
