A Gradient Model for the Spatial Patterns of Cities