  Recently, topologically nontrivial polarization textures have been predicted
and observed in nanoscale systems. While these polarization textures are
interesting and promising in terms of applications, their topology in general
is yet to be fully understood. For example, the relation between topological
polarization structures and band topology has not been explored, and polar
domain structures are typically considered in topologically trivial systems. In
particular, the local polarization in a crystal supercell is not well-defined,
and typically calculated using approximations which do not satisfy gauge
invariance. Furthermore, local polarization in supercells is typically
approximated using calculations involving smaller unit cells, meaning the
connection to the electronic structure of the supercell is lost. In this work,
we propose a definition of local polarization which is gauge invariant and can
be calculated directly from a supercell without approximations. We show using
first-principles calculations for commensurate bilayer hexagonal boron nitride
that our expressions for local polarization give the correct result at the unit
cell level, which is a first approximation to the local polarization in a
moir\'e superlattice. We also illustrate using an effective model that the
local polarization can be directly calculated in real space. Finally, we
discuss the relation between polarization and band topology, for which it is
essential to have a correct definition of polarization textures.
