160 likes | 354 Views
Geo 580 – Python Short Course. Dr. Jim Graham. ArcGIS Python Short Course. This is a short course in using Python in ArcGIS based on Geo 599: Introduction to GIS Programming Website: Ibis.colostate.edu/jim The focus is on quickly learning to create scripts for “batch” operations in ArcGIS
E N D
Geo 580 – Python Short Course Dr. Jim Graham
ArcGIS Python Short Course • This is a short course in using Python in ArcGIS based on Geo 599: Introduction to GIS Programming • Website: Ibis.colostate.edu/jim • The focus is on quickly learning to create scripts for “batch” operations in ArcGIS • Batch operations repeat the same processing over and over, typically on a large set of files
We are not learning… • Everything about Python • It’s a huge language that is growing all the time! • You only need a fraction of what is out there • The challenge is to find that fraction and get good at it! • Everything about programming ArcGIS • You will learn how to find anything available in programming ArcGIS
Why Program? • Automate tasks • Repeated over and over again • Speed up tasks • Computers can run 24/7 • Allows for “exact” replication of processes • Except that the libraries you call will change! • “Encapsulate” functionality and expertise • You and everyone else can use it
Definitions • Code – Instructions for a computer • Programming/Coding – writing, documenting, and testing code • Program – A file with instructions for a computer to execute to complete a task • Application – A program with a graphic user interface (as opposed to a command line interface) • Library – A file with code for a computer to be used by other programs
Why Python? • ESRI’s primary scripting language (for now) • Very popular in GIS (Arc and OpenSource) • Very flexible (can solve lots of problems) • Well supported (with Wing IDE) • Easy to learn (relative to complied languages) • Portable • But it is not the fastest language • Compiled (C/C++, Java, C#) are faster
GIS Library/Package • A library with code to complete GIS tasks • Spatially referenced data • Tasks specific to GIS • Union, intersect, mosaic, project, and lots more! • Options • ArcGIS – arcpy, etc. • GeoTools – Open source • GDAL, ORG, Proj – Open source • BlueSpray – SchoonerTurtles
Big Picture ArcGIS Desktop Wing IDE Other Programs Model Builder Python Scripts ArcGIS Libraries Other Libraries Data Data includes GIS (spatially referenced) and non-spatially reference
Installing • Install ArcGIS with appropriate license • Install Python from • Install Wingware IDE from Wingware.com • Latest version of “Wing IDE Personal” • Note: • ArcGIS installs their own version of Python! • Set the “Python Executable” to ArcGIS’s
1. Python Short Course • 2.3 Introduction to Programming in Python • 2.5 Arithmetic in Python • 2.6 Generating Random Numbers • 3.1 How Computers Work • 3.2 Boolean Logic and "If" Statements • 3.5 Lists, Ranges, and "For" Loops • 3.6 Strings are Made Up of Characters • 3.7 Writing to Text Files • 3.8 Grid ASCII File Format • 3.9 Creating ASCII Grid Files
New Titanic Wreck Map • http://ngm.nationalgeographic.com/2012/04/titanic/titanic-interactive • http://ngm.nationalgeographic.com/ngm/0412/feature5/images/mp_download.5.pdf
2. Python Short Course • 4.2 Parsing (chopping up) Strings • 4.3 Reading Text Files • 6.1 Handling Exceptions • 6.2 An Overview of ArcGIS Functions • 6.3 Calling ArcGIS From Python • 7.1 More on Calling ArcGIS • 8.5 Batch Processing in Python
Where to Go From Here • GIS @ OSU Links to Free ArcGIS Tutorials • An Informal Introduction to Python • Beginners Guide • Python for Non-Programmers
Get code snippet from results • ArcGIS desktop help (website) • ArcGIS built-in help (not always correct) • Function definitiones in wing