This repository has been archived by the owner on Aug 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
74 lines (55 loc) · 1.46 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
cache = FALSE,
comment = "#>",
message = FALSE,
error = FALSE,
warning = FALSE,
fig.path = "README/README-",
fig.width=7.3,
fig.height=5,
out.width = '100%'
)
```
## Description
`gtsf` is an R package for using GTFS data as [simple features](https://en.wikipedia.org/wiki/Simple_Features). You can also use it to make shapefiles and geojson from GTFS data.
## Installation
You can install this package from GitHub using the devtools package:
```
if (!require(devtools)) {
install.packages('devtools')
}
devtools::install_github('r-gtfs/gtsf')
```
## Example Usage
Import transit lines from the NYC Subway using `trread`.
```{r readme-body}
library(trread)
library(gtsf)
library(dplyr)
NYC <- import_gtfs("http://web.mta.info/developers/data/nyct/subway/google_transit.zip")
```
## Get Simple Features
```{r}
NYC <- gtfs_as_sf(NYC)
```
This adds two simple features dataframes to the list of GTFS objects:
-stops_sf
-routes_sf
## Make Maps
These can be mapped with various libraries. For example, with the [tmap](https://cran.r-project.org/web/packages/tmap/vignettes/tmap-nutshell.html) package:
```{r}
library(tmap)
routes_sf <- NYC$sf_routes
qtm(routes_sf)
```
## Export (GeoJSON/Shapefile)
They can also be exported to geojson, for use elsewhere. For example:
```{r}
library(sf)
st_write(NYC$sf_routes,"nyc_routes.geojson", delete_dsn = TRUE)
```