Represent and GeoDjango

Dec 19 2008

For more details on Represent, see our post on the NYT’s Open blog.

Today (well, technically last night) at work we launched a beta Web application called Represent that helps New York City residents keep tabs on what their elected officials are doing. It’s the product of an idea that my colleague Andrei Scheinkman suggested when we sat down in the late Spring to kick around ideas for the Times’ internal technology challenge. We ended up being a finalist with our entry, which became the app you see today, thanks to design work by Stephan Weitberg and advice from a lot of folks.

Since Andrei and I both liked Python, and the contest asked for a working prototype, we built Represent using GeoDjango, the part of Django that makes spatial work easy enough that even I can manage it. This is my first time really dealing with GIS data, and probably the hardest part was getting all the dependencies installed the first time (after you do it once, the install becomes fairly routine, and on the latest Ubuntu version it’s simple).

So if you’re thinking about going the GeoDjango route, or trying it out, I’d offer these suggestions:

  • Go with Ubuntu Linux as your OS. It’s just easier. You can run GeoDjango on Windows, but I think I hate the Postgres Windows install and configure process more than just about anything I’ve tried to do on Windows.
  • When installing, do what the docs say. These are written by people who have already installed it. Once you start freelancing, your chance of success goes down dramatically.
  • Make sure that when you install Postgres, you test it out via the psql shell.
  • When in doubt, try the #geodjango IRC channel on FreeNode
  • When things just work, do not be surprised or await a message saying they worked.

Once you get GeoDjango installed - and it might take awhile the first time - you’ll be really impressed with how easy it is to use. I’ve written before about the power of LayerMapping, which is a huge gift to people who want to move from using Shapefiles to using GeoDjango. And there are other goodies, too, like the ability to plug into the GeoIP library to place your site visitors on a map (or configure their content based on that information). For Represent, we needed to produce KML files of each district that would display on the results pages. Turns out GeoDjango does that, too. To my eternal shame, I never really got the hang of working with Arc. Now I have a tool that suits me better.