Modeling spatial heterogeneity with MESF