Lecture 12 Programming for automation of common data management tasks Daniel P. Ames Hydroinformatics Fall 2012 This work was funded by National Science Foundation Grant EPS 1135482 Goals this Week… • To learn the basics of Python Scripting for automation of basic geoprocessing and database management tasks. • Tuesday focus on intro to Python and ArcPy for mapping and geoprocessing tasks • Thursday focus on PyODBC and using Python to automate database tasks Useful Software to have on your laptop computer in class… • ArcGIS. http://www.esri.com/software/arcgis/arcgis- for-desktop/free-trial • Python. www.Python.org. • PyODBC. http://code.google.com/p/pyodbc/. • ArcMap 10.x comes with Python 2.6. It installs it in your C: folder under C:\Python\ArcGIS10\. • PyODBC. http://code.google.com/p/pyodbc/downlo ads/detail?name=pyodbc-3.0.6.win32- py2.6.exe&can=2&q= Slide Credits • 2010 Mitch Marcus and Varun Aggarwala, University of Pennsylvania • 2010 ESRI Conference Workshop: Python Essentials in ArcGIS-I • 2002 LinuxWorld Tutorial: Introduction to Python by Guido van Rossum Python Python is an open source scripting language. Developed by Guido van Rossum in the early 1990s Named after Monty Python Available on eniac Available for download from http://www.python.org CIS 530 - Intro to NLP 5 Why Python? Powerful but unobtrusive object system Every value is an object Classes guide but do not dominate object construction Powerful collection and iteration abstractions Dynamic typing makes generics easy Python Interpreted language: works with an evaluator for language expressions Dynamically typed: variables do not have a predefined type Rich, built-in collection types: Lists Tuples Dictionaries (maps) Sets Concise Language features Indentation instead of braces Newline separates statements Several sequence types Strings ’…’: made of characters, immutable Lists […]: made of anything, mutable Tuples (…) : made of anything, immutable Powerful subscripting (slicing) Functions are independent entities (not all functions are methods) Exceptions Basics
Description: