Tag Archives: perl

NYTimes on using GeoDjango

Nice work NYTimes.

Open: Represent:

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.