  Let $(X,d,\mu)$ be an Ahlfors metric measure space. We give sufficient
conditions on a closed set $F\subseteq X$ and on a real number $\beta$ in such
a way that $d(x,F)^\beta$ becomes a Muckenhoupt weight. We give also some
illustrations to regularity of solutions of partial differential equations and
regarding some classical fractals.
