adrian holovaty

Low-tech edition (Skip to navigation)

May 31, 2005, 2:25 AM ET

Drawing arbitrary GIS data on Google Maps

I just added ZIP-code browsing to chicagocrime.org. A novel thing about it, from a technical standpoint, is that the ZIP code maps (example) display a blue border around the relevant area, so you can tell where the ZIP code begins and ends.

I did this using free GIS data from the City of Chicago. That data defines each ZIP code in the city and its spatial boundaries.

The data comes in standard SHP (shapefile) format, which I imported into PostgreSQL using its excellent PostGIS spatial-database package. PostGIS handles the conversion of the shapefile data to longitude and latitude points in the projection that Google Maps uses.

Next, I fed that list of coordinates through a Python script that encodes latitude/longitude points into Google's proprietary line-generation format. That script is a port of Neil Kandalgaonkar's Perl version. Neil appears to be the guy who reverse-engineered the line-generation format -- an incredibly impressive feat.

With Google's line-generation format calculated, it was just a matter of inserting that chunk of characters in the appropriate place within the Google Maps XML file.

Interesting tidbit: I played with importing the City of Chicago's neighborhood-boundary data, too, but the neighborhood boundaries -- particularly those that touch Lake Michigan -- are made up of so many distinct longitude/latitude points that displaying them on a Google Map crashes the browser when viewed at a close zoom level. The lines generated in that case are simply too complex!

Comments (46) / Permalink

May 18, 2005, 5:46 PM ET

Announcing chicagocrime.org

First, it was Chicago transit maps on Google Maps. Now, I'm very excited to announce chicagocrime.org, an independent side project I've been working on for the past month or so of weekends and nights.

The site is a freely browsable database of crimes reported in Chicago. My scripts collect data from the Chicago Police Department once every weekday. The site slices and dices crime information in a ton of different ways, complete with a wide assortment of Google Maps.

I did all the development, data munging, etc. My talented friend and coworker Wilson Miner did the slick design. The site is powered by the Python programming language.

I'd originally launched it yesterday, anonymously (for privacy/security reasons, as crime is a touchy subject), but I've given it more thought and decided to put my name on it.

The site has already gotten a ton of good press, and it got so much traffic yesterday that I had to improvise a quick caching system. (It's nice and zippy now.)

Some of my favorite features:

To me, the most exciting thing about this site is that (I hope) it gives people helpful and important information in an easy-to-use way.

The second-most exciting thing is that I've got a long list of cool technical things to add. The ink is far from dry on this baby. Make sure to subscribe to the site news RSS feed to keep up. And please send me suggestions if you think of other cool and helpful ways to sort and display crime information.

Comments (43) / Permalink



Thanks for reading.

A Django site.