In the analysis of energy dispersive X-ray diffraction (EDXRD) spectra of drug body packing, feature extraction is a great challenge. In this work, nonnegative matrix factorization (NMF) is proposed to identify drug body packing. NMF was applied to extract features from EDXRD spectra of samples in a set of drugs and other materials concealed in an anthropomorphic phantom. Compared with the features extracted by principal component analysis (PCA) and robust PCA, the features extracted by NMF are physically significant, and can be easily interpreted as diffraction peaks of samples. The features were classified by K-nearest neighbor and support vector machine. The results indicated that the recognition rate using NMF was ideal (above 98%) and insensitive to classifiers. This investigation has demonstrated that NMF is effective in feature extraction for the identification of drug body packing.