gtfs2sldf: Import GTFS shapes and route data to SpatialLinesDataFrame.

Description Usage Arguments Examples

View source: R/gtfs.R

Description

Takes a string with the file path of the zip file with the GTFS feed, imports the shapes (geometry), route and agency data and returns a SpatialLinesDataFrame for the GTFS feed.

Usage

1
gtfs2sldf(gtfszip = "")

Arguments

gtfszip

String with the file path of the GTFS feed zip file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
f <- system.file("extdata", "beartransit-ca-us.zip", package = "stplanr")
# update file to latest version
# see https://code.google.com/p/googletransitdatafeed/wiki/PublicFeeds
u <- "http://data.trilliumtransit.com/gtfs/beartransit-ca-us/beartransit-ca-us.zip"
# download.file(u, f)
gtfs <- gtfs2sldf(gtfszip = f)
plot(gtfs, col = gtfs$route_long_name)
plot(gtfs[gtfs$route_long_name == "Central Campus",])
## Not run: 
# An example of a larger gtfs feed
download.file("http://www.yrt.ca/google/google_transit.zip",
                     paste0(tempdir(),"/gtfsfeed.zip"))
yrtgtfs <- gtfs2sldf(paste0(tempdir(),"/gtfsfeed.zip"))
sp::plot(yrtgtfs,col=paste0("#",yrtgtfs$route_color))

## End(Not run)

stplanr documentation built on June 3, 2018, 1:04 a.m.