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
PythonではじめるGTFS
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Satoshi Gachi Fujimoto
February 12, 2020
Technology
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PythonではじめるGTFS
熊本GTFS-JP活用勉強会 vol.1の資料です。
https://kumamcn.connpass.com/event/164026/
Satoshi Gachi Fujimoto
February 12, 2020
More Decks by Satoshi Gachi Fujimoto
See All by Satoshi Gachi Fujimoto
忘年会LT(2025)
satoshirobatofujimoto
0
65
バスあと何分ミニサイネージ
satoshirobatofujimoto
0
150
高専で制御を、大学でセンシングを学び、次は脳みそ
satoshirobatofujimoto
0
340
画像生成AIを使って勝負しよう
satoshirobatofujimoto
1
180
ガチマナ会 vol.1
satoshirobatofujimoto
0
280
画像生成AIを使って勝負しよう
satoshirobatofujimoto
0
340
画像からプロンプトを考えて最も似ている画像を生成した人が勝ちのゲーム@AIミーティング
satoshirobatofujimoto
0
230
VPS研究者が語る”VPS概論”
satoshirobatofujimoto
0
490
画像からプロンプトを考えて最も似ている画像を生成した人が勝ちのゲーム
satoshirobatofujimoto
0
260
Other Decks in Technology
See All in Technology
背中から、背中へ /paying forward to community
naitosatoshi
0
210
#エンジニアBooks 30分でわかる 「技術記事を書く技術」 / engineer-books 2026-06-30
jnchito
1
170
CVE-2026-20833_脆弱性対応とAES 化について
jukishiya
0
350
組織における AI-DLC 実践
askul
0
300
AWS Blocks を触ってみた/first-tach-aws-blocks
fossamagna
2
140
NDIAS CTF 2026 問題解説会資料
bata_24
0
170
AWS Summit 2026で見えたSIerにとっての Amazon Quickの位置づけ
maf_0521
0
160
Terraform 101 (初心者向け) 資料
shuadachi
0
160
ご挨拶「10周年を迎える共創ラボのこれまでとこれから」
iotcomjpadmin
0
180
はてなのサービス基盤を支える Kubernetes《足腰》
masayoshimaezawa
0
430
クラウドファンディング版StackChan 3体(4体)をインタラクティブな体験型作品にして展示もした話 / スタックチャンお誕生日会2026
you
PRO
0
270
5分でわかるDuckDB Quack
chanyou0311
4
300
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
30 Presentation Tips
portentint
PRO
1
340
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
350
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
BBQ
matthewcrist
89
10k
Un-Boring Meetings
codingconduct
0
330
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Statistics for Hackers
jakevdp
799
230k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Transcript
2020/02/12 熊本GTFS-JP活用勉強会 vol.1 PythonではじめるGTFS
自己紹介 ガチ本 です co-founder KumaMCN ナレッジコミュニケーション R&D戦略チーム AWS ML コンピテンシーパートナー
Microsoft Mixed Reality Partner CV / SLAM / WHILL / Python satoshi.gachi.fujimoto @sotongshi
Pythonでサーマルプリンタの印刷をするほどガチ
• 標準的なバス情報フォーマットとは • 熊本のオープンデータ • GTFS-JP相関図 • CSV形式とJSON形式 • データの読み取り
• 全部あげときます アジェンダ
標準的なバス情報フォーマットとは[1] • バス事業者と経路検索等の情報利用者との情報受け渡しのための共通フォーマット • 静的データ「GTFS-JP」と動的データ「GTFSリアルタイム」の2種類 [1] はじめよう︕「標準的なバス情報フォーマット」 http://www.mlit.go.jp/common/001283238.pdf 区分 フォーマット名
対象とする情報 ファイル形式 静的データ GTFS-JP 停留所、路線、便、時刻表、運賃 など csvをzipで圧縮 動的データ GTFSリアルタイム 遅延、到着予測、車両位置、運行情報 など Protocol Buffers
熊本のオープンデータ • バスきたくまさんの静的データ[2] • 産交バス、熊本電鉄バス、熊本バス、熊本 都市バスの4種類 • ファイル数は12個 • csv形式で書かれている
ファイル名 主な情報 必須 agency.txt 事業者情報 ✔ agency_jp.txt 事業者追加情報 calendar.txt 運行区分情報 ✔ calendar_dates.txt 運行日情報 feed_info.txt 提供情報 ✔ office_jp.txt 営業所情報 routes.txt 経路情報 ✔ routes_jp.txt 経路追加情報 stop_times.txt 通過時刻情報 ✔ stops.txt 停留所・標柱情報 ✔ translations.txt 翻訳情報 ✔ trips.txt 便情報 ✔ [2] バスきたくまさん(Bus-Vision) https://km.bus-vision.jp/kumamoto/view/opendataKuma.html
GTFS-JP相関図[3] [3] 静的バス情報フォーマット(GTFS-JP)仕様書 (第 2 版) https://www.mlit.go.jp/common/001283244.pdf
GTFS-JP相関図[3] [3] 静的バス情報フォーマット(GTFS-JP)仕様書 (第 2 版) https://www.mlit.go.jp/common/001283244.pdf
CSV形式とJSON形式 • CSV形式 • カンマ区切りのテキストファイル形式 • JSON形式 • 人間にとっても機械にとっても読み書きが容易な形式 •
Pythonでいうリストや辞書型 • APIのデータのやり取りに用いられる形式 "agency_id","agency_name","agency_url","agency_timezone","agency_lang","agency_phone","agency_fare_url“ "9330001006723","産交バス","https://www.kyusanko.co.jp/","Asia/Tokyo","ja","0963258243", [ { 'agency_id': '9330001006723’, 'agency_name': '産交バス’, 'agency_url': 'https://www.kyusanko.co.jp/’, 'agency_timezone': 'Asia/Tokyo’, 'agency_lang': 'ja’, 'agency_phone': '0963258243’, 'agency_fare_url': ‘’ } ]
データの読み取り import csv def read_gtfs(filename): with open(filename, 'r', encoding="utf-8") as
f: reader = csv.reader(f) data = [] for row in reader: data.append(row) result = [] for d in data[1:]: json_data = dict(zip(data[0], d)) result.append(json_data) return result
データの読み取り dirname = "sankobus/" filename = "agency.txt" data = read_gtfs(dirname
+ filename) print(data) for agency in data: print(agency["agency_id"]) print(agency["agency_name"]) print(agency["agency_url"]) print(agency["agency_timezone"]) print(agency["agency_lang"]) print(agency["agency_phone"]) print(agency["agency_fare_url"])
実行結果 print(data) [{'agency_id': '9330001006723', 'agency_name': '産交バス', 'agency_url': 'https://www.kyusanko.co.jp/', 'agency_timezone': 'Asia/Tokyo',
'agency_lang': 'ja', 'agency_phone': '0963258243', 'agency_fare_url': ‘’}] print(agency["agency_id"]) 9330001006723 print(agency["agency_name"]) 産交バス print(agency["agency_url"]) https://www.kyusanko.co.jp/ print(agency["agency_timezone"]) Asia/Tokyo print(agency["agency_lang"]) ja print(agency["agency_phone"]) 0963258243 print(agency["agency_fare_url"])
全部あげときます print(agency["agency_id"]) print(agency["agency_name"]) print(agency["agency_url"]) print(agency["agency_timezone"]) print(agency["agency_lang"]) print(agency["agency_phone"]) print(agency["agency_fare_url"]) print(agency_jp["agency_id"]) print(agency_jp["agency_official_name"])
print(agency_jp["agency_zip_number"]) print(agency_jp["agency_address"]) print(agency_jp["agency_president_pos"]) print(agency_jp["agency_president_name"])
全部あげときます print(calendar["service_id"]) print(calendar["monday"]) print(calendar["tuesday"]) print(calendar["wednesday"]) print(calendar["thursday"]) print(calendar["friday"]) print(calendar["saturday"]) print(calendar["sunday"]) print(calendar["start_date"])
print(calendar["end_date"]) print(calendar_dates["service_id"]) print(calendar_dates["date"]) print(calendar_dates["exception_type"])
全部あげときます print(feed_info["feed_publisher_name"]) print(feed_info["feed_publisher_url"]) print(feed_info["feed_lang"]) print(feed_info["feed_start_date"]) print(feed_info["feed_end_date"]) print(feed_info["feed_version"]) print(office_jp["office_id"]) print(office_jp["office_name"]) print(office_jp["office_url"])
print(office_jp["office_phone"])
全部あげときます print(routes_jp["route_id"]) print(routes_jp["route_update_date"]) print(routes_jp["origin_stop"]) print(routes_jp["via_stop"]) print(routes_jp["destination_stop"]) print(routes["route_id"]) print(routes["agency_id"]) print(routes["route_short_name"]) print(routes["route_long_name"])
print(routes["route_desc"]) print(routes["route_type"]) print(routes["route_url"]) print(routes["route_color"]) print(routes["route_text_color"]) print(routes["jp_parent_route_id"])
全部あげときます print(stop_times["trip_id"]) print(stop_times["arrival_time"]) print(stop_times["departure_time"]) print(stop_times["stop_id"]) print(stop_times["stop_sequence"]) print(stop_times["stop_headsign"]) print(stop_times["pickup_type"]) print(stop_times["drop_off_type"]) print(stop_times["shape_dist_traveled"])
全部あげときます print(stops["stop_id"]) print(stops["stop_code"]) print(stops["stop_name"]) print(stops["stop_desc"]) print(stops["stop_lat"]) print(stops["stop_lon"]) print(stops["zone_id"]) print(stops["stop_url"]) print(stops["location_type"])
print(stops["parent_station"]) print(stops["stop_timezone"]) print(stops["wheelchair_boarding"]) print(stops["platform_code"])
全部あげときます print(translations["trans_id"]) print(translations["lang"]) print(translations["translation"]) print(trips["route_id"]) print(trips["service_id"]) print(trips["trip_id"]) print(trips["trip_headsign"]) print(trips["trip_short_name"]) print(trips["direction_id"])
print(trips["block_id"]) print(trips["shape_id"]) print(trips["jp_trip_desc"]) print(trips["jp_trip_desc_symbol"]) print(trips["jp_office_id"])
Python はじめよう!
イベント 日時 2020/3/4(水) 19:00-21:00 場所 えきまえスペース(熊本駅白川口前) 参加費 500円(会場代) URL https://kumamcn.connpass.com/event/166426/
日時 2020/4/6(月) 午後 場所 未定 参加費 未定 URL https://hololens.connpass.com/
ご清聴ありがとうございました