The layered-hexagonal structure was proposed as a reference by Dreyer et al. [Phys. Rev. X 6, 021038 (2016)] to determine polarization properties of wurtzite materials. Using this reference in the context of the Berry-phase theory, we study the polarization of wurtzite III-nitride ternary alloys Al
x
Ga1−x
N, In
x
Ga1−x
N and In
x
Al1−x
N. We report composition-dependent expressions of the spontaneous and piezoelectric polarizations and compare these values to the zincblende results. It is found that both spontaneous and piezoelectric components exhibit nearly linear dependence on alloy concentration, which means they follow the linear behavior predicted by Vegard’s law. The total-polarization charge of the quaternary-alloy heterostructure Al
x
In
y
Ga1−x−y
N/GaN is also investigated based on the hexagonal structure. We show that the polarization charge results to be zero at certain Al and In contents, giving heterostructures free of built-in electric fields and thus allowing the design of high-efficiency optical devices. Furthermore, we compute the total-polarization charge of Al
x
Ga1-x
N/GaN, In
x
Ga1−x
N/GaN and In
x
Al1−x
N/GaN. These values are compared to available theoretical and experimental data in order to validate the results of our simulation.