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
Satoshi Gachi Fujimoto
February 12, 2020
Technology
1.2k
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
MCPをつなげて作る組織横断のAIエージェント基盤
tsubakimoto_s
0
360
論語・武士道・産業革命から見る かわるもの、かわらないもの
ichimichi
8
1.6k
セキュリティ研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
31
25k
QAタスクをスキル化したいときに考えること
aomoriringo
0
130
AIツールを導入しても生産性はあがらない? カオナビが直面した 3つの壁と乗り越え方。/ Overcoming 3 Barriers to AI-Driven Productivity at kaonavi
kaonavi
0
460
GMOフィナンシャルゲートが挑む、「止まらない」決済インフラ構築の裏側【SORACOM Discovery 2026】
soracom
PRO
0
110
reFACToring
moznion
1
880
データ活用研修 データマネジメント【MIXI 26新卒技術研修】
mixi_engineers
PRO
4
780
BigQuery を検索ソースとした AI Agent の作り方って 〇〇 通りあんねん
satohjohn
0
140
現場との対話から始める “作る前に問い直す”業務改善
mochico50
2
340
新たなDBアーキテクチャ「LTAP」にDeep Dive!!
inoutk
0
150
ここは地獄!つらい朝会を体験することで、チームとしてのより良い振る舞いに気づくワークショップ / The stand-up meeting from hell in the game industry
scrummasudar
0
440
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
170
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
230
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
470
For a Future-Friendly Web
brad_frost
183
10k
YesSQL, Process and Tooling at Scale
rocio
174
15k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
850
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
280
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
Documentation Writing (for coders)
carmenintech
77
5.4k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Writing Fast Ruby
sferik
630
63k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
350
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/
ご清聴ありがとうございました