Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GTFSのデータを Streamlitで可視化してみた
Search
NearMeの技術発表資料です
PRO
April 19, 2024
Programming
410
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GTFSのデータを Streamlitで可視化してみた
Streamlitを用いてGTFSの可視化を行なった資料になります。今回では、東京都内のバス停を可視化、そしてリアルタイムでのバスの位置情報の可視化を行なっています。
NearMeの技術発表資料です
PRO
April 19, 2024
More Decks by NearMeの技術発表資料です
See All by NearMeの技術発表資料です
Claude Code × git worktree で並列開発 (続き) -差分のサービスだけを併設する-
nearme_tech
PRO
1
43
Claude Code × git worktree で並列開発 — サブモジュール構成のリポジトリで成立させる —
nearme_tech
PRO
0
49
LLM + 強化学習
nearme_tech
PRO
0
31
PosthogのA/Bテスト機能の紹介
nearme_tech
PRO
1
41
AIフレンドリーなプロダクトに向けて
nearme_tech
PRO
2
65
初めてのLean言語
nearme_tech
PRO
0
100
Apache Airflow Workflow orchestration without turning cron into spaghetti
nearme_tech
PRO
2
37
実務で役立つ幾何学 ボロノイ図の基礎から グラフ・ネットワーク応用まで
nearme_tech
PRO
1
73
SQL/ID抽出タスクから考える 実践的なハルシネーション対策
nearme_tech
PRO
1
87
Other Decks in Programming
See All in Programming
My Marp Sample
sinoue0108
0
140
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
660
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
560
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
270
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
業務時間外もAIに働いてもらう話
colorful12
3
9.9k
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
350
新卒PdEのリアル
ryu1013
1
290
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
200
AIの中の人になってみる
htkym
0
150
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
720
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
250
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
3
550
Code Reviewing Like a Champion
maltzj
528
40k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
300
Docker and Python
trallard
47
4.2k
エンジニアに許された特別な時間の終わり
watany
108
250k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
The SEO identity crisis: Don't let AI make you average
varn
0
550
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Transcript
0 GTFSのデータを Streamlitで可視化してみた 2024-04-19 第87回NearMe技術勉強会 Kenji Hosoda
1 GTFSとは • GTFS (General Transit Feed Specification) は、交通システムに関する関連情報を利⽤者に配 信するために使⽤される”オープン標準”
• 路線、時刻表、運賃、地理的な乗り換えを表現する「GTFS Schedule」とトリップの更新、⾞ 両位置、サービスアラートなどのリアルタイム情報を提供する「GTFS Realtime」という⼆つ の主要な仕様がある • それに加えて、様々なニーズに対応するために拡張されたフォーマットが存在
2 GTFS-JPについて • GTFSの国際標準をベースにしつつ、⽇本独特の交通システムや⾔語、運賃体系に対応 するためにカスタマイズされている • 以下のサイトからデータを取得可能 https://tshimada291.sakura.ne.jp/transport/gtfs-list.html
3 今回は都営バスのデータを可視化してみる • GTFS-JP • https://ckan.odpt.org/dataset/b_bus_gtfs_jp-toei • GTFS Realtime •
https://ckan.odpt.org/dataset/b_bus_gtfs_rt-toei
4 セットアップ • こちらのコードをダウンロード • https://gist.github.com/kenji4569/ea42817d05980d2508963e66b297d03b • 以下を実⾏ • pip
install streamlit streamlit-folium folium pydeck pandas requests geopy gtfs-realtime-bindings • streamlit run gtfs-viewer-app.py • (オプション)公共交通オープンデータセンターにて開発者登録してアクセストークンを取得 (2営 業⽇かかる) • https://developer.odpt.org/ • 実⾏時にアクセストークンをセット • ACCESS_TOKEN=<your_access_token> streamlit run gtfs-viewer-app.py
5 実⾏結果 GTFS-JPのダウンロード バス停の表示 リアルタイムバス位置の表示 更新頻度 表示対象の絞り込み マップの種類
6 (表⽰対象の絞り込みとマップの切り替えについて) • データ数が多いのでfoliumだと動きが遅い → pydeckに変更 • (ただし、現状pydeckの⽅がリアルタイムの更新は苦⼿?)
7 コード解説1 GTFS-JPのダウンロード def download_gtfs_jp (): ... url = (
f"https://api.odpt.org/api/v4/files/Toei/data/ToeiBus-GTFS.zip?acl:consumerKey= {ACCESS_TOKEN}" if ACCESS_TOKEN else "https://api-public.odpt.org/api/v4/files/Toei/data/ToeiBus-GTFS.zip" ) with ( requests.get(url) as res, io.BytesIO(res.content) as bytes_io, zipfile.ZipFile(bytes_io) as zip, ): zip.extractall(GTFS_JP_DATA_DIR ) • ToeiBus-GTFS.zipファイルをダウンロード • ファイルを展開して./data以下に保存 ダウンロードしたデータ
8 コード解説2 GTFS Realtime のダウンロード from google.transit import gtfs_realtime_pb2 def
download_gtfs_realtime (time_steps): ... feed = gtfs_realtime_pb2.FeedMessage() records = [] with urllib.request.urlopen(url) as res: feed.ParseFromString( res.read()) for entity in feed.entity: record = [ entity.id, entity.vehicle.trip.trip_id, entity.vehicle.trip.route_id, entity.vehicle.trip.direction_id, entity.vehicle.position.latitude, entity.vehicle.position.longitude, entity.vehicle.current_stop_sequence, entity.vehicle.timestamp, entity.vehicle.stop_id, ] records.append(record) • ToeiBusのリアルタイムフィード (Protocol Buffers形式)をライブラリ を介して取得 参考:https://nttdocomo-developers.jp/entry/20231218_1
9 今後の展望 https://www.linkedin.com/posts/mobilitydata_gtfs-demandrespo nsivetransportation-drt-activity-7175942816848588800-JX9v • 「GTFS-Flex」来るか? • オンデマンド交通などフレキシブルなルートを扱うことが可能になる • NearMeの配⾞もルート検索アプリに表⽰できるようになる?
10 Thank you