Rooftop solar panels could meet three-quarters of California's electricity needs and about 40 percent of the country's electricity needs, according to a new study from the National Renewable Energy Laboratory.

Researchers at the federally funded lab, which is based in Colorado, had estimated in 2008 that rooftop solar could generate 800 terawatt-hours of electricity per year, supplying about 21 percent of the country's current electricity demand. Now they've upped their estimate to 39 percent, in an analysis sure to be embraced by clean-energy advocates who see solar power as critical to fighting climate change.

It's unlikely the United States will tap all the sunlight at its disposal, at least not soon. The study focuses only on rooftop solar's theoretical potential, without considering which systems would make financial sense for the owners of homes, businesses and other commercial buildings. Dramatically scaling up rooftop solar would also require big investments in the electric grid, which was built to accommodate large, centralized power plants.

But even if the United States never reaches the 1,432 terawatt-hours of annual rooftop solar generation that NREL estimates is possible, the study gives policymakers a starting point for discussion, said Pieter Gagnon, an engineering analyst and the study's lead author.

"It doesn’t speak to whether or not that’s something that should be supported through policy or not. That’s ultimately up to whatever institutions are making those decisions," Gagnon said. "But they can do it in light of the understanding of how much electricity could conceivably come from rooftop solar."

The research lab was particularly bullish on California, which has a lot of sunlight, many large buildings and low per-person energy use. Researchers estimated that California could generate 74 percent of its electricity from rooftop solar — far more than any other state. The next-highest percentages came from the six states of New England, which get relatively little sunlight but don't use much energy to begin with. Unsurprisingly, large, sunny states such as California, Texas and Florida have the greatest overall generation potential.

UC Riverside solar energy expert Alfredo Martinez-Morales said that while he hadn't seen the study, he trusts NREL, a widely respected, privately run research lab funded by the Department of Energy. Still, he cautioned that even if California could theoretically get 74 percent of its electricity from rooftop solar, there would be many obstacles to making that work in practice.

In 2014, California got about 2.4 percent of its electricity from rooftop solar, according to calculations by the California Solar Energy Industries Association, a trade group. Getting that number into the double-digits — let alone close to 74 percent — would require big changes in how the electric grid is operated, according to Martinez-Morales, the managing director of UC Riverside's Southern California Research Initiative for Solar Energy.

“My feeling is you should definitely exploit the rooftop option, but there are some challenges. It’s always a tradeoff," he said.

California is working to solve those grid challenges and ramp up rooftop solar, but not without pushback from utility companies such as Southern California Edison, Pacific Gas & Electric and San Diego Gas & Electric. They've have been fighting a state program that gives people a financial incentive to go solar, saying it has forced non-solar homes and businesses to spend millions of dollars subsidizing their solar-powered neighbors.

Solar advocates reject those claims, saying any subsidy is small if not nonexistent. They also say utilities fail to account for rooftop solar's main benefits: that it reduces human-caused climate change, and that it limits the need for new power plants and transmission lines. But even the technology's staunchest defenders acknowledge that California can't keep incentivizing rooftop solar at current rates forever. Eventually, policymakers will have to figure out how to allocate the costs fairly, and that could involve new charges for solar customers.

"I think there’s a need to come up with something that doesn’t penalize solar, but allows utility companies to recoup some of their investments," Martinez-Morales said.

The NREL study could provide ammunition for opponents of large-scale solar, who say big solar farms such as Desert Sunlight and Ivanpah have harmed species and ecosystems in the California desert. Many of those critics believe California should fight climate change exclusively through rooftop solar, which has fewer environmental impacts. Large-scale solar supporters have countered that big solar farms can generate electricity more cheaply than small rooftop systems, and that the environmental impacts can be minimized by building large-scale plants in the least sensitive locations.

Gagnon, the NREL researcher, said there are "excellent arguments" for both kinds of solar.

"Some of that rooftop area would be great in terms of cost effectiveness," he said. "Some of it would be less optimal."

NREL researchers estimated the country's rooftop solar potential by examining specialized aerial images — known as light detection and ranging, or LiDAR — for 128 cities, including Los Angeles, St. Louis and Buffalo, and then extrapolating their results to the rest of the country. The research lab didn't have access to LiDAR data during its previous analysis of rooftop solar potential, which is one of the reasons the estimates changed so much from 2008, Gagnon said. The estimates also went up because solar panels are much more efficient now than they were a decade ago, and because there are more buildings now than there were then.

Researchers estimated that "small buildings" — homes, for the most part — account for 65 percent of the country's rooftop solar generation potential. In California, that number is 59 percent.