Evolutionary origins for ecological patterns in space