The effects of spatial heterogeneity in population dynamics