gtfs-geojson is a Ruby utility to convert the shapes.txt file of a GTFS feed into a GeoJSON file. It uses the GTFS gem to validate GTFS feeds and wrap the feed data into usable objects. Two command-line utilities are also included with a gem install.
Add the following to your Gemfile.
gem 'gtfs-geojson'
or install the gem through the command line.
gem install `gtfs-geojson`
Convert a GTFS feed shapes.txt file into a GeoJSON file.
gtfs_to_geojson gtfs.zip output.geojson
Print a human-readable form of a GTFS-realtime feed.
gtfs-rt_to_json http://developer.mbta.com/lib/GTRTFS/Alerts/VehiclePositions.pb positions.json
require 'gtfs-geojson'
geojson = GTFS::GeoJSON.generate("gtfs.zip")
File.open("gtfs.geojson",'w') do { |f| f.write(geojson) }
To develop locally, clone the repository and run bundler to setup the necessary gems.
bundle install
bundle exec rake
bundle exec rake coverage