We investigate the structural and optical properties of spontaneously formed GaN nanowires with different degrees of coalescence. This quantity is determined by an analysis of the cross-sectional area and perimeter of the nanowires obtained by plan-view scanning electron microscopy. X-ray diffraction experiments are used to measure the inhomogeneous strain in the nanowire ensembles as well as the orientational distribution of the nanowires. The comparison of the results obtained for GaN nanowire ensembles prepared on bare Si(111) and AlN buffered 6H-SiC(000-1) reveals that the main source of the inhomogeneous strain is the random distortions caused by the coalescence of adjacent nanowires. The magnitude of the strain inhomogeneity induced by nanowire coalescence is found not to be determined solely by the coalescence degree, but also by the mutual misorientation of the coalesced nanowires. The linewidth of the donor-bound exciton transition in photoluminescence spectra does not exhibit a monotonic increase with the coalescence degree. In contrast, the comparison of the root mean square strain with the linewidth of the donor-bound exciton transition reveals a clear correlation: the higher the strain inhomogeneity, the larger the linewidth.