As floodwaters rose in Baton Rouge and surrounding parishes in August, municipal police and sheriff's deputies dropped radar guns and ticket books to help rescue folks from their flooded homes. With interstates closed for days on end, fewer reckless motorists zipped by speed traps or swerved between lanes to be pulled over by watchful officers.

The officers performed essential work, leaving their lower-priority traffic details to rescue desperate residents and deter looters. Yet the thousands of citations that went unwritten have, months later, continued to leave a crater in the budgets of agencies that depend heavily on traffic fines and fees to fund their operations.

Those agencies include local public defenders, where a majority of their revenue comes from a $45 fee tacked onto traffic tickets. The offices of judges and district attorneys have also taken a hit.

Law enforcement agencies regularly redeploy manpower to respond to disasters. Yet the way Louisiana has structured its budget and directed court fees and traffic ticket revenues essentially means that abandoning a speed trap for a rescue boat during a flood can have a significant impact on numerous other agencies much later.

The revenue collected from fines and fees is dedicated to a variety of purposes, such as compensating crime victims, paying for training and certification for law enforcement officers, providing drug-abuse education, providing attorneys to represent the poor and funding a state-run trust that covers services for victims of traumatic head or spine injuries.

It wasn't just the flood, though, that had an impact.

Protests and demonstrations over the fatal shooting of Alton Sterling in Baton Rouge on July 5 also appeared to have triggered a steep drop in the number of tickets written in the area as hundreds of police officers worked lengthy shifts and were redirected to control the crowds.

Some law enforcement agencies that usually sent cops to patrol the streets solo — including the Baton Rouge Police Department — decided to pair officers in patrol cars for safety reasons during that tense period, reducing the number of cruisers on the road.

And in some jurisdictions, including St. John the Baptist Parish, agencies cut down on traffic stops to avoid what they feared might turn into risky confrontations.

In Baton Rouge City Court, where all tickets written within the city limits are handled, the number of traffic cases collapsed.

Traffic tickets written in July fell to just 38 percent of the number issued in the same month the previous year. In August, as floods swamped the area, filings fell even further, with only 22 percent as many tickets issued as in the same month in 2015.

For the year, the number of tickets processed through the court — which provides most of the local funding for the parish's public defenders — dropped nearly 40 percent.

Tickets issued by State Police troopers working out of Troop A, an eight-parish district that includes Baton Rouge and the surrounding capital region, also dropped dramatically. Troopers wrote less than half as many tickets in July, August and September of 2016 as they had the year before as they patrolled protests in Baton Rouge and responded to floods.

"The revenue from court costs is our life-blood," said Mike Mitchell, the chief public defender for East Baton Rouge Parish, whose office has cut back on staff and refused some complex and expensive cases because of budget shortages. "Our office has taken a substantial hit."

Mitchell said the hit to his budget comes amid a years-long decline in court revenue for his office that he can't fully explain. Even before the Sterling protests pulled traffic cops off their beats, monthly city court revenue for Mitchell's office was at its lowest levels in years.

But the drop that began to hit in August, when tickets written in July would've started to be paid, turned that slight drop into a precipitous fall.

Without a serious influx of funds from the state — an unlikely proposition, considering strained budgets at the state Public Defender Board and throughout state government — Mitchell said his office may be forced to adopt a waiting list for criminal defendants too poor to hire their own attorneys.

"We'd already cut to the bone, as much as we could," Mitchell said. "We're operating at a bare minimum right now."

The floods and protests wound up costing the East Baton Rouge District Attorney's Office between $100,000 and $200,000 in court revenue out of a roughly $1.2 million budget, said Mark Dumaine, the chief of administration for District Attorney Hillar Moore III. Dumaine added that the office also saw the number of criminal cases drop by about 4,000 compared to previous years.

But Dumaine noted the budget for the public defenders suffered a far more severe blow.

Natural disasters such as hurricanes and floods can wreak particular havoc on the budgets of local public defenders, which receive the lion's share of their funds from traffic tickets and which have been forced to spend down reserves in recent years in response to funding shortfalls.

Jay Dixon, the state public defender, said the crises unleashed by the floods for the public defenders in East Baton Rouge and Livingston parishes point toward what he describes as the fundamental flaw in paying for legal representation for the poor through traffic tickets.

"This is the inherent instability and unreliability we have in our system," said Dixon. "No district has any idea how much money they're going to receive locally. An act of God can affect our budget. A spat between the district attorney and the sheriff can affect our budget. We're completely at the whim of weather and politics."

In Livingston Parish, public defenders also lost thousands of files and dozens of computers when rising water rushed into their offices, said Reggie McIntyre, who's headed the 21st Judicial District's public defender office for the past 18 years. McIntyre said attorneys had to destroy the soggy files and put in long hours rebuilding their case notes.

Though some court fees owed by defendants have been paid up since clerk's offices and local courthouses reopened in Denham Springs, Walker and other hard-hit areas, McIntyre said, much of the lost court revenue will likely never be made up.

He estimated his office — which also covers St. Helena and Tangipahoa parishes — lost several hundred thousand dollars in revenue as a result of the floods, a budget shortfall he made up in part by leaving several job openings vacant for months. He also burned through reserves, which McIntyre said will likely be entirely spent by the end of his fiscal year in June.

"It cut into us pretty good," said McIntyre. "I've got my CPA checking every month to make sure we're going to make it."

Follow Bryn Stole on Twitter, @BrynStole.