And Brooke Singer, the designer in residence at the Hall of Science, was mixing it with her bare hands. “Smell this,” she said, holding her palm out to another volunteer. “Makes you happy, huh? It’s the soil bacteria.” Ms. Singer is the driving force behind Carbon Sponge, a project that is exploring New York’s capacity to sequester carbon in soil by putting in test plots around the city.

“We’re planting eight different cover-crop types that were developed by a sunflower farmer in Kansas,” Ms. Singer said. In addition to testing the capacity of urban soils to suck carbon dioxide and nitrogen from the atmosphere, they want to find out what precise mix of compost, sediment and cover crops can best transform the sterile sediments that abound deep below the city’s neighborhoods into productive soils.

That New York sits atop a trove of potential agricultural materials might surprise anyone who has dug in a backyard or community garden. Sink a shovel into the ground and you will encounter brick fragments, ceramic pipes, glass shards and other industrial debris. But according to Joshua Cheng, a geologist at Brooklyn College, concealed under several feet of surface rubble are sediments that were laid down by glaciers during the Ice Age.

Professor Cheng explained that 20,000 years ago, the last glacier had advanced as far as what is now New York City. The deposits of sand, silt and rounded pebbles dumped by the retreating glacier are 300 to 400 feet deep in parts of Brooklyn and Queens.

But the rich and clean glacial soil is well below the surface of the city. A study conducted by Professor Cheng in 2015 found that 97 percent of the community gardens and backyards that they tested had elevated levels of lead and arsenic. While the main sources of these pollutants, leaded gasoline and lead-based paint, are now strictly regulated, high levels persist in topsoil and get blown into the air as dust, potentially putting gardeners and children who play in the most contaminated gardens at risk.