This study analyzes spatio-temporal data mining and prediction methods and further constructs a prediction model based on spatio-temporal analysis. The LSTM model is used to identify the temporal characteristics of the input data, and the time lag cross-correlation function is used to dynamically assess the correlation between time series. The spatial component is used to visualize the spatial lag relationship, and finally, the component models are integrated and coordinated through a fusion strategy. Based on the study of the effects of soil mineral ion-microbial interactions on phosphorus and sulfur cycles, this research achieves spatio-temporal distribution predictions for phosphorus and sulfur cycles. The abundance of functional genes related to organic phosphorus transformation in soil phosphorus cycle microorganisms, Shannon diversity indices, and soil mineral ions all showed significant positive correlations (P < 0.05). Similarly, as soil mineral ion concentrations increased, the abundance of sulfur reduction genes and sulfur oxidation genes in soil sulfur cycle microorganisms, as well as Shannon diversity indices, also increased. In grasslands, the density of phosphorus and sulfur ions exhibits a relatively stable annual distribution trend, while in paddy fields, the density of phosphorus and sulfur ions shows an increasing trend over time, being more susceptible to the influence of soil mineral ions. The prediction results of the phosphorus and sulfur cycles in non-saline-alkali grasslands for 2024 obtained from this model are generally consistent with the measured results.