“I won’t speak for the mayor,” he said, “but I do think it was a learning experience for us.”

The mayor has said the current effort could reduce the number of people in the city’s main shelter system by 2,500 over the next five years. The administration’s belief is that people will be better positioned to return to permanent housing if they are in purpose-built shelters near family and community anchors, like churches and schools, instead of being sent to hotels or stopgap apartments far from where they had been living.

The mayor’s plan calls for adding 18 new shelters this year to a system of more than 275 throughout the city. To make such an undertaking work, City Hall officials will need to go neighborhood by neighborhood to address local opposition, hoping to avert large, damaging protests. In an effort to be more transparent, the city is giving communities 30 days’ notice before a shelter opens, an increase from one week.

Emma Wolfe, a top aide to the mayor, said the strategy was intended to make those discussions easier. “It makes it a much more logical conversation,” she said. “Even if you’re going to have some sites where there’s a massive flare-up.”

Some level of opposition will always materialize. The city was forced to delay the opening of a men’s shelter in Crown Heights, Brooklyn, after a judge in State Supreme Court in Brooklyn issued a temporary restraining order on Friday in response to a lawsuit filed by several residents and civic organizations.

According to the lawsuit, the city is “foisting yet another” shelter on Crown Heights, a largely West Indian and African-American community, in order to avoid “the vocal criticism of the affluent and largely white citizenry” in other neighborhoods. The matter is to be heard before Justice Katherine A. Levine on Tuesday.

Though gentrifying, Crown Heights remains one of the city’s poorer neighborhoods, and Mr. de Blasio’s math — intended to match new shelter capacity with the communities where the homeless are most prevalent — will give wealthier, whiter communities fewer shelters than poorer ones.