Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A script/query for creating gtfs_shape_lines table #29

Closed
daphshez opened this issue May 28, 2017 · 1 comment
Closed

A script/query for creating gtfs_shape_lines table #29

daphshez opened this issue May 28, 2017 · 1 comment
Labels
Hackathon Preparation for the upcoming hackathon

Comments

@daphshez
Copy link
Collaborator

daphshez commented May 28, 2017

We are want to add geometry fields to our database in order to be able to run geoqueries using PostGIS.

The task is to create a script that:

  • Creates a new table, gtfs_shape_lines, with two fields: shape_id (INTEGER NOT NULL) and shape_line (geometry)
  • Insert data from gtfs_shapes to gtfs_shape_lines. All the records with the same shape_id should in gtfs_shape should be merged into a single record in gtfs_shape_lines. The line data should be a concatenation of the of the shape_pt_lon & shape_pt_lan fields, ordered by shape_pt_sequence.
  • Optional for extra credit: before loading the line strings, run shape simplification (https://github.com/hasadna/open-bus/blob/master/gtfs/parser/simplifyshapes.py). This should be useful because the data in gtfs_shapes is over sampled.

The script location should be under the /postgres folder in the source code. If you need Python code, put the script under /gtfs/parser

Additional pointers:

  • Use AddGeometryColumn rather than ALTER TABLE (see here why)
  • These are probably the correct parameters for add geometry column: srid = 4326 , type = "LINESTRING"
  • When inserting the data, shape_pt_lon is the X value and shape_pt_lat is the Y value

What's would you need to implement this?

@daphshez daphshez added the Hackathon Preparation for the upcoming hackathon label May 28, 2017
@MYank0
Copy link
Collaborator

MYank0 commented Jun 10, 2017

Query created and saved https://github.com/hasadna/open-bus/blob/master/postgres/postgis_queries.
DB updated with the table.
@daphshez can we close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hackathon Preparation for the upcoming hackathon
Projects
No open projects
Development

No branches or pull requests

2 participants