PTNA: news for Public Transport Network Analysis

@NeatNit

I just imported a new version of the IL GTFS data and … it seems that the route_ids are stable, except for ‘Rail’?

Compare 2024-09-20 with 2024-09-12 version

List is arranged by ‘route_id’

An orange background in the

  • first column shows: this is new in the newer version
  • second column shows: this was not found in the newer version
  • other columns shows: what has changed

That’s disappointing. I think route_desc should be stable then. I’m sorry, I don’t have anything useful to add :confused:

I took a few days break, but now back at trying to import GTFS to PTNA. Thought I’d give you a little update. I’ve reached the point where I need to disambiguate routes that have the same ref. When I started writing this comment I thought it was impossible, but now I’ve found a way and it’s just annoying and cumbersome.

There are 5 bus routes with ref ‘1’ in the Haifa sub-district, and 4 of them would need to be disambiguated with from/to labels. Unfortunately the from/to which you can get from routes.txt is not usable for this - it’s too specific, giving the full name of the first/last stop instead of the general name used normally. But it turns out trips.txt has usable labels for destinations. So I need to keep the destination for forward trips and the destination for backward trips, and use that to disambiguate. I’m kinda losing my patience for this… But if I manage to keep myself together, it shouldn’t be much longer until I have some form of useful output.

Yeah, that’ll be the tricky part. As mentioned before: DE-SN-VMS has 11 times ref=‘A’

  • the CSV data has 11 lines with ‘A;bus;
  • in such cases, PTNA evaluates the ‘operator’ data in the CSV and compares it with the ‘operator’ tag in OSM
    • A;bus;;;;OP1
    • A;bus;;;;OP2
    • A;bus;;;;OP3
    • A;bus;;;;OP1
  • if this is not sufficient, then PTNA also compares ‘from’/‘to’ in the CSV data with the ‘from’/‘to’ tags in OSM (and ‘from’ with ‘to’, …). If there is a match for a route relation, then the route_master and all sister/brother routes are taken into consideration as well
    • A;bus;;from1,to1;OP1
    • A;bus;;from2;to2;OP1

What does this mean for you?

  1. the CSV ‘operator’ can be obtained from GTFS ‘agency’
  • the ‘agency’ must then appear also as OSM ‘operator’
  1. the CSV ‘from’ and ‘to’ can be obtained from GTFS trips
  • route variants must be embraced by a route_master
    • you said, this can be achieved in GTFS by analysing route_descr?
  • at least one OSM relation’s ‘from’ and ‘to’ must match with CSV ‘from’ and ‘to’
  • CSV ‘from’ and ‘to’ should then be derived from a single GTFS trip as stop_name of the first and last stop
  • A match exists if CSV ‘from’ is substring of OSM ‘from’ and vice versa and CSV ‘from’ with OSM '‘to’ and so on
  • CSV ‘from’ and ‘to’ may include ‘|’ as the OR sign, so you can add all stop_name of all relevant GTFS trips’ first stop into the CSV ‘from’, same for ‘to’ with last stop

Let’s see whether this is still readable for humans and PTNA and how that works then

Fortunately, we’re only 1 hour apart re. timezones. So, once the code runs, I can check the result manually and by using PTNA and give feed back and you can fix and beautify and …

I just added gtfs anaysis support for public-transport to ptna

1 Like

I just added analysis of public-transport to ptna for

Yesterday I added analysis support for public-transport to ptna for

For FR-BRE-TUDBUS I also added the related CSV data “Lignes TUDBUS” to the OSM wiki based on GTFS data.

gtfs data for all 13 ‘network’ is included in FR-BRE-KorriGo which has been released by PTNA two days (2 posts) ago.

@Patchi @XioNoX

2 Likes

Regarding GTFS → PTNA CSV, progress is slow after I lost some of my motivation with the real-world hell happening right now, but I hope to get back to it now.

I’ve implemented the solution I wanted for disambiguating routes, but the results are not always ideal. Some of the destinations are in the form ‘city_destination’ e.g. ‘חיפה_מרכזית המפרץ’. Others are just not very clear, and in some cases there’s more than one option to choose from so one is selected arbitrarily. That’s a lot of downsides, but this is better than nothing.

So far I’ve made no usable output (just debugging stuff), but now the next step is to make some CSV output. I might allow human mappers to change the from/to labels of routes, without overwriting it. That way we can fix any of the bad labels based on how routes are actually mapped in OSM, while using the initial labels as a guide. The script could identify which route is which based on the gtfs route_ids associated with it.

On the other hand, that sounds like a hard challenge so that cleverness might have to wait for later. Perhaps I should just sprint to making output.

As before, you can see the code here: gtfs2osm-il/ptnaGenerate.py at ptna-import - NeatNit/gtfs2osm-il - Codeberg.org

1 Like

Thanks, that looks good. And: no need to code for SQL, raw GTFS files are welcome as well and still do exist during/after the import.

I’d have a different approach for def get_stop_codes(): though.

Do not search for OSM stops in the area.
Instead, select/search GTFS stops who’s lat/lon is in that area and select the GTFS trips and GTFS routes stopping there.

Overpass API or OSM API should be used only to get the polygon data of the area of interest.

Or do I misunderstand that part?

No, you’re right. The use of Overpass is a placeholder.

Relatify now supports route=tram for public-transport editing.

ptna will add appropriate links for each tram route.

#relatify tools editors

6 Likes

I’ve added the bus lines generated from my code to the wiki page: Israel/Public Transport/PTNA/IL-HA-Haifa-Routes - OpenStreetMap Wiki

I want to see the output in PTNA :slight_smile:

There’s still work to do, the code is by no means done. I just wanted to see how the results go.

Not too bad, looks good indeed. There are only 4 routes (ref) which could not be assigned to a CSV entry PTNA - IL-HA-Haifa

There are many missing routes, I guess due to that fact that the CSV list covers Israel whereas the search area is limited to Haifa?

1 Like

No, it’s because public transit routes just aren’t mapped enough in Israel. I believe Jerusalem will fare better, but I still expect significant missing routes.

I just made an edit to replace “_” with " - ", I hope this will resolve a couple of the unassigned routes.

This makes me realise: The RNN region is outdated as Wackernheim and Zornheim (both in Mainz-Bingen) are part of the VMW tariff zone (i.e. located in RMV, not RNN). I’ve already updated the relation a month ago it but that has yet to be updated in PTNA.

Looking good now. The remaining buses 9 and 14 cannot be assigned: ‘operator’ in relation is in ASCII, in CSV is in Hebrew.

From PTNA’s point of view that is not a problem, if the search area includes more villages.

I just added analysis support for public-transport to ptna for

I just added analysis support for gtfs data to ptna for

Remark:

  • the stop data of this “GTFS Sweden 2” data does not specify the pole’s lat/lon but rather represents the stop area
  • we’re working on using the “GTFS Sweden 3” data which includes shape data and precise positions of the platforms. This requires creating an account and requesting an API key which I want to avoid.
2 Likes