Cloud-induced atmospheric extinction and occlusion significantly affect the effectiveness and quality of telescope observations. Real-time cloud-cover distribution and long-term statistical data are essential for astronomical siting and telescope operations. Visual inspection is currently the primary approach for analyzing cloud distribution at ground-based astronomical sites. However, the main disadvantages of manual observation methods are human subjectivity, heavy workloads, and poor real-time performance. Therefore, a real-time automatic cloud image classification method is desperately needed. This paper presents a novel cloud identification method named the PSO+XGBoost model, which combines eXtreme Gradient Boosting (XGBoost) with particle-swarm optimization (PSO). The entire cloud image is divided into 37 sub-regions to identify the distribution of the clouds more precisely. Nineteen features, including the sky background, star density, lighting conditions, and subregion grayscale values, are extracted. The experimental results have shown that the overall classification accuracy is 96.91%, and our model can outperform several state-of-the-art baseline methods. Our approach achieves high accuracy in comparison with the manual observation methods. Moreover, this method meets telescope real-time scheduling requirements.