最終更新:2026-01-02
# 必要なパッケージの読み込み
library(sf)
# シェープファイルの読み込み
kuiki03 <- sf::st_read("N03-20240101_03_GML/N03-20240101_03.shp")## Reading layer `N03-20240101_03' from data source
## `/Users/ayumu/Documents/GitHub/research/4_GIS/railway/N03-20240101_03_GML/N03-20240101_03.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 8224 features and 6 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 140.6531 ymin: 38.74765 xmax: 142.0725 ymax: 40.45026
## Geodetic CRS: JGD2011
## Coordinate Reference System:
## User input: JGD2011
## wkt:
## GEOGCRS["JGD2011",
## DATUM["Japanese Geodetic Datum 2011",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["degree",0.0174532925199433]],
## CS[ellipsoidal,2],
## AXIS["geodetic latitude (Lat)",north,
## ORDER[1],
## ANGLEUNIT["degree",0.0174532925199433]],
## AXIS["geodetic longitude (Lon)",east,
## ORDER[2],
## ANGLEUNIT["degree",0.0174532925199433]],
## USAGE[
## SCOPE["Horizontal component of 3D system."],
## AREA["Japan - onshore and offshore."],
## BBOX[17.09,122.38,46.05,157.65]],
## ID["EPSG",6668]]
駅については:
路線については:
# 必要なパッケージの読み込み
library(sf)
# シェープファイルの読み込み
#eki <- sf::st_read("N05-24_GML/UTF-8/N05-24_Station2.shp")
eki <- sf::st_read("Data_raw/Merged.shp")## Reading layer `Merged' from data source
## `/Users/ayumu/Documents/GitHub/research/4_GIS/railway/Data_raw/Merged.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 23812 features and 17 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: 127.6523 ymin: 26.19326 xmax: 145.7539 ymax: 45.41634
## Geodetic CRS: JGD2011
## Reading layer `N05-24_RailroadSection2' from data source
## `/Users/ayumu/Documents/GitHub/research/4_GIS/railway/N05-24_GML/UTF-8/N05-24_RailroadSection2.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 2645 features and 11 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: 127.6523 ymin: 26.19315 xmax: 145.7539 ymax: 45.41634
## Geodetic CRS: JGD2011
crop()関数を使って、岩手県の範囲(kuiki03.shp)にデータを限定する。# 重要な駅の駅名を変数として追加
eki_iwate$Major_Station[eki_iwate$N05_011=="盛岡"] <- "盛岡"
eki_iwate$Major_Station[eki_iwate$N05_011=="一ノ関"] <- "一ノ関"
eki_iwate$Major_Station[eki_iwate$N05_011=="北上"] <- "北上"
eki_iwate$Major_Station[eki_iwate$N05_011=="花巻"] <- "花巻"
#eki_iwate$Major_Station[eki_iwate$N05_011=="新花巻"] <- "新花巻"
eki_iwate$Major_Station[eki_iwate$N05_011=="水沢"] <- "水沢"
#eki_iwate$Major_Station[eki_iwate$N05_011=="水沢江刺"] <- "水沢江刺"
eki_iwate$Major_Station[eki_iwate$N05_011=="釜石"] <- "釜石"
eki_iwate$Major_Station[eki_iwate$N05_011=="宮古"] <- "宮古"
eki_iwate$Major_Station[eki_iwate$N05_011=="久慈"] <- "久慈"
eki_iwate$Major_Station[eki_iwate$N05_011=="盛"] <- "盛"
eki_iwate$Major_Station[eki_iwate$N05_011=="北雫石"] <- "北雫石"
eki_iwate$Major_Station[eki_iwate$N05_011=="いわて沼宮内"] <- "いわて沼宮内"
eki_iwate$Major_Station[eki_iwate$N05_011=="茂市"] <- "茂市"
eki_iwate$Major_Station[eki_iwate$N05_011=="遠野"] <- "遠野"
eki_iwate$Major_Station[eki_iwate$N05_011=="陸前高田"] <- "陸前高田"
eki_iwate$Major_Station[eki_iwate$N05_011=="二戸"] <- "二戸"
eki_iwate$Major_Station[eki_iwate$N05_011=="雫石"] <- "雫石"# 必要なパッケージの読み込み
library(ggplot2)
# 岩手県地図の作成
ggplot() +
geom_sf(data = kuiki03, fill = "white", color = "black", size = 0.2) +
geom_sf(data = senro_iwate, color = "blue",
size = 0.5, alpha = 0.1) +
geom_sf(data = eki_iwate, color = "red",
size = 0.5, alpha = 0.1) +
# Major_Stationをラベルとして表示
geom_sf_text(data = eki_iwate, aes(label = Major_Station),
size = 2, family = "Osaka", color = "black",
nudge_y = 0.01) +
labs(title = "Railway Stations and Lines",
subtitle = "Iwate Prefecture",
caption = "Source: Ministry of Land, Infrastructure, Transport and Tourism") +
theme_minimal() +
theme(axis.text = element_blank(), # 目盛りを非表示
axis.title = element_blank()) # 軸タイトルを非表示TRUE
N05_005eが9999の値の場合は、2024年現在営業中。N05_005bが2010年以前の値の場合は、2010年以前に営業開始。N05_005eが2010年以降の値の場合は、2010年現在営業中。N05_005bが2011年以前の値の場合は、2011年以前に営業開始。N05_005eが2011年から2024年までの値の場合は、2011年〜2024年に営業# 必要なパッケージの読み込み
library(ggplot2)
# 岩手県地図の作成
ggplot() +
geom_sf(data = kuiki03, fill = "white", color = "black", size = 0.2) +
geom_sf(data = senro_iwate_2010, color = "blue",
size = 0.5, alpha = 0.7) +
geom_sf(data = eki_iwate_2010, color = "red",
size = 2, alpha = 0.7) +
# Major_Stationをラベルとして表示
geom_sf_text(data = eki_iwate, aes(label = Major_Station),
size = 2, family = "Osaka", color = "black",
nudge_y = 0.01) +
labs(title = "Railway Stations and Lines",
subtitle = "Iwate Prefecture (2010)",
caption = "Source: Ministry of Land, Infrastructure, Transport and Tourism") +
theme_minimal() +
theme(axis.text = element_blank(), # 目盛りを非表示
axis.title = element_blank()) # 軸タイトルを非表示 TRUE
# 必要なパッケージの読み込み
library(ggplot2)
# 岩手県地図の作成
ggplot() +
geom_sf(data = kuiki03, fill = "white", color = "black", size = 0.2) +
geom_sf(data = senro_iwate_2024, color = "blue",
size = 0.5, alpha = 0.7) +
geom_sf(data = eki_iwate_2024, color = "red",
size = 2, alpha = 0.7) +
# Major_Stationをラベルとして表示
geom_sf_text(data = eki_iwate, aes(label = Major_Station),
size = 2, family = "Osaka", color = "black",
nudge_y = 0.01) +
labs(title = "Railway Stations and Lines",
subtitle = "Iwate Prefecture (2024)",
caption = "Source: Ministry of Land, Infrastructure, Transport and Tourism") +
theme_minimal() +
theme(axis.text = element_blank(), # 目盛りを非表示
axis.title = element_blank()) # 軸タイトルを非表示 TRUE
# 必要なパッケージの読み込み
library(ggplot2)
# 岩手県地図の作成
ggplot() +
geom_sf(data = kuiki03, fill = "white", color = "black", size = 0.2) +
geom_sf(data = senro_iwate_closed, color = "blue",
size = 0.5, alpha = 0.7) +
geom_sf(data = eki_iwate_closed, color = "red",
size = 2, alpha = 0.7) +
# Major_Stationをラベルとして表示
geom_sf_text(data = eki_iwate, aes(label = Major_Station),
size = 2, family = "Osaka", color = "black",
nudge_y = 0.01) +
labs(title = "Closed Railway Stations and Lines",
subtitle = "Iwate Prefecture (Closed: 2011-2024)",
caption = "Source: Ministry of Land, Infrastructure, Transport and Tourism") +
theme_minimal() +
theme(axis.text = element_blank(), # 目盛りを非表示
axis.title = element_blank()) # 軸タイトルを非表示TRUE