There are plenty of good educational and aesthetic reasons to grow food in a city. But, locavores who insist on eating food produced within the city limits are fighting a battle that they cannot win. Urban agriculture cannot and should not be expected to produce a meaningful share of a city's food needs.
As the blog post linked below post illustrates, so that I don't have to, the theoretical maximum amount of food that a typical major U.S. city could produce (putting all of it surface area into growing produce) is only about 1% of the total amount of food production that it needs to feed itself. Any more realistic assumptions (e.g. not putting gardens on highly pitched rooftops and making a reasonable allowance for golf courses, sports fields and flower gardens) which significant reduce this theoretically maximal productivity.
The entire notion of a high density population area that we call a city, inherently requires huge tracts of rural farm land to support it. Not many people need to live on that rural farm land. We can currently manage to provide all of the food that the nation needs to eat and export a bit of it with 1%-2% of the population.
If we had some compelling reason to produce the nation's food with the minimum percentage of people, we could probably do it with 0.25% to 0.5% of the land using existing technology or modest modifications and development of existing technologies that probably wouldn't be entitled to a patent (based mostly upon the fact that a very large percentage of farmers have tiny farms that produce only a negligible share of the nation's food production and on the fact that automation efforts are currently nowhere close to maximal in the agriculture industry).
For example, it takes roughly 10,600 square miles of arable land with crops growing on them to feed the population of Seattle, while the city itself has less than 84 square miles of land area and not all of that is arable land (i.e. land that it is possible to grow crops upon). If people would like to eat beef at typical modern levels, however, it takes far more land that that.