I want to draw the moon phases and started with this code
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=2pt,fill=white] (char) {#1};}}
\begin{document}
\begin{tikzpicture}
\draw (0cm,0cm) circle(4cm);
\foreach \x in {0,45,...,360} {
\filldraw[fill=white] (\x:4cm) circle(0.4cm);
\filldraw[fill=white] (\x:5cm) circle(0.4cm);
\draw[fill=black!70] (\x:4cm)-- +(0,0.4cm) arc (90:-90:0.4cm) -- cycle;
}
\node[inner sep=0pt] at (0,0) {\includegraphics[height=5cm]{aarde2}};
\foreach \x/\xtext in {
0/\circled{5},
45/\circled{6},
90/\circled{7},
135/\circled{8},
180/\circled{1},
225/\circled{2},
270/\circled{3},
315/\circled{4}}
\draw (\x:3.3cm) node {\tiny \xtext};
\end{tikzpicture}
\end{document}
resulting in this:
(picture of the earth is not uploaded)
My question is: how can I draw squares around the white circles. As the circles have a radius of 8mm, the squares should have a side of 1cm.
(the purpose of the white circles is to color to realistic view of the moon phase if you stand on that position.


[count=\n, evaluate=\n as \angle using int(135+45*\n)]in the foreach statement (between\xtext ... in), then inside of it you can write\node[circle, inner sep=1mm] at (\angle:3cm) {\n};. This should work. – Alenanno Sep 03 '16 at 15:33