R Code for Regional Analysis: Interactive Mapping of Public Transport Infrastructure using Leaflet 地域分析のためのRコード:Leafletによる公共交通(バス)配置のインタラクティブ・マップ化
Abstract
地域分析のためのRコード:Leafletによる公共交通(バス)配置のインタラクティブ・マップ化 概要 (Description) 行政区域データとバス停留所データを活用し、Webブラウザ上で探索可能なインタラクティブ・マップを作成するRスクリプトである。静的な地図では困難な、バス停の具体的位置等の詳細情報の確認や、ズーム操作による周辺環境(道路、施設等)との位置関係の把握を迅速に行うことを主目的とする。 本スクリプトの最大の特徴は、Rの leaflet パッケージを用いることで、特別なサーバー設定やGIS専用ソフトを介さずに、背景地図(OpenStreetMap等)を伴う高度な可視化を数行のコードで実現している点にある。シリーズ第2弾「公共交通空白地帯の可視化」の結果を補完するものであり、理論的な分析(空白地帯の特定)から「現場感覚」を伴う探索(具体的なバス停位置の確認)へと分析フェーズを移行させる役割を担う。分析者自身が使い慣れたR環境で完結するため、自治体の交通計画やEBPM(証拠に基づく政策立案)における合意形成の基礎資料作成において高い柔軟性を発揮する。 開発にあたっては、Google Geminiのコード作成支援を利用した。本コードは、南山大学のゼミ(プロジェクト研究)において地域分析のための手法としてLMSに共有していたものである。このコードの出力を用い、2026年3月に卒業した行政学ゼミ1期生が、卒業研究において対象地域の詳細な状況を現地の文脈に即して確認するのに用いた。 分析用のデータ入手先 (Data Sources) 本分析には、国土数値情報ダウンロードサイトから取得した以下のデータを使用する。 行政区域データ (N03) URL: https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N03-v3_1.html バス停留所データ (P11) URL: https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-P11-2022.html 実行手順と注意点 (Execution Procedures & Notes) 上記URLより愛知県のデータをそれぞれ選択してダウンロードする。 ダウンロードしたZIPファイルを解凍し、構成ファイル(N03-20_23_200101.shp や P11-22_23.shp など)をRの作業フォルダに配置する。 スクリプト内のファイル名が、実際のダウンロードファイル名と一致しているか確認して実行すること。 実行結果の地図は、RStudio内の「Viewer」タブ(またはデフォルトのWebブラウザ)に出力される。 本ページでの出力例は愛知県一宮市である。また、背景地図としてOpen Street Mapを用いている。 [English] This R script generates an interactive web map for exploring administrative boundaries and bus stop locations. Its primary purpose is to facilitate the rapid identification of detailed information, such as the specific locations of bus stops, and to understand their spatial relationships with the surrounding environment (roads, facilities, etc.) through zooming operations—tasks that are challenging with static maps. The key feature of this script is its ability to achieve sophisticated visualization with background tiles (such as OpenStreetMap) using only a few lines of code via the R leaflet package, without requiring special server configurations or dedicated GIS software. It complements Part 2 of the series ("Visualizing Public Transport Service Gaps") by shifting the analytical phase from theoretical analysis (identifying service gaps) to exploratory discovery with a "sense of the field" (confirming specific bus stop locations). Since it operates entirely within the familiar R environment, it offers high flexibility for creating foundational materials for consensus building in municipal transport planning and Evidence-Based Policy Making (EBPM). The development was supported by Google Gemini. This script was originally shared via the Learning Management System (LMS) for a Public Administration seminar at Nanzan University. This code was utilized by the first cohort of the Public Administration seminar (graduating class of March 2026) to verify the detailed status of target areas within the local context and to generate analytical figures (outputs) for their graduation research. Additionally, it utilizes OpenStreetMap for the background tiles. Data Sources This analysis utilizes the following datasets obtained from the National Land Numerical Information Download Service: Administrative Boundary Data (N03) URL: https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N03-v3_1.html Bus Stop Location Data (P11) URL: https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-P11-2022.html Execution Procedures & Notes Select and download the datasets for Aichi Prefecture from the URLs provided above. Extract the downloaded ZIP files and place the constituent files (e.g., N03-20_23_200101.shp, P11-22_23.shp, etc.) into your R working directory. Ensure that the file names in the script match the actual names of the downloaded files before execution. The resulting map will be displayed in the "Viewer" tab within RStudio (or your default web browser). Note: The example output featured on this page is Ichinomiya City, Aichi Prefecture.
Publication details
- Journal / source
- Zenodo (CERN European Organization for Nuclear Research)
- Publication date
- 27 April 2026