Programming ArcGIS 10.1 with Python Cookbook
Table of Contents
Programming ArcGIS 10.1 with Python Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Fundamentals of the Python Language for ArcGIS
Using IDLE for Python script development
The Python shell window
The Python script window
Editing existing Python scripts
Executing scripts from IDLE
Python language fundamentals
Commenting code
Importing modules
Variables
Built-in datatypes
Strings
String manipulation
Numbers
Lists
Tuples
Dictionaries
Classes and objects
Statements
Decision support statements
Looping statements
Try statements
with statements
File I/O
Summary
2. Writing Basic Geoprocessing Scripts with ArcPy
Introduction
Using the ArcGIS Python window
Getting ready
How to do itā¦
Accessing ArcPy with Python
Getting ready
How to do itā¦
How it worksā¦
Executing tools from a script
How to do itā¦
How it worksā¦
There's moreā¦
Using ArcGIS Desktop help
Getting ready
How to do it...
How it works...
Using variables to store data
Getting ready
How to do it...
How it works...
Accessing ArcPy modules with Python
Getting ready
How to do itā¦
How it worksā¦
3. Managing Map Documents and Layers
Introduction
Referencing the current map document
Getting ready
How to do itā¦
How it works
Referencing map documents on a disk
Getting ready
How to do itā¦
How it worksā¦
Accessing a data frame
Getting ready
How to do it...
How it works...
Getting a list of layers in a map document
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Restricting the list of layers
Getting ready
How to do itā¦
How it worksā¦
Changing the map extent
Getting ready
How to do it...
How it works...
Getting a list of tables
Getting ready
How to do itā¦
How it worksā¦
Adding layers to a map document
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Inserting layers into a map document
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Updating layer symbology
Getting ready
How to do itā¦
How it worksā¦
There's more...
Updating layer properties
Getting ready
How to do itā¦
4. Finding and Fixing Broken Data Links
Introduction
Finding broken data sources in your map document and layer files
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Fixing broken data sources with MapDocument.findAndReplaceWorkspacePaths()
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Fixing broken data sources with MapDocument.replaceWorkspaces()
Getting ready
How to do itā¦
How it worksā¦
Fixing individual Layer and Table objects with replaceDataSource()
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Finding all broken data sources in all map documents in a folder
Getting ready
How to do it...
How it works...
5. Automating Map Production and Printing
Introduction
Creating a list of layout elements
Getting ready...
How to do itā¦
How it worksā¦
Assigning a unique name to layout elements
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Restricting the layout elements returned by ListLayoutElements()
Getting ready
How to do itā¦
How it works...
Updating layout element properties
Getting ready
How to do itā¦
How it works...
Getting a list of available printers
Getting ready
How to do itā¦
How it works...
Printing maps with PrintMap()
Getting ready
How to do itā¦
How it works...
Exporting a map to a PDF file
Getting ready
How to do itā¦
How it worksā¦
Exporting a map to an image file
Getting ready
How to do itā¦
How it worksā¦
Creating a map book with PDFDocumentCreate() and PDFDocumentOpen()
Getting ready
How to do itā¦
How it works...
There's moreā¦
6. Executing Geoprocessing Tools from Scripts
Introduction
Finding geoprocessing tools
Getting ready
How to do itā¦
How it worksā¦
Retrieving a toolbox alias
Getting ready
How to do itā¦
How it worksā¦
Executing geoprocessing tools from a script
Getting ready
How to do itā¦
How it worksā¦
There's more...
Using the output of a tool as an input to another tool
Getting ready
How to do it...
How it works...
Setting environment variables and examining tool messages
Getting ready
How to do itā¦
How it worksā¦
7. Creating Custom Geoprocessing Tools
Introduction
Creating a custom geoprocessing tool
Getting ready
How to do itā¦
How it worksā¦
There's more...
8. Querying and Selecting Data
Introduction
Constructing proper attribute query syntax
Getting ready
How to do itā¦
How it worksā¦
Creating feature layers and table views
Getting ready
How to do itā¦
How it works...
There's more...
Selecting features and rows with the Select Layer by Attribute tool
Getting ready
How to do itā¦
How it worksā¦
Selecting features with the Select by Location tool
Getting ready
How to do itā¦
How ...