GithubHelp home page GithubHelp logo

merge two GTFS files about gtfs2gps HOT 6 CLOSED

ipeagit avatar ipeagit commented on July 28, 2024
merge two GTFS files

from gtfs2gps.

Comments (6)

rafapereirabr avatar rafapereirabr commented on July 28, 2024

I've added a new function merge_gtfs_feeds to our package (commit 55eda53 ) . This is just a starting point, I believe we can improve the function from here. As it stands, the function does not check for duplicated IDs.

from gtfs2gps.

pedro-andrade-inpe avatar pedro-andrade-inpe commented on July 28, 2024

Nice! I only don´t know whether we should consider the question of GTFS files with and without frequencies. Could GTFS files of these two types be merged?

from gtfs2gps.

rafapereirabr avatar rafapereirabr commented on July 28, 2024

Merging two GTFS feeds of different types (detailed and frequency based) is not a problem per se. However, our core function gtfs2gps currently does not work well with mixed-type GTFS feeds. As it stands, the function assumes all data in a feed are of a single type. We know from the data of Rio de Janeiro, however, that a single GTFS feed might have some trips/routes organized in one way or another. I have created a separate issue for this. This should be fun to tackle.

from gtfs2gps.

rafapereirabr avatar rafapereirabr commented on July 28, 2024
  • Add ERROR if there are any route_id or stop_ids shared between different GTFS feeds
  • test output 1 (merging 2 GTFS feeds) and output 2 (getting the gtfs2gps outputs of two files)

from gtfs2gps.

rafapereirabr avatar rafapereirabr commented on July 28, 2024

quick approach to check overlapping values

spo <- system.file("extdata/saopaulo.zip", package = "gtfs2gps")
poa <- system.file("extdata/poa.zip", package = "gtfs2gps")
gtfs_list <- list(spo, poa)

# read all feeds
all_feeds <- lapply(gtfs_list, read_gtfs)


##### STOPS ----------------------

# extract stops from all GTFS feeds
stops <- sapply(all_feeds, "[", 'stops')

# extract stop ids
stop_ids <-  sapply(stops, "[[", 'stop_id')

# check inersection between ids
output_intersect <- Reduce(intersect, stop_ids)

# if there is any overlap
if( length(output_intersect) = 0){ 
  stops <- rbindlist(stops, fill = T)
    }



##### AGENCY ----------------------
# extract stops from all GTFS feeds
agency <- sapply(all_feeds, "[", 'agency')

# extract stop ids
agency_ids <-  sapply(agency, "[[", 'agency_id')

from gtfs2gps.

rafapereirabr avatar rafapereirabr commented on July 28, 2024

then we need to update the trips, routes, shapes and stop ids:

for(i in 1:length(agency_ids)){
 stop_ids[i] <- sprintf("%s_%s", agency_ids[[i]], stop_ids[[i]])
 # route_ids[i] <- sprintf("%s_%s", agency_ids[[i]], route_ids[[i]])
 # trip_ids[i] <- sprintf("%s_%s", agency_ids[[i]], trip_ids[[i]])
 # ...
}

from gtfs2gps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.