Diabetes, which is a chronic disease with a high prevalence in people over 45 years old in China, is a public health issue of global concern. In order to explore the spatiotemporal patterns of diabetes among people over 45 years old in China, to find out diabetes risk factors, and to assess its risk, we used spatial autocorrelation, spatiotemporal cluster analysis, binary logistic regression, and a random forest model in this study. The results of the spatial autocorrelation analysis and the spatiotemporal clustering analysis showed that diabetes patients are mainly clustered near the Beijing–Tianjin–Hebei region, and that the prevalence of diabetes clusters is waning. Age, hypertension, dyslipidemia, and smoking history were all diabetes risk factors (p < 0.05), but the spatial heterogeneity of these factors was weak. Compared with the binary logistic regression model, the random forest model showed better accuracy in assessing diabetes risk. According to the assessment risk map generated by the random forest model, the northeast region and the Beijing–Tianjin–Hebei region are high-risk areas for diabetes.