Yesterday afternoon and last night I spent more time than is strictly necessary on figuring out how to use the Census’s GIS API to return GeoJSON so that I could draw maps on web pages.

Long story short, my map of Schenectady County was perfect. The code for automatically scaling the bounding box was flawless, and my map would fill the entire SVG element. On the other hand, the map of San Diego County was wrong, wrong, wrong, wrong, wrong. Sure, it was centered in the box, but the map was tiny. This happened for every non-Schenectady County that I tried. Albany County? Fail. Broome County? Fail. Oneida County? Fail.

Why, why, why is the only county that works the county that I grew up in?

I figured maybe something was being cached somewhere, since most of the original just-get-it-to-work-in-the-first-place-darnit code was written with Schenectady County hard-coded into the script. Search for the letter combination “sc” everywhere in the file; it only shows up in script tags. Search for the magic numbers 36 and 93. Nothing.

Hard reload. Clear cookies, cache, and local storage. Try a different browser. Download a new browser and use igcognito mode. Still broken.

I opened the other laptop and opened the pages over my local network. Still broken.

Was my router caching the responses from the API? I put the files In The Cloud (maybe they are still here in /maps/foo.html and /maps/bar.html) turned off the wifi on my phone and viewed them over my phone’s data connection. Still broken.

There’s got to be something about Schenectady.

Outside of New York City, Schenectady County is the smallest county in New York (geographically). And not a lot of people live there, so there are not a lot of census tracts or census block groups or other people-containing geographic features. Schenectady County is small enough and sparsely populated enough that the API is able to return the GeoJSON without timing out or throwing an error. The other counties were all larger and/or more populous, and the error from the server was being read in by the map-scaling code.

Next up, I picked a county in Rhode Island. Works perfectly.