The space density of late M dwarfs, subtypes M7 to M9.5, is not well determined. We applied the photo-type method to iz photometry from the Sloan Digital Sky Survey and YJHK photometry from UKIRT Infrared Deep Sky Survey, over an effective area of 3070 deg 2 , to produce a new, bright J(Vega) < 17.5, homogeneous sample of 33 665 M7 to M9.5 dwarfs. The typical S/N of each source summed over the six bands is > 100. Classifications are provided to the nearest half spectral subtype. Through a comparison with the classifications in the BOSS Ultracool Dwarfs (BUD) spectroscopic sample, the typing is shown to be accurately calibrated to the BUD classifications and the precision is better than 0.5 subtypes rms; i.e. the photo-type classifications are as precise as good spectroscopic classifications. Sources with large χ 2 > 20 include several catalogued late-type subdwarfs. The new sample of late M dwarfs is highly complete, but there is a bias in the classification of rare peculiar blue or red objects. For example, L subdwarfs are misclassified towards earlier types by approximately two spectral subtypes. We estimate that this bias affects only ∼ 1% of the sources. Therefore the sample is well suited to measure the luminosity function and investigate the softening towards the Galactic plane of the exponential variation of density with height.An independent estimate of the M dwarf LF for spectral types M7 to M9 was made by Cruz et al. (2007), using a sample of 53 stars within 20pc of the Sun. The objects were identified using 2MASS JHK s photometry by application of a colour cut J − K s > 1. 0. Cruz et al. (2007) estimated that 79% of M7 dwarfs are redder than this colour limit and all M8 and M9 dwarfs. Unfortunately this sample is also problematic. Recent analysis of the 2MASS colours of M dwarfs by Schmidt et al. (2015) provided median colours J − K s = 0.96, 1.03 for M7, M8. These results suggest that only ∼ 50% of M7 and M8 dwarfs satisfy the above colour cut, meaning their space densities have been substantially underestimated.These questions motivate the compilation of a new sample of late M dwarfs, hereafter M7−M9.5, in order to obtain an improved measurement of the LF. We now briefly consider the issues involved in making an accurate measurement of the LF. Various studies of the LF may be distinguished by whether distances are measured by trigonometric, spectroscopic (absolute magni-Article number, page 1 of 8