SAN FRANCISCO — A federal judge cleared the way Tuesday for San Francisco to ban most displays of public nudity, ruling that an ordinance set to take effect Feb. 1 does not violate the free-speech rights of residents and visitors who like going out in the buff.

U.S. District Court Judge Edward Chen refused to block the ban temporarily or to allow a lawsuit challenging it to proceed. “In spite of what plaintiffs argue, nudity in and of itself is not inherently expressive,” Chen wrote in an 18-page opinion.

The city board of supervisors voted 7-4 last month to prohibit residents and visitors older than 5 from exposing their genitals on public streets, in parks or plazas or while using public transit.