Suppose $D = [0,1]\times [0,1]$. Then, its boundary can be represented by $$ \partial D = B_1 \cup B_2 \cup B_2 \cup B_4, $$ where $B_1 = \{0\}\times [0,1]$, $B_2 = \{1\}\times [0,1]$, $B_3 = [0,1] \times \{0\}$, $B_4 = [0,1] \times \{1\}$.
I want to draw random samples out of $D$. Suppose $\mu$ is a Lebesgue probability measure on $D$. I can then use $\mu$ to draw samples from $D^\circ$, the interior of $D$, (since $\mu(\partial D) = 0$). For the samples of $\partial D$, I can employ four probability measures $p_i$ on $[0,1]$ and use $p_i$ for $B_i$.
I am struggling with describing $B_i$'s in a topological sense to define probability measure $p_i$ on $B_i$. I know that $\partial D$ is a connected component in $\mathbb{R}^2$. However, it is essentially a concatenation of four intervals. So it is roughly a union of four connected components in $\mathbb{R}$. However, I am not sure how to describe it... I believe there must be some topological notion of describing each $B_i$. But I cannot think of any...
Any suggestions/comments/answers will be very appreciated.
Drawing a random (uniform) sample from $D$ does not require describing $D$ any better than you have. Choose an edge randomly (probability $1/4$ for each), then choose a number between $0$ and $1$.
If you feel you must somehow define $D$ as a disjoint union you can use half open edges.
If you need a formal definition of the probability measure on $D$ map it to the interval $(0,4]$ in the obvious way and pull back Lebesgue measure.