We study the distribution of economic activity, as proxied by lights at night, across 250,000 grid cells of average area 560 square kilometers. We first document that nearly half of the variation can be explained by a parsimonious set of physical geography attributes. A full set of country indicators only explains a further 10%. When we divide geographic characteristics into two groups, those primarily important for agriculture and those primarily important for trade, we find that the agriculture variables have relatively more explanatory power in countries that developed early and the trade variables have relatively more in countries that developed late, despite the fact that the latter group of countries are far more dependent on agriculture today. We explain this apparent puzzle in a model in which two technological shocks occur, one increasing agricultural productivity and the other decreasing transportation costs, and in which agglomeration economies lead to persistence in urban locations. In countries that developed early, structural transformation due to rising agricultural productivity began at a time when transport costs were still relatively high, so urban agglomerations were localized in agricultural regions. When transport costs fell, these local agglomerations persisted. In late developing countries, transport costs fell well before structural transformation. To exploit urban scale economies, manufacturing agglomerated in relatively few, often coastal, locations. With structural transformation, these initial coastal locations grew, without formation of more cities in the agricultural interior.