Once upon a time everybody ate local food. No one called it that back then, of course. People just hunted, gathered, tilled the soil, and grazed livestock—all, for the most part, relatively close to home. But then small agricultural settlements grew into towns, towns grew into cities, and eventually the city became a place where you moved to get away from farming.

Covering the flat roofs and roof terraces of Bologna, Italy, with soil-free gardens could supply 12,000 tons of vegetables per year, or 77% of what the city’s inhabitants consume.

Lately we’ve come full circle, as the local food movement has reignited our interest in eating what’s produced nearby. A turning point came in 2001, when a study of food distribution systems in the midwestern US showed that produce travels 1,500 miles on average from farm to plate. (1) That little statistical morsel focused major attention on “food miles” and the possibilities for reducing them.

More than half of the world’s population lives in cities, so an interest in local food quickly morphs into a discussion of urban agriculture. But just how compatible is the landscape of modern cities with large-scale food production?

A smattering of studies, mostly in the United States, suggests that a lot of little vegetable plots can add up to something pretty major. In Cleveland, for example, converting 80 percent of every vacant lot to food production could supply about half of the produce, one-quarter of the poultry and eggs, and all of the honey consumed by the city’s residents. (2)

Vacant lots are plentiful in Cleveland, a city that has been hit hard by both deindustrialization and the foreclosure crisis. But not all cities have so much slack. New York City requires between 162,000 and 232,000 acres to grow all its fruits and vegetables, according to an analysis by Columbia University’s Urban Design Lab. (3) But it has only about 5,000 acres of suitable vacant land.

Producing a city’s entire food supply locally, not just its fruits and vegetables, gets even trickier. If all the grassy areas in Seattle—every lawn, public park, and soccer field—were pressed into agricultural service, they would yield crops (a combination of beets, squash, potatoes, carrots, dry beans, barley, kale, hazelnuts, and apples) sufficient to meet the total nutritional needs of just four percent of the city’s residents. (4)

On a global scale, one-third of the urban footprint would be necessary to produce the vegetables consumed by urban dwellers. (5) But this overall statistic hides a lot of variability: in some countries—such as Laos, Nigeria, and Cuba—the entire area covered by cities is smaller than the area required to grow vegetables for the urban population; other countries—such as the United States, Australia, and Brazil—could manage this feat on 10 percent or less of their urban land.

In general, denser cities will have more difficulty achieving food self-sufficiency. That means there’s a trade-off between different aspects of sustainability: a city can have high population density or lots of locally grown food, but probably not both. The old real estate adage that you can’t make more land applies here, although some people have tried getting around this constraint by proposing that we farm underground or in high-tech high-rises. (6)

Looking up can also improve the picture somewhat. One analysis found that covering the flat roofs and roof terraces of Bologna, Italy, with soil-free gardens could supply 12,000 tons of vegetables per year, or 77 percent of what the city’s inhabitants consume. (7)

Still, there might be more opportunities for old-fashioned, in-the-dirt farming in cities than we’ve yet realized. More than half the world’s urban residents live in small-to-medium-sized cities, which also tend to be less dense and therefore have more room for agricultural production compared to the biggest metropolises. (5)

And maybe it doesn’t have to be all or nothing. The United Nations Food and Agriculture Organization has estimated that at least 800 million people grow food in and around cities. Many of these people are poor, and growing a bit of supplemental produce can make a real difference to their economic and physical health. In the Kibera slum of Nairobi, Kenya, families who engage in sack gardening, a space-efficient method in which vegetables such as kale and Swiss chard are planted in soil-filled sacks, eat a wider variety of vegetables compared to other families. (8) This is because they are able to both eat the vegetables they grow and use money earned from selling their crops to buy other foods.

Food production isn’t the only benefit of urban agriculture, either. Farms on the outskirts of Sydney, Australia, might provide a buffer to the bush fires that periodically threaten the city (9); urban farms in Antananarivo, Madagascar, can also help with flood protection if they’re properly sited. (10) All of this suggests that the real question is not so much about food miles as about food security, and how the food system fits into a broader vision of a sustainable urban world.