More than eight million people live in the five boroughs of New York City. They have more than 150 elected legislative representatives, from the local level to Congress. Keeping tabs on the people who represent you is a difficult task.

That’s the idea behind Represent, an interactive feature we launched in beta last week. Using your address as a starting point, Represent figures out which political districts you live in and who represents you at different levels of government. It draws maps that show how where you live fits into the political geography of the city. And using information collected from around the Web, it presents a customized activity stream that tracks what the people who represent you are doing.

Represent crawls a collection of New York Times stories and City Room blog posts, looking for references to public officials. It also draws from official data sources — currently, Congressional roll-call votes, which we collect by parsing feeds and scraping government Web sites. It evaluates each article, blog post and vote to find the stories most relevant to you. (Both our article search and our Congressional votes database will soon be available to outside developers through free, open APIs.)

Represent is in beta. When new elected officials take office in early 2009, we’ll be tracking them too. We welcome your feedback on how to make it a more useful service.

Geographic computing

We built Represent with Django, the Python web framework. Although we do most of our work with Ruby on Rails, we chose Django for this project so we could use GeoDjango, an add-on that supports geometry fields and extends the ORM to allow spatial queries.

We started with maps from New York City’s Department of City Planning showing district boundaries for City Council, State Assembly, State Senate and the U.S. House of Representatives. We used the Geospatial Data Abstraction Library, a translator library for raster geospatial data formats, through GeoDjango’s LayerMapping class to populate a PostgreSQL database extended with the PostGIS spatial extension. The geometry relationship functions provided by PostGIS allow for quick, accurate lookups to determine which legislative districts contain your address.

Represent shows you your address in relation to each of the political districts that contain it. To draw the maps of your districts, we used GEOS, a C++ port of the Java Topology Suite, an API for modeling and manipulating 2-dimensional linear geometry, via GeoDjango’s GEOS API. GEOS allows for the conversion of a geometry to KML, which can then be consumed by Google Maps.

But to do all that, we need an address: yours, hopefully, if you live in New York City. To turn that address into coordinates, we built a geocoding service based on Geo-Coder-US, the perl library that powers geocoder.us.

Update: Wired.com gives us props.