To put this in perspective let's take a look at some other cities. (I have left off the numbers behind the decimal)
Los Angeles California : Square miles-468, population- 3,857,799, persons per square mile-8,092
Dallas Texas: Square miles- 340, population-1,241,162, persons per square mile-3,517
New York City New York: Square miles 302, population- 8,336,697, persons per square mile- 27,012
Miami Florida: Square miles-35, population- 413,892, persons per square mile- 11,135
Washington D.C: Square miles- 61, population- 632,323, persons per square mile-9,856
My current home Jacksonville Florida- Square miles- 747, population- 836,507, persons per square mile-1,100
Across the bay from San Francisco, Oakland California: Square miles- 55, population-400,740, persons per square mile-7,004
Of those cities the ones closest in size would be Miami, Oakland and Washington D.C and their persons per square mile are extremely low in comparison to S.F. Population wise the only city that compares would be Jacksonville, and it has a meager 1,100 persons per square mile. Living in or close to both of these cities for most of my life, S.F.-19 years and Jacksonville- 14 years I believe San Francisco to be a cleaner city although Jacksonville is a fairly clean city but 747 square miles is a lot to keep up on.
I can only think the trashcans and ashtrays posted sporadically throughout S.F. have something to do with the cleanliness of the city. Where ever I went I always had a place close to throw my trash away. In Jacksonville I feel I'm on a hunting spree when I have trash to toss. I also believe both these cities being so close to oceans have something to do with air quality. There is nearly constant winds that blow through S.F. not so much in Jax as the air seems to hang thick and heavy although ocean breezes can be felt on occasion sweeping through the air.
I did some further research According to http://www.forbes.com/2008/03/17/miami-seattle-orlando-biz-logistics-cx_tvr_0317cleanest.html Miami was named cleanest U.S. city with Jacksonville coming in at number three, and San Francisco at number six. The other cities I listed didn't even rank. This ranking and article was based air quality, water quality and street cleanliness.
According to http://www.rd.com/advice/travel/americas-top-5-cleanest-cities/ San Francisco came in at number five, none of the other cities were listed. The article was also based on air, water and street cleanliness.
Kudos to San Francisco on being one of the smallest large cities in the U.S. and maintaining limited pollution. If you haven't visited the city yet now you have one more reason to do so.