Those envisioning July 4 celebrations at the beach may be swimming at their own risk, according to a new study that found the number of beach closures nationwide due to dirty water soared last year.

The Natural Resources Defense Council, which released its annual report Wednesday, found that beach closures and advisories across the country increased by 29 percent in 2010 compared to a year earlier. The conservation group used data from 3,000 locations nationwide and found that waters in Louisiana, Ohio, Indiana and Michigan had the highest levels of contamination.

Virginia came in at No. 12 and exceeded the EPA’s contamination level 5 percent of the time, up from 3 percent in 2009. Maryland came in at No. 16 and went over the recommended standards 7 percent of the time, also up from 3 percent in 2009. Delaware had among the cleanest beaches, ranking fifth with 3 percent of samples above standards, up slightly from 2 percent in 2010.

Beaches where violations were most frequent were concentrated in Newport News and King George and Mathews counties in Virginia and Kent and Cecil counties on the upper Chesapeake Bay in in Maryland. One beach in Kent County had contamination closures or advisories for 71 days in 2010.

“It’s a summer rite of passage,” said David Beckman, a senior attorney who directs the nonprofit’s water program. “Unfortunately it can also make you sick.”

Eleven percent of California’s beaches reported elevated levels of bacterial contamination, the largest amount in five years. Among those at the top of the list were Avalon Beach, Cabrillo Beach and Colorado Lagoon in Los Angeles County, Poche County Beach and Doheny State Beach in Orange County and Candlestick Point in San Francisco County.

Most bacterial contamination occurs during winter, when heavy rains overload storm drains and sewage systems, washing waste into the sea.

Swimming in such pollution can cause gastrointestinal, respiratory and other illnesses and is of particular risk for children and the elderly whose immune systems may not be as strong. The Environmental Protection Agency estimates that up to 3.5 million people become ill from contact with raw sewage from overflows every year.

Swimmers are advised not to swim near storm drains or go into the waters within 72 hours of a rain when pollution levels are typically higher.