A stochastic model for linking and predicting spatial patterns in species-rich ecosystems