https://github.com/paithiov909/jprailway
Dataset of Japanese Railway
https://github.com/paithiov909/jprailway
r r-package
Last synced: 6 months ago
JSON representation
Dataset of Japanese Railway
- Host: GitHub
- URL: https://github.com/paithiov909/jprailway
- Owner: paithiov909
- License: cc-by-4.0
- Created: 2023-09-27T14:37:05.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-03T15:35:33.000Z (7 months ago)
- Last Synced: 2025-04-03T16:36:03.291Z (7 months ago)
- Topics: r, r-package
- Language: R
- Homepage: https://paithiov909.r-universe.dev/jprailway
- Size: 38.7 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
pkgload::load_all()
```# jprailway
> Dataset of Japanese Railway
[](https://paithiov909.r-universe.dev/jprailway)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)## Overview
以下のGitHubリポジトリで公開されている、日本の鉄道路線・駅のデータセットを`sf`オブジェクトとして加工したものです。
> [Seo-4d696b75/station_database: スマートフォン位置ゲーム「駅メモ!」で扱う駅データを独自に収集・管理し、二次利用可能な形式で提供します](https://github.com/Seo-4d696b75/station_database)
元のデータセットは[クリエイティブ・コモンズ 表示 4.0 国際 ライセンス](https://creativecommons.org/licenses/by/4.0/)で頒布されていますが、鉄道路線のポリライン情報については「国土数値情報 鉄道データ」を典拠とするため、利用にあたって国土交通省の指示するクレジット記載が必要になります。詳しくは[国土数値情報ダウンロードサイト](https://nlftp.mlit.go.jp)の利用規約を確認してください。
## Installation
```r
remotes::install_github("paithiov909/jprailway")
```## Example
```{r example}
# 東海道新幹線が通過する都府県のJISコード
jis_code <- jisx0402::jpprefs |>
dplyr::filter(
name %in% c("東京都", "神奈川県", "静岡県", "愛知県", "岐阜県", "滋賀県", "京都府", "大阪府")
) |>
dplyr::pull(pref_code)# 通過する都府県のsf (MULTIPOLYGON)
pref <- jisx0402::jptopography("prefecture") |>
dplyr::filter(pref_code %in% jis_code)# 鉄道区間のsf (LINESTRING)
tkd_line <- jprailway::polylines |>
dplyr::filter(name == "東海道新幹線")# 駅のsf (POLYGON). ただし、ここでは代表点の座標を使う
tkd_station <- jprailway::stations |>
dplyr::semi_join(
jprailway::lines |>
dplyr::filter(name == "東海道新幹線") |>
tidyr::unnest(station_list, names_sep = "_"),
by = c("code" = "station_list_code")
)# プロット
require(ggplot2)pref |>
ggplot() +
geom_sf() +
geom_sf(data = tkd_line) +
geom_point(aes(x = lng, y = lat), data = tkd_station) +
ggrepel::geom_label_repel(aes(x = lng, y = lat, label = name), data = tkd_station) +
coord_sf(xlim = c(135, 140), ylim = c(34.5, 35.8)) +
labs(
title = "東海道新幹線の停車駅",
caption = paste(
"出典:国土数値情報(行政区域データ、鉄道データ)(国土交通省)",
"https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N03-v3_0.html",
"https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N02-v2_3.html",
sep = "\n"
)
) +
theme_light()
```