Bondify / gtfs_functions

Package with useful functions to create geo-spatial visualizations from a GTFS.
MIT License
114 stars 30 forks source link

cut_loops_shapes_ok() -> last_point referenced before assignment #2

Closed Macscroge closed 9 months ago

Macscroge commented 3 years ago

Hi,

I am using gtfs_functions on a dataset of Irish buses, generally working fine except gtfs.cut_gtfs(stop_times, stops, shapes). gtfs.stop_freq() & line_freq() work perfectly and I can map the lines with gtfs_map_gdf with no errors.

This check fails, which leads to last_point not being defined and causing an error on line 508

if segment.intersects(cut_lines[0]): # line 493 gtfs_funtions.py

The dataset looks okay, no missing data, no missing columns. But I am new to GTFS so may be wrong. The bus routes are several km each so I don't get why it's failing. Would you have any idea what I am doing wrong? I've attached the data set if that's any help. Thanks. cork.zip

Bondify commented 3 years ago

Hi @Macscroge, usually, when cut_gtfs fails it's because there's something weird with the shape it is trying to cut. Something very common is that the points of a shape are not physically sorted as their shape_pt_sequence says they are.

srahman16 commented 3 years ago

Hi @Bondify,

I am also experiencing the same issue as @Macscroge. This line is not executing, segments_gdf = gtfs.cut_gtfs(stop_times,stops,shapes)

Here is the data link. Please help if possible.

Kind regards,

Shahriar

Bondify commented 3 years ago

hi @srahman16 , I ran the line in my local and it took a while to execute but it returned the right GeoDataFrame. I saved it as a geojson here: https://drive.google.com/file/d/1W2rMFo9_o5wIIuwpPOgcgQ-7vjgbOPHA/view?usp=sharing

You can try to run the line again and wait until is finished or start your workflow directly from the data in the link.

I hope this helps :)

RJJZitman commented 2 years ago

Hi @Bondify,

I'm running into the same issue with this line the same line of code. This is the link to the data. Or the latest dataset on this page.

Running it in Jupiter it also shows: "The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt. Please visit http://www.java.com for information on installing Java." while I've got the latest version of java installed.

I'd really appreciate your help!

Kind regards, Rogier

Bondify commented 9 months ago

hi @RJJZitman the latest version of the package should fix this