The Whole Foods in Gowanus, Brooklyn, can boast that it has the freshest leafy greens and tomatoes available in any supermarket in the city—thanks to its rooftop tenant, Gotham Greens, which owns and operates a 20,000-square-foot greenhouse. It is the only grocer that gets produce delivered by elevator just hours after being picked.

Gotham Greens is not only running the first greenhouse on top of a supermarket, but the company also asserts that it has the only commercial rooftop greenhouse in the entire country. It is also the fastest-growing greenhouse company in the city using hydroponics instead of soil to grow crops. It harvested its first tomatoes, lettuces, basil, bok choy and kale a couple of weeks ago. All are pesticide-free, though not certified organic.

The Brooklyn-based urban farmer is taking the locavore movement to a new level by growing produce year-round like competitors in California, where New York gets a big chunk of its produce. Local farmers are quick to point out that a typical shipment from the West is already a week old by the time it hits store shelves in New York.

While urban farming now refers to any number of farming activities at dozens of hotels, restaurants, residential and industrial buildings, and schools in the city, Gotham Greens has bolted out of the starting gate. Though Brooklyn Grange has a bigger footprint here, its farms are all open-air and thus seasonal.

Gotham Greens' customers include FreshDirect, D'Agostino, Dean & DeLuca, Key Food and Westside Market. The privately held company is backed by investors and has some debt, but co-founder Viraj Puri said it is profitable "and in the black since day one." He would not disclose revenue but said it would increase by 160% this year. It has raised more than $15 million so far.

Six-year-old Gotham Greens launched its first greenhouse in 2011 in Greenpoint, Brooklyn; its second, at Whole Foods, was completed in January; and a third will open later this year in Jamaica, Queens, where it has a signed deal with a developer.

The company declined to disclose the address or identify the developer, but said it received $900,000 late last year from the state Regional Economic Development Council to build out the Queens site. That facility will add another 60 employees to its roster, bringing the total to 100 in 2014.

"Now that we have this experience under our belt, we are scaling up our company and brand," said Mr. Puri. Having Whole Foods in its corner will certainly help.

More rooftop farms?

"On paper, we are their landlord," said a spokesman for Whole Foods, "but we look at this as a strategic partnership." Mr. Puri has already been to the grocer's headquarters in Austin, Texas, and Whole Foods executives have been touring the greenhouse.

Replicating the Gowanus store is "certainly something we talk about," said the Whole Foods spokesman. But, he added, "it was easy to do it in Gowanus, because we own this building."

Whole Foods will be opening four more stores in New York City, but none of them is suitable for a greenhouse, said the spokesman.

In fact, finding the right location for such a business is among the biggest challenges Gotham Greens and all urban farmers face. After all, large spaces are not easy to find in the city. BrightFarms, a Manhattan-based competitor to Gotham Greens, for example, has not been able to open a greenhouse here, though it has one in rural Pennsylvania and plans to build six others outside New York.

A year ago, the urban farmer announced a deal with Salmar Properties to convert the roof of a 100-year-old building in Sunset Park, Brooklyn, to a greenhouse. But BrightFarms never developed the property and in February terminated its lease. The company and the developer declined to give a reason for the reversal.

"As New Yorkers, we are eager to start growing produce in our hometown," said BrightFarms CEO Paul Lightfoot in a prepared statement, adding that the company is looking for another opportunity here.

And so are others. California-based Famgro Farms, which grows produce in a converted surfboard factory in Oceanside, Calif., that's now a greenhouse using hydroponic technology, is scouting for sites in the Bronx.

"We've made several trips lately to review our options in the area, and the Bronx seems well suited to Famgro Farms," said founder Steve Fambro. His products are also sold at Whole Foods.

Similarly, Montreal-based Lufa Farms has been looking for the past couple of years for a rooftop in the city on which to erect a greenhouse. Lufa has two in Montreal that use water irrigation to grow its crops. It sells directly to consumers based on a CSA model. The Canadian farm recently inked a deal for its first outpost in the U.S., in Boston.

"We've been trying to get to developers before they build, so they can make adjustments to accommodate our needs," said Lufa founder Kurt Lynn.

Proprietary methods

Not only does the roof need to be sturdy, the greenhouse also has to be constructed so that it's not "lifted off the roof by strong winds," added Mr. Lynn.

So far, Gotham Greens has been winning the battle for real estate, but it is keenly aware of the competitive pressures it faces, particularly in protecting the proprietary science and technology it uses.

"We do have intellectual property that we are in the process of trying to protect," conceded Mr. Puri, who instructed a photographer not to take photos showing how the water-irrigation system works.

"All of our recipes are proprietary, from how we provide nutrition to our crops, to our temperature settings, to the varieties of crops we use," he said.

The greenhouse relies on sensors that track the temperature—tomatoes need more heat and humidity than leafy greens—as well as carbon dioxide and oxygen levels, and the amount of light. The data are fed into a computer system that can automatically adjust the environment as needed.

Gotham Greens will also be tracking information about tomatoes for the first time. They take up to three months to harvest, compared with the 20 to 30 days leafy greens require. The tomatoes can also command a premium price, because they are truly ripe when they are plucked from the vine.

"These are very coddled plants," Mr. Puri said. "They have the best conditions."