  We present a study of the spin properties of dense layers of near-surface
nitrogen-vacancy (NV) centres in diamond created by nitrogen ion implantation.
The optically detected magnetic resonance contrast and linewidth, spin
coherence time, and spin relaxation time, are measured as a function of
implantation energy, dose, annealing temperature and surface treatment. To
track the presence of damage and surface-related spin defects, we perform in
situ electron spin resonance spectroscopy through both double electron-electron
resonance and cross-relaxation spectroscopy on the NV centres. We find that,
for the energy ($4-30$~keV) and dose ($5\times10^{11}-10^{13}$~ions/cm$^2$)
ranges considered, the NV spin properties are mainly governed by the dose via
residual implantation-induced paramagnetic defects, but that the resulting
magnetic sensitivity is essentially independent of both dose and energy. We
then show that the magnetic sensitivity is significantly improved by
high-temperature annealing at $\geq1100^\circ$C. Moreover, the spin properties
are not significantly affected by oxygen annealing, apart from the spin
relaxation time, which is dramatically decreased. Finally, the average NV depth
is determined by nuclear magnetic resonance measurements, giving
$\approx10$-17~nm at 4-6 keV implantation energy. This study sheds light on the
optimal conditions to create dense layers of near-surface NV centres for
high-sensitivity sensing and imaging applications.
