It's not exactly like for like, but compare these maps of available public restrooms in SF and NYC:
- NYC: http://m3.mappler.net/nyrestroom/
- SF: https://www.google.com/maps/d/u/1/viewer?mid=1xRGER_GLPdRdOA...
No disagreement as to the opiate issues in SF exacerbating the problem, but it seems reasonable to think that anyone (drug problem or not) would prefer to use a bathroom than squat on a sidewalk.