Courtesy of DC Water

The water authority in Washington, D.C., receives 1,500 wet tons of sewage into its wastewater-treatment facility each day. CEO George Hawkins views it as liquid gold—an ingredient for a moneymaking operation that could help pay for repairs to its aging infrastructure. His agency, DC Water, cooks, sterilizes, and turns that sewage into a soil fertilizer called Bloom, which began shipping this spring to nurseries and garden centers in the region.

Ignore the “ick” ­factor. DC Water is among a handful of utilities that is innovating to save or generate money. Philadelphia’s utility is using the water that washes into the sewers during storms to keep its parks green. And in Portland, Ore., purified wastewater is being used to make beer. (No one says you have to drink it.)

The Washington initiative is ambitious. The process begins with the matter flushed down a toilet, which may travel through any of DC Water’s 1,800 miles of sewer pipes to the wastewater-treatment plant. Oils, fats, sediments, and objects are screened out, and the water is disinfected. The remaining sludge then goes through a three-stage process that cooks it in high heat and pressure, sterilizing and softening it. The clean sludge is then sent to four 80-foot-tall anaerobic digesters, where giant mixers churn the liquid for two weeks while a population of microorganisms called “methanogens” eats the organic matter, producing methane gas for electricity that ultimately powers a third of the water plant’s operations. The solids then travel to a belt-filter press that squeezes out water and delivers the crumbly compost to bunkers that can hold 1,000 tons each.

The result can be used to fertilize gardens and trees. (Bloom fertilizer is in high demand, says Brian Riddle, who bought 1,000 tons of it for his D.C.-area garden centers, Homestead Gardens. He says it’s hard to find affordable fertilizer that’s safe and natural. “Bloom,” he says, “is loaded with valuable nutrients.”)

DC Water spent several years investigating and testing the technology, which was already in use in Europe, before spending $470 million on the equipment two years ago. DC Water would have needed to spend most of that money anyway to treat the biosolids, and this was a way to do that in a sustainable manner and generate revenue to fix aging pipes. More than half of the D.C. pipes are 79 years or older—some date to 1860—and the agency estimates a need for at least $1 billion in repairs in the coming years.

Bloom’s sales are still fledgling, and Hawkins says it may take two or three years to ramp up. But the approach was a necessity. “It’s literally like a startup,” he says. “Our business model was going to fail without fundamental change.”

That could be the case for much of America’s broad array of infrastructure, says Greg DiLoreto, past president of the American Society of Civil Engineers, which produces a report card on the state of the nation’s infrastructure every four years. America’s grade this year: D+. The nation’s 14,748 water-treatment facilities are in particular disrepair, suffering from 240,000 pipe breaks a year. Those facilities will need to serve some 56 million new customers over the next two decades, says DiLoreto.

He praises DC Water’s initiative. “That kind of innovation will make the money go a lot further,” says DiLoreto, “but we still need investment or we’re going to see more pipe breaks and more Flint, Michigans.”

DC Water’s new investment has allowed it to cut its operating budget, as well as its biosolid disposal and energy costs, making it the largest generator of clean energy in the Washington, D.C., area. The utility has even more plans to generate revenue, including selling “sewer-thermal energy,” which uses heat exchangers inside the city’s underground sewage system to heat and cool buildings—much like traditional geothermal energy drawn from the earth’s core. The sewer energy is being tested at several of DC Water’s own buildings before being rolled out to potential customers. Other plans are in the works too. They give new meaning to the old phrase “Waste not, want not.” 

Old Data, New Problem

Can transportation apps help address the nation’s aging roads?

Los Angeles Tops List Of Most Traffic-Congested Cities In The World
Waze is sharing traffic data with the city of Los Angeles.Justin Sullivan—Getty Images
Justin Sullivan—Getty Images

When it comes to fixing the nation’s crumbling roads, the one thing you can count on is that political rhetoric will far outpace spending. That makes information—say, which portions of a decaying highway force drivers to slow down most often—crucial in deciding where to target government dollars. Enter the data-drenched startups of the new economy. Google’s Waze, the mapping app that optimizes routes to avoid traffic, along with ride-sharing company Uber, is helping officials prioritize by delivering data collected from millions of drivers on the road.

Just two years after its start, Waze’s Connected Citizens program delivers free data to 250 cities and half of the nation’s state transportation departments. (In return, Waze receives information from its government partners.) The program helps identify traffic patterns, map potholes, and suggest where to allocate resources.

Rio de Janeiro, beset by complaints about its infrastructure in the run-up to the 2016 Summer Olympics, used Waze’s data to validate locations for two new highways and then to manage traffic and road closings during the games. Boston used Waze data to determine which intersections were most congested and which needed new stoplights. The result: an 18% reduction in congestion at key intersections.

Waze may not be able to fix a road—but it can find the one that needs the most urgent attention.

A version of this article appears in the June 15, 2017 issue of Fortune with the headline “Turning Waste Into Gold (or Copper).”

Subscribe to Well Adjusted, our newsletter full of simple strategies to work smarter and live better, from the Fortune Well team. Sign up today.