![Page 1: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/1.jpg)
GISを自動化するーArcPyの紹介ーAutomating GIS: Introduction of ‘ArcPy’
GIS Seminar
Yuki IWAI(SIS M1)
1
![Page 2: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/2.jpg)
Ⅰ Introduction of ArcPy
Ⅱ Introduction of Python
Ⅲ Case study: “Dissolve” and “Merge”
Ⅳ Application example: “Switching display / non-display of layers at once”
Ⅴ Conclusion
Structure
2
![Page 3: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/3.jpg)
ArcPy とは、 ArcGISの様々な機能をPythonというプログラム言語で操作することを可能とした、arcgisscriptingモジュールの後継となるサイト パッケージである。
ArcPyの目的は、地理データ解析、データ変換、データ管理、およびマップの自動化を Python で実行するための便利で生産性の高い土台を築くことである。
ArcPyは ArcGIS10にて導入された。
What is ‘ArcPy’?
3
![Page 4: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/4.jpg)
Words:
汎用プログラミング言語:特定の用途に特化しないコンピュータプログラミング言語の総称。⇔ドメイン固有言語
インタプリタ言語:プログラミング言語で書かれたソースコードないし中間表現を逐次解釈しながら実行するプログラム言語
What is ‘ArcPy’?
Python 内で ArcPy を使用する利点は、Python が汎用プログラミング言語であるという点である。Python はインタープリタ言語でありタイプ指定は動的に行われるので、インタラクティブな作業と、スクリプトと呼ばれる小さな単発プログラムの素早い試作に適していると同時に、大規模なアプリケーションを作成するために十分な強力さも兼ね備えている。
4
![Page 5: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/5.jpg)
ArcPy を使用して作成された ArcGIS アプリケーションは、GIS プロフェッショナルや多種多様な専門分野のプログラマが開発した追加モジュールを活用することができる。
これはつまり、ArcPyを使えば誰でもGISスペシャリストであるかのような操作を可能とする!
Utility of ArcPy
5
![Page 6: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/6.jpg)
INTRODUCTION OF PYHON
6
![Page 7: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/7.jpg)
Python(パイソン)は、汎用のプログラミング言語である。コードがシンプルで扱いやすく設計されており、C言語などに比べて、さまざまなプログラムを分かりやすく、少ないコード行数で書けるといった特徴がある。
また、1991年に登場したPythonは、2017年現在、最も人気のプログラミングとしても知られている。
What is ‘Python’?
7
![Page 8: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/8.jpg)
プログラミング言語Pythonは、産業界・学術界などにおいて、多くの人によって幅広い目的で使われている。
Pythonで書かれたソフトウェア、Pythonを内部に組み込んでいるソフトウェア、Pythonに対応した統合開発環境、などのうち比較的有名なものを示す。
ArcGIS - GISプラットフォーム
QGIS - スクリプティングとプラグイン開発にPythonを使用している
SPSS - SPSSのコマンド構文でPythonを使用できるようにするSPSS Programmability Extensionが存在する
Google - Google Groups, Gmail, Google Mapsのバックエンドで各種のタスクを遂行するために使用している
YouTube -「メンテナンスが容易な機能を最小の開発者で迅速に作る」ためにPythonを使っている
Various software using Python
8
![Page 9: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/9.jpg)
もしPythonについてより深く学びたい場合は、ArcGIS ProのWebサイトからチュートリアルのページへ移動することができる。
To you who wish to study Python
9
![Page 10: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/10.jpg)
HOW TO USE
10
![Page 11: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/11.jpg)
11
![Page 12: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/12.jpg)
12
![Page 13: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/13.jpg)
13
![Page 14: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/14.jpg)
EXAMPLE: DISSOLVE
14
![Page 15: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/15.jpg)
15
![Page 16: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/16.jpg)
16
![Page 17: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/17.jpg)
17
![Page 18: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/18.jpg)
18
![Page 19: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/19.jpg)
19
![Page 20: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/20.jpg)
20
![Page 21: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/21.jpg)
21
![Page 22: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/22.jpg)
22
![Page 23: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/23.jpg)
EXAMPLE:MERGE
23
![Page 24: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/24.jpg)
24
![Page 25: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/25.jpg)
25
![Page 26: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/26.jpg)
26
レイヤーの数が多くて切り替えに苦労した経験、ありませんか?
![Page 27: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/27.jpg)
APPLICATION EXAMPLE:
SWITCHING DISPLAY / NON-DISPLAY OF LAYERS AT ONCE
27
![Page 28: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/28.jpg)
Example
28
Basic knowledge of Python
全ての行が“オブジェクトである”特に、4行目のまとまりを“クラス”という
![Page 29: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/29.jpg)
「for」文とは、オブジェクトから要素を順に変数に代入し、要素の数だけ繰り返しを行う構文である。
例えば、リスト型のオブジェクトを指定した場合はリストの要素を先頭から順に変数に代入しながら繰り返しを行う。
最終的には、オブジェクトに含まれる要素の数だけ繰り返しが行われることになる。
リスト型とは、複数の要素から構成され、かつ要素が順に並んでいるオブジェクトである。
リストは要素としてあらゆるオブジェクトを持つことができるため、他の複数のオブジェクトをまとめて管理することが出来るオブジェクトであると言える。
29
About “For loop”
![Page 30: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/30.jpg)
30
![Page 31: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/31.jpg)
一度コードを作ってしまえば、それを繰り返し用いることで作業スピードの効率化が図られる→Dissole、Merge
同じ処理を繰り返し行うときArcPyは特に有効である
大量のデータを一括して処理することが可能となる→レイヤーの表示/非表示
また、ArcGISを起動しなくても処理することができるため、PCにかかる負荷を抑えることができる
31
Conclusion:Utility of ArcPy
![Page 32: Automating GIS Introduction of ArcPygiswin.geo.tsukuba.ac.jp/sis/gis_seminar/20171109Iwai.pdfPython(パイソン)は、汎用のプログラミング言語である。コードがシンプルで](https://reader030.vdocuments.net/reader030/viewer/2022040319/5e3daaea5284f831fd1a9706/html5/thumbnails/32.jpg)
THANK YOU VERY MUCHFOR YOUR ATTENTION!
32