Officials in San Francisco last week sought to sweep out one of the city's more conspicuous tent cities, declaring the area a health hazard in need of a cleanup.

Dozens of homeless people have been camped out on sidewalks beneath a freeway near downtown. The city's decision came after residents and business owners complained for weeks that the homeless encampment made them feel unsafe.

The incident highlights the difficulties that city officials face when they try to keep people from sleeping in public spaces. Forcing homeless people to move along is a time-honored urban tactic, but advocates for the homeless -- and federal officials -- contend that it's a shortsighted policy.

“Criminalization of homelessness is essentially lazy policymaking,” said Eric Tars, an attorney with the National Law Center on Homelessness and Poverty. “You’re being confronted with constituents who are saying, ‘We see homeless people on the street and they make us uncomfortable. What are you going to do about it?’”

In San Francisco, health inspectors say the Division Street encampment is unsafe and unsanitary.

“People are living without access to running water, bathrooms, trash disposal or safe heating or cooking facilities,” said the Department of Public Health in a written statement. "The encampments ... are unsanitary due to accumulation of garbage, human feces, hypodermic needles, urine odors and other unsanitary conditions."

But Phillip Matier and Andrew Ross, columnists with the San Francisco Chronicle, cite City Hall sources who concede that "having the health department take the lead on declaring Division Street uninhabitable was intended in part to deflect criticism that [Mayor Ed] Lee’s administration is criminalizing homelessness."

The Lee administration recently opened a 100-bed shelter it hoped would attract some of the people living in the Division Street encampment. Since giving notice about the sweep, an outreach team has placed at least 27 adults in shelters, according to Rachael Kagan, a spokeswoman for the public health department. Shelters have space for more, she said.

Even though the city gave people in the encampment three days to relocate, Public Works employees arrived early to clean the sidewalks. The Coalition on Homelessness, a San Francisco nonprofit, documented city workers throwing away a tent and a walker, despite a city policy to tag and store people's belongings. The Lawyers' Committee for Civil Rights of the San Francisco Bay Area condemned the sweep as illegal and suggested that the city compensate people for the destruction of their property. As of Sunday afternoon, police hadn't arrested the few dozen holdouts who remained in the area after the health department's Friday deadline.

Even though the city gave people in the encampment three days to relocate, Public Works employees arrived early to clean the sidewalks.

The clearing of homeless encampments is hardly unique to San Francisco. City officials from Baltimore to Honolulu have sought to remove clusters of tents and relocate the inhabitants to shelters, permanent housing or just somewhere else out of sight.

Last summer, Baltimore Mayor Stephanie Rawlings-Blake drew criticism from homeless advocates when the city cleared an encampment beneath an underpass. As in San Francisco, city officials said they were doing it out of concern for the well-being of the inhabitants.

Part of what rankled advocates in Baltimore was the abrupt nature of the sweep. Usually the city gives advance notice so service providers can try to help the people being forced to move.

But the bigger issue is providing permanent housing for those who feel shelters are less sanitary and safe than the streets, said Joe Surkiewicz, a spokesman for the Baltimore-based Homeless Persons Representation Project.

“It’s very disingenuous for a city to say, ‘Well, you’ve got to move to a shelter,’ because they won’t,” said Surkiewicz. “The city is just moving people around.”

A mayoral advisory board actually sided with advocates and providers, recommending that Baltimore hold off on any more encampment razings until it could guarantee rental vouchers for the displaced people.

Last year, Boise, Idaho, faced a legal challenge to its “sleeping ordinance,” which banned camping on streets, sidewalks, parks and public places. The plaintiffs in the case, people who are or were homeless, argued that enforcement of that ban was tantamount to criminalizing homelessness. A federal judge dismissed their suit, though, on the grounds that the homeless individuals lacked legal standing. By that time, the U.S. Justice Department had weighed in, calling anti-camping ordinances “both unconstitutional and misguided public policy.”

Even when they survive legal scrutiny, clearance policies aren't going to be cost-effective.

In Honolulu, for example, the city spends $15,000 a week to clear homeless encampments. “Criminalization is the most expensive and least effective way of addressing these problems,” said Tars of the National Law Center on Homelessness and Poverty.

A man carries debris to a garbage truck after packing up his tent along Division Street.

San Francisco, one of the most expensive cities in the country, is among more than a dozen large urban areas that have seen an uptick in homelessness since the Great Recession, according to data collected by the U.S. Department of Housing and Urban Development. San Francisco’s homeless population grew 16 percent between 2009 and 2015, while homelessness steadily declined nationwide over that same period.

The problem appears to be most acute in a few cities with hot real estate markets and a shortage of affordable housing. Last fall, mayors in Portland, Seattle and Los Angeles said homelessness had reached a crisis point and asked for state and federal assistance in tackling the issue.

Tars said there are ways for cities to clear encampments without raising the hackles of homeless advocates and civil liberties groups. He pointed to a bill now being considered in Indianapolis, which lays out a process for removing tent cities that takes into account the needs of homeless individuals. The city would have to give advance notice of a clearing, provide people with a temporary place to store their belongings during the move and connect them with nonprofits to help find housing and other support services.

While some local governments still resort to sweeps, federal officials are pressuring them to find other ways of dealing with homeless encampments. The U.S. Interagency Council on Homelessness published guidance papers last year that called forced dispersal of encampments “not an appropriate solution.”

In December, the Office of Community Oriented Policing Services criticized the use of officers in forcibly removing the homeless from public areas.

“Arresting people for performing basic life-sustaining activities like sleeping in public,” the newsletter said, “takes law enforcement professionals away from what they are trained to do: fight crime.”

Perhaps the most concrete step taken so far by federal officials is a new question inserted last year in applications for a $2 billion grant program from the Department of Housing and Urban Development. Local governments now get higher scores if they demonstrate ways they are preventing the criminalization of homelessness.