Compositional disorder has important consequences on the optical properties of III-nitride ternary alloys. In AlGaN epilayers and AlGaN-based quantum heterostructures, the potential fluctuations induced by such disorder lead to the localisation of carriers at low temperature, which affects their transition energies. Using the correlations between micro-photoluminescence, scanning transmission electron microscopy and atom probe tomography we have analysed the optical behaviour of Al0.25Ga0.75N epilayers and that of GaN/AlGaN quantum wells, and reconstructed in three dimensions the distribution of chemical species with sub-nanometre spatial resolution. These composition maps served as the basis for the effective mass calculation of electrons and holes involved in radiative transitions. Good statistical predictions were subsequently obtained for the above-mentioned transition and localisation energies by establishing a link with their microstructural properties.