There are many resources [1][2][3] for geographic data. Learning how to use tools like PostGIS [4], gdal [5], and d3 [6] are well worth the effort.
Hacks like this are great when there is no other way around it, but I can't help but imagine that it would have been a much easier problem to solve using some of these existing data sets and tools.
When given the option to attempt a novel hack like the original poster's keep in mind that the skills learned while solving the problem with existing tools and workflows will be very valuable the next time you need to do any GIS related work!