SlideShare a Scribd company logo
1 of 35
pgRouting



       YAMAGUCHI Toshimitsu
Shortest Path Problem
Dijkstra's Algorithm
Edsger Wybe Dijkstra
(1930 5 11 - 2002      8   6
G

S



    6
6

    5           2
                            G

        4
S                           4
                        2

            3
    2

                    6
5

                        6

    5           2
                                G
                    4
        4
S                               4
                            2

            3
    2
        2
                        6
5

                        6

    5           2
                                G
                    4
        4
S                               4
                            2

            3
    2
        2
                        6
5

                         6

    5           2
                                 G
                    45
        4
S                                4
                             2

            3                        8
    2
        2
                         6
5

                         6

    5           2
                                 G
                    45
        4
S                                4
                             2

            3                        8
    2
        2
                         6
56

                          6

    5            2
                                  G
                     45
        4
S                                 4
                              2

             3                        86
    2
        2
                          6
56

                          6

    5            2
                                  G
                     45
        4
S                                 4
                              2

             3                        86
    2
        2
                          6
56

                          6

    5                                 11
                 2
                                  G   10
                     45
        4
S                                 4
                              2

             3                        86
    2
        2
                          6
56

                          6

    5                                 11
                 2
                                  G   10
                     45
        4
S                                 4
                              2

             3                        86
    2
        2
                          6
Route finding with pgRouting
pgRouting (http://pgrouting.postlbs.org/)
pgRouting
1

2

3
1

#!/bin/sh
ogr2ogr -update   -append   ./allRoads/roads.shp   ./aaa/a.shp   -nln   roads
ogr2ogr -update   -append   ./allRoads/roads.shp   ./aaa/b.shp   -nln   roads
ogr2ogr -update   -append   ./allRoads/roads.shp   ./aaa/c.shp   -nln   roads
ogr2ogr -update   -append   ./allRoads/roads.shp   ./bbb/a.shp   -nln   roads
ogr2ogr -update   -append   ./allRoads/roads.shp   ./bbb/b.shp   -nln   roads
....
2
              DB                 — PostGIS



% createdb -U postgres routing

% psql -U postgres -f [path]/lwpostgis.sql routing

% psql -U postgres -f [path]/spatial_ref_sys.sql routing
2
      DB                — pgRouting(                        )



% psql -U postgres -f [path]/routing_core.sql routing

% psql -U postgres -f [path]/routing_core_wrappers.sql routing

% psql -U postgres -f [path]/routing_topology.sql routing
2
      DB                — pgRouting(TSP)



% psql -U postgres -f [path]/routing_tsp.sql routing

% psql -U postgres -f [path]/routing_tsp_wrappers.sql routing
2
       DB                — pgRouting(DD)



% psql -U postgres -f [path]/routing_dd.sql routing

% psql -U postgres -f [path]/routing_dd_wrappers.sql routing
2
                         DB




% shp2pgsql ./roads.shp roads | nkf -w | psql -U postgres -d routing
2
 source        target



ALTER TABLE routing ADD COLUMN source integer;
ALTER TABLE routing ADD COLUMN target integer;
2


SELECT assign_vertex_id('routing', 0.00001, 'the_geom', 'gid');
<0.00001
3

routing=# SELECT gid,source,target FROM roads ORDER BY
Distance(the_geom,GeomFromText('POINT(139.708 35.7076)')) limit 1;

  gid   | source | target
--------+--------+--------
 583718 | 446827 | 446860
(1 row)

routing=#
3

routing=# SELECT AsText(the_geom) FROM dijkstra_sp('roads', 273679, 273974);

                 astext
------------------------------------------------------------------------
MULTILINESTRING((139.862297777778 35.6611955555556,.....
...
MULTILINESTRING((139.865603888889 35.663965,139.865358055556 35.6641527777778))
(13 rows)

routing=#
May
June
September

More Related Content

More from Toshimitsu YAMAGUCHI

先端人間支援科学ミーティング資料
先端人間支援科学ミーティング資料先端人間支援科学ミーティング資料
先端人間支援科学ミーティング資料Toshimitsu YAMAGUCHI
 
視覚障害者のための触地図作成システムの開発—経路情報を利用した触地図簡略化—
視覚障害者のための触地図作成システムの開発—経路情報を利用した触地図簡略化—視覚障害者のための触地図作成システムの開発—経路情報を利用した触地図簡略化—
視覚障害者のための触地図作成システムの開発—経路情報を利用した触地図簡略化—Toshimitsu YAMAGUCHI
 
触地図作成システムの開発
触地図作成システムの開発触地図作成システムの開発
触地図作成システムの開発Toshimitsu YAMAGUCHI
 
第53回WIT研究会におけるリアルタイム映像配信 -技術編-
第53回WIT研究会におけるリアルタイム映像配信 -技術編-第53回WIT研究会におけるリアルタイム映像配信 -技術編-
第53回WIT研究会におけるリアルタイム映像配信 -技術編-Toshimitsu YAMAGUCHI
 
新潟市障がい者ITサポートセンターの活動 - 新潟市におけるITサポートの実践と課題
新潟市障がい者ITサポートセンターの活動 - 新潟市におけるITサポートの実践と課題新潟市障がい者ITサポートセンターの活動 - 新潟市におけるITサポートの実践と課題
新潟市障がい者ITサポートセンターの活動 - 新潟市におけるITサポートの実践と課題Toshimitsu YAMAGUCHI
 
Perlmagickを使った画像処理
Perlmagickを使った画像処理Perlmagickを使った画像処理
Perlmagickを使った画像処理Toshimitsu YAMAGUCHI
 
秋葉区ボランティアセンタ支援技術講座
秋葉区ボランティアセンタ支援技術講座秋葉区ボランティアセンタ支援技術講座
秋葉区ボランティアセンタ支援技術講座Toshimitsu YAMAGUCHI
 
視覚障害者のための触地図作成システムの試作
視覚障害者のための触地図作成システムの試作視覚障害者のための触地図作成システムの試作
視覚障害者のための触地図作成システムの試作Toshimitsu YAMAGUCHI
 
触地図システムの機能紹介
触地図システムの機能紹介触地図システムの機能紹介
触地図システムの機能紹介Toshimitsu YAMAGUCHI
 
Introduction of Web Accessibility at Kawasaki
Introduction of Web Accessibility at KawasakiIntroduction of Web Accessibility at Kawasaki
Introduction of Web Accessibility at KawasakiToshimitsu YAMAGUCHI
 
Assistive Technologies for Web Access
Assistive Technologies for Web AccessAssistive Technologies for Web Access
Assistive Technologies for Web AccessToshimitsu YAMAGUCHI
 

More from Toshimitsu YAMAGUCHI (17)

サイトワールド2010
サイトワールド2010サイトワールド2010
サイトワールド2010
 
先端人間支援科学ミーティング資料
先端人間支援科学ミーティング資料先端人間支援科学ミーティング資料
先端人間支援科学ミーティング資料
 
視覚障害者のための触地図作成システムの開発—経路情報を利用した触地図簡略化—
視覚障害者のための触地図作成システムの開発—経路情報を利用した触地図簡略化—視覚障害者のための触地図作成システムの開発—経路情報を利用した触地図簡略化—
視覚障害者のための触地図作成システムの開発—経路情報を利用した触地図簡略化—
 
G空間EXPO 触地図ポスタ
G空間EXPO 触地図ポスタG空間EXPO 触地図ポスタ
G空間EXPO 触地図ポスタ
 
新潟養護学校勉強会2010
新潟養護学校勉強会2010新潟養護学校勉強会2010
新潟養護学校勉強会2010
 
触地図作成システムの開発
触地図作成システムの開発触地図作成システムの開発
触地図作成システムの開発
 
第53回WIT研究会におけるリアルタイム映像配信 -技術編-
第53回WIT研究会におけるリアルタイム映像配信 -技術編-第53回WIT研究会におけるリアルタイム映像配信 -技術編-
第53回WIT研究会におけるリアルタイム映像配信 -技術編-
 
新潟市障がい者ITサポートセンターの活動 - 新潟市におけるITサポートの実践と課題
新潟市障がい者ITサポートセンターの活動 - 新潟市におけるITサポートの実践と課題新潟市障がい者ITサポートセンターの活動 - 新潟市におけるITサポートの実践と課題
新潟市障がい者ITサポートセンターの活動 - 新潟市におけるITサポートの実践と課題
 
Perlmagickを使った画像処理
Perlmagickを使った画像処理Perlmagickを使った画像処理
Perlmagickを使った画像処理
 
CSUN2010報告
CSUN2010報告CSUN2010報告
CSUN2010報告
 
2010MSW協会プレゼン
2010MSW協会プレゼン2010MSW協会プレゼン
2010MSW協会プレゼン
 
秋葉区ボランティアセンタ支援技術講座
秋葉区ボランティアセンタ支援技術講座秋葉区ボランティアセンタ支援技術講座
秋葉区ボランティアセンタ支援技術講座
 
視覚障害者のための触地図作成システムの試作
視覚障害者のための触地図作成システムの試作視覚障害者のための触地図作成システムの試作
視覚障害者のための触地図作成システムの試作
 
触地図システムの機能紹介
触地図システムの機能紹介触地図システムの機能紹介
触地図システムの機能紹介
 
Introduction of Web Accessibility at Kawasaki
Introduction of Web Accessibility at KawasakiIntroduction of Web Accessibility at Kawasaki
Introduction of Web Accessibility at Kawasaki
 
UAI Seminar 2008 at Nagoya
UAI Seminar 2008 at NagoyaUAI Seminar 2008 at Nagoya
UAI Seminar 2008 at Nagoya
 
Assistive Technologies for Web Access
Assistive Technologies for Web AccessAssistive Technologies for Web Access
Assistive Technologies for Web Access
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

pgRoutingを使った経路検索

  • 1. pgRouting YAMAGUCHI Toshimitsu
  • 3.
  • 5. Edsger Wybe Dijkstra (1930 5 11 - 2002 8 6
  • 6. G S 6
  • 7. 6 5 2 G 4 S 4 2 3 2 6
  • 8. 5 6 5 2 G 4 4 S 4 2 3 2 2 6
  • 9. 5 6 5 2 G 4 4 S 4 2 3 2 2 6
  • 10. 5 6 5 2 G 45 4 S 4 2 3 8 2 2 6
  • 11. 5 6 5 2 G 45 4 S 4 2 3 8 2 2 6
  • 12. 56 6 5 2 G 45 4 S 4 2 3 86 2 2 6
  • 13. 56 6 5 2 G 45 4 S 4 2 3 86 2 2 6
  • 14. 56 6 5 11 2 G 10 45 4 S 4 2 3 86 2 2 6
  • 15. 56 6 5 11 2 G 10 45 4 S 4 2 3 86 2 2 6
  • 16. Route finding with pgRouting
  • 19. 1 2 3
  • 20. 1 #!/bin/sh ogr2ogr -update -append ./allRoads/roads.shp ./aaa/a.shp -nln roads ogr2ogr -update -append ./allRoads/roads.shp ./aaa/b.shp -nln roads ogr2ogr -update -append ./allRoads/roads.shp ./aaa/c.shp -nln roads ogr2ogr -update -append ./allRoads/roads.shp ./bbb/a.shp -nln roads ogr2ogr -update -append ./allRoads/roads.shp ./bbb/b.shp -nln roads ....
  • 21. 2 DB — PostGIS % createdb -U postgres routing % psql -U postgres -f [path]/lwpostgis.sql routing % psql -U postgres -f [path]/spatial_ref_sys.sql routing
  • 22. 2 DB — pgRouting( ) % psql -U postgres -f [path]/routing_core.sql routing % psql -U postgres -f [path]/routing_core_wrappers.sql routing % psql -U postgres -f [path]/routing_topology.sql routing
  • 23. 2 DB — pgRouting(TSP) % psql -U postgres -f [path]/routing_tsp.sql routing % psql -U postgres -f [path]/routing_tsp_wrappers.sql routing
  • 24. 2 DB — pgRouting(DD) % psql -U postgres -f [path]/routing_dd.sql routing % psql -U postgres -f [path]/routing_dd_wrappers.sql routing
  • 25. 2 DB % shp2pgsql ./roads.shp roads | nkf -w | psql -U postgres -d routing
  • 26. 2 source target ALTER TABLE routing ADD COLUMN source integer; ALTER TABLE routing ADD COLUMN target integer;
  • 29. 3 routing=# SELECT gid,source,target FROM roads ORDER BY Distance(the_geom,GeomFromText('POINT(139.708 35.7076)')) limit 1; gid | source | target --------+--------+-------- 583718 | 446827 | 446860 (1 row) routing=#
  • 30. 3 routing=# SELECT AsText(the_geom) FROM dijkstra_sp('roads', 273679, 273974); astext ------------------------------------------------------------------------ MULTILINESTRING((139.862297777778 35.6611955555556,..... ... MULTILINESTRING((139.865603888889 35.663965,139.865358055556 35.6641527777778)) (13 rows) routing=#
  • 31.
  • 32.
  • 33. May
  • 34. June

Editor's Notes