CTA transit map

Lots of people have them. I like mine. Check it out.

How I did this:

  • Installed PostgreSQL and PostGIS
  • Tried to load data from the City of Chicago Maps SHP file.
  • Discovered the City uses a weird, us-ft based projection. Installed proj4 to reproject data.
  • Reinstalled postgis to get proj4 support.
  • Realized that doing reprojection inline was crazy, and I couldn’t figure out the right incantation anyway. Installed gdal, which includes a tool called ogr2ogr.
  • Recreated my map database schema with ogr2ogr with the following incantation: ogr2ogr -f PostgreSQL -t_srs EPSG:4326 PG:dbname=maps srcdir. Explanation: -f PostgreSQL specifies output format; -t_srs EPSG:4326 says to translate coordinates from the input spec (which it can read from the .PRJ file) to the standard EPSG mapping #4326 which is mercator lat/long; srcdir contains the unzipped SHP/PRJ/DBF files.
  • Wrote a python script that outputs javascript to create routes and points for lines and stations.
  • Added a zoomlevel field to the stations, a relative ranking of importance/crowdedness, added support for that to the javascript. Once you get to zoom level 4 (two levels in from the starting level) all stations are visible. As you zoom out you see only major stations, then only endpoints, then the airports and Clark/Lake, then just Clark/Lake.
  • PROFIT!

Note that this does not query the database in realtime, once the page is loaded everything is client side. The database is only used for semi-permanent storage of custom markers like zoomlevel and as a reasonably easy way of accessing the data (I’m better with postgres data APIs than I am with csv or parsing shpfiles or whatever).

12 Comments

  1. John Garcia
    Posted October 3, 2005 at 12:18 pm | Permalink

    Cool work! Which reminds me I have to hack this google map API. Thanks for the instrcutions.

  2. Anonymous Commuter
    Posted October 3, 2005 at 11:58 pm | Permalink

    this is incredibly cool – you, sir, are a prince among coders.

  3. Posted October 4, 2005 at 12:14 am | Permalink

    FYI: I wouldn’t reuse my GIS data from the javascript src. It’s been flattened in spots, and excessively so in a few spots.

    Round two — Bus maps — is going to be much harder.

  4. Jeremy
    Posted October 5, 2005 at 6:38 pm | Permalink

    Very nice. One problem… there’s no way to pinpoint where you’re trying to get to. Any way to add search capabilities?

    Google maps really needs to add bike paths and public transport (at least trains) to their base site.

  5. Posted October 8, 2005 at 1:07 am | Permalink

    Nice blog.I like this.
    Nick
    http://www.yahoo.com

  6. Posted October 10, 2005 at 9:46 am | Permalink

    Looks good. I did a CTA map months ago – http://www.tastypopsicle.com/maps/cta.asp. When I did mine I had no idea that the CTA has all of the points for their track plotted out already. I unfortunately had to use a lot of time plotting individual points around the track by hand. Good job on the Blue and Green lines. Where they split is a doosey because, as you saw, you actually have to treat those as separate lines. Otherwise, Google tries to pplt the end points together.

    I’d love to see you points that you were able to convert from the CTA to see how close I was able to get to it.

  7. Posted October 10, 2005 at 10:14 am | Permalink

    If you view source you can see my line data, it’s packaged in its own javascript file. I like your map quite a bit, Ed, in fact that’s where I got the idea to use circles for stations instead of the stock google red markers. :)

  8. Posted October 10, 2005 at 2:42 pm | Permalink

    Ahhhh! I see. What I enjoy is how we approached the same idea, but if you look at the implementation (ie. the javascript and XML) we came up with 2 completely different methods (arrays vs separate “points”).

    Oh, and the circles “just work”. I used the markers at first and it looked terrible. Someone on the Google Maps discussion group said I should try circles for stations and it does make the whole map more attractive.

  9. Posted January 10, 2006 at 9:02 am | Permalink

    I’d like to add this site to my list of Chicago-area Googlemaps, if that’s possible. Would it be ok to post a link on my site to your map?

    Thanks,
    Chris

  10. Posted January 13, 2006 at 2:37 pm | Permalink

    Chris, that’s fine .. where is that site, out of curiosity?

  11. yaniv
    Posted September 14, 2006 at 2:42 pm | Permalink

    Is it possible to download this app as an extension in Google Earth?

  12. Posted September 14, 2006 at 2:54 pm | Permalink

    The El lines are already available in google earth, no separate kml file necessary.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*