Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by...
Transcript of Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by...
![Page 1: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/1.jpg)
![Page 2: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/2.jpg)
Getting Started with PythonMichael Rhoades
![Page 3: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/3.jpg)
Agenda
• What is Python and why use it?• Python basics• The ArcPy module – Python’s window to ArcGIS• Geoprocessing script tools• Resources
![Page 4: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/4.jpg)
What is Python?
“Python is an easy to learn, powerful language… (with) high level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing…make it an ideal language for scripting…in many areas and on most platforms.”
– python.orgScripting language of ArcGIS
Free, cross-platform, easy to learn, widely useful, great community
![Page 5: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/5.jpg)
Why use Python and ArcGIS?
Automate repetitive tasksMake your own spatial analysis toolsAdd geoprocessing to web applicationsExtend the capabilities of ArcGIS
![Page 6: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/6.jpg)
Python Basics
Where do I write Python code?Python file is text with .py extensionIDE like PyScripter, Wing IDE ($), PythonWin, IDLEPython window in ArcGIS
![Page 7: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/7.jpg)
Python building blocks
Function: a defined piece of functionality that performs a specific task; requires argumentsModule: a Python file where functions live; importPackage: a collection of related modules
import mathmath.sqrt(100) … 10
Python Standard Library / Built-insos, sys, math, datetime, urllib2
![Page 8: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/8.jpg)
Writing Python codePython basicsPython IDEArcGIS Python window
Demo
![Page 9: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/9.jpg)
The ArcPy Module
Site package that adds ArcGIS functionality to PythonAccess to rich suite of geoprocessing toolsFunctions, classes and modules
Helper functions like ListFeatureClasses, DescribeClasses that can be used to create complex objects likeSpatialReference, FieldMapModules that provide specialized functionality like Mapping,SpatialAnalyst, NetworkAnalyst, DataAccess
![Page 10: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/10.jpg)
What can you do with Arcpy?
• Arcpy Functions (Geoprocessing) --- There are limits…- ArcGIS Toolbox tools (functions)
- Mapping Module – Manipulate map documents, data frames and layers
- Data Access Module – Cursors, Editor, Calculate
- Spatial Analyst Module – Spatial Analyst functions
- Network Analyst Module – Network Analyst functions
![Page 11: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/11.jpg)
Run geoprocessing tools
import arcpy
Tool syntaxarcpy.Buffer_analysis()Enter input and output parameters
How do I use a specific tool?Tool help pageCopy as Python Snippethelp(arcpy.Buffer_analysis)Export from Model Builder
![Page 12: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/12.jpg)
Python script tools
Make your Python script into a geoprocessing tool
Great way to create and share workflows, extend ArcGIS
More accessible than stand-alone script
Share as a geoprocessing package or service
Integrated with geoprocessing frameworkUse it just like any other tool
Works with map layers, selections
![Page 13: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/13.jpg)
Geoprocessing script tool
Demo
![Page 14: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/14.jpg)
Resourcesresources.ArcGIS.com
arcpy.wordpress.com
GIS Stack Exchange, Stack Overflow
Python ReferencesPython Scripting for ArcGIS
by Zandbergen (Esri Press)
GIS Tutorial for Python Scripting
by Allen (Esri Press)
Learning Python
by Lutz
The Python Standard Library by Example
by Hellmann
python.org
![Page 15: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/15.jpg)
![Page 16: Python: Getting Started - Esri...Learning Python by Lutz The Python Standard Library by Example by Hellmann python.org Title Python: Getting Started Author Esri Subject 2015 Esri Southeast](https://reader031.fdocuments.us/reader031/viewer/2022013002/5eb47122e13b1857a73cfb24/html5/thumbnails/16.jpg)