Programming ArcGIS 10.1 with Python Cookbook

This book provides the recipes you need to use Python with AcrGIS for more effective geoprocessing. Shortcuts, scripts, tools, and customizations put you in the driving seat and can dramatically speed up your workflow.

Programming ArcGIS 10.1 with Python Cookbook

Cookbook
Eric Pimpler

This book provides the recipes you need to use Python with AcrGIS for more effective geoprocessing. Shortcuts, scripts, tools, and customizations put you in the driving seat and can dramatically speed up your workflow.
$10.00
$44.99
RRP $26.99
RRP $44.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

+ Collection
Free Sample

Book Details

ISBN 139781849694445
Paperback304 pages

About This Book

  • Learn how to create geoprocessing scripts with ArcPy
  • Customize and modify ArcGIS with Python
  • Create time-saving tools and scripts for ArcGIS

Who This Book Is For

"Programming ArcGIS 10.1 with Python Cookbook" is written for GIS professionals who wish to revolutionize their ArcGIS workflow with Python. Basic Python or programming knowledge is essential(?).

Table of Contents

Chapter 1: Fundamentals of the Python Language for ArcGIS
Using IDLE for Python script development
Python language fundamentals
Summary
Chapter 2: Writing Basic Geoprocessing Scripts with ArcPy
Introduction
Using the ArcGIS Python window
Accessing ArcPy with Python
Executing tools from a script
Using ArcGIS Desktop help
Using variables to store data
Accessing ArcPy modules with Python
Chapter 3: Managing Map Documents and Layers
Introduction
Referencing the current map document
Referencing map documents on a disk
Accessing a data frame
Getting a list of layers in a map document
Restricting the list of layers
Changing the map extent
Getting a list of tables
Adding layers to a map document
Inserting layers into a map document
Updating layer symbology
Updating layer properties
Chapter 4: Finding and Fixing Broken Data Links
Introduction
Finding broken data sources in your map document and layer files
Fixing broken data sources with MapDocument.findAndReplaceWorkspacePaths()
Fixing broken data sources with MapDocument.replaceWorkspaces()
Fixing individual Layer and Table objects with replaceDataSource()
Finding all broken data sources in all map documents in a folder
Chapter 5: Automating Map Production and Printing
Introduction
Creating a list of layout elements
Assigning a unique name to layout elements
Restricting the layout elements returned by ListLayoutElements()
Updating layout element properties
Getting a list of available printers
Printing maps with PrintMap()
Exporting a map to a PDF file
Exporting a map to an image file
Creating a map book with PDFDocumentCreate() and PDFDocumentOpen()
Chapter 6: Executing Geoprocessing Tools from Scripts
Introduction
Finding geoprocessing tools
Retrieving a toolbox alias
Executing geoprocessing tools from a script
Using the output of a tool as an input to another tool
Setting environment variables and examining tool messages
Chapter 7: Creating Custom Geoprocessing Tools
Introduction
Creating a custom geoprocessing tool
Chapter 8: Querying and Selecting Data
Introduction
Constructing proper attribute query syntax
Creating feature layers and table views
Selecting features and rows with the Select Layer by Attribute tool
Selecting features with the Select by Location tool
Combining a spatial and attribute query with the Select by Location tool
Chapter 9: Using the ArcPy Data Access Module to Select, Insert, and Update Geographic Data and Tables
Introduction
Retrieving features from a feature class with a SearchCursor
Filtering records with a where clause
Improving cursor performance with geometry tokens
Inserting rows with InsertCursor
Updating rows with an UpdateCursor
Deleting rows with an UpdateCursor
Inserting and updating rows inside an edit session
Reading geometry from a feature class
Chapter 10: Listing and Describing GIS Data
Introduction
Getting a list of feature classes in a workspace
Restricting the list of feature classes returned with a wildcard
Restricting the list of feature classes returned with a feature type.
Getting a list of fields in a feature class or table
Using the Describe() function to return descriptive information about a feature class
Using the Describe() function to return descriptive information about an image
Returning workspace information with the Describe() function
Chapter 11: Customizing the ArcGIS Interface with Add-Ins
Introduction
Downloading and installing the Python Add-In wizard
Creating a button add-in
Installing and testing an add-in
Creating a tool add-in
Chapter 12: Error Handling and Troubleshooting
Introduction
Exploring the default Python error message
Adding Python exception handling structures (try/except/finally)
Retrieving tool messages with GetMessages()
Filtering tool messages by severity level
Testing for and responding to specific error messages
Returning individual messages with GetMessage()

What You Will Learn

  • Fundamental Python programming skills
  • Update layer properties and symbology
  • Automate map production, printing, and the creation of PDF map books
  • Find and fix broken data links in your map document files
  • Create custom geoprocessing tools that can be shared with others
  • Schedule your geoprocessing scripts to run after hours
  • Create new feature classes or tables and add records, as well as edit feature classes and tables
  • Customize the ArcGIS Desktop interface with Python add-ons

In Detail

ArcGIS is an industry standard geographic information system from ESRI.

This book will show you how to use the Python programming language to create geoprocessing scripts, tools, and shortcuts for the ArcGIS Desktop environment.

This book will make you a more effective and efficient GIS professional by showing you how to use the Python programming language with ArcGIS Desktop to automate geoprocessing tasks, manage map documents and layers, find and fix broken data links, edit data in feature classes and tables, and much more.

"Programming ArcGIS 10.1 with Python Cookbook" starts by covering fundamental Python programming concepts in an ArcGIS Desktop context. Using a how-to instruction style you’ll then learn how to use Python to automate common important ArcGIS geoprocessing tasks.

In this book you will also cover specific ArcGIS scripting topics which will help save you time and effort when working with ArcGIS. Topics include managing map document files, automating map production and printing, finding and fixing broken data sources, creating custom geoprocessing tools, and working with feature classes and tables, among others.

In "Python ArcGIS 10.1 Programming Cookbook" you’ll learn how to write geoprocessing scripts using a pragmatic approach designed around an approach of accomplishing specific tasks in a Cookbook style format.

Authors

Table of Contents

Chapter 1: Fundamentals of the Python Language for ArcGIS
Using IDLE for Python script development
Python language fundamentals
Summary
Chapter 2: Writing Basic Geoprocessing Scripts with ArcPy
Introduction
Using the ArcGIS Python window
Accessing ArcPy with Python
Executing tools from a script
Using ArcGIS Desktop help
Using variables to store data
Accessing ArcPy modules with Python
Chapter 3: Managing Map Documents and Layers
Introduction
Referencing the current map document
Referencing map documents on a disk
Accessing a data frame
Getting a list of layers in a map document
Restricting the list of layers
Changing the map extent
Getting a list of tables
Adding layers to a map document
Inserting layers into a map document
Updating layer symbology
Updating layer properties
Chapter 4: Finding and Fixing Broken Data Links
Introduction
Finding broken data sources in your map document and layer files
Fixing broken data sources with MapDocument.findAndReplaceWorkspacePaths()
Fixing broken data sources with MapDocument.replaceWorkspaces()
Fixing individual Layer and Table objects with replaceDataSource()
Finding all broken data sources in all map documents in a folder
Chapter 5: Automating Map Production and Printing
Introduction
Creating a list of layout elements
Assigning a unique name to layout elements
Restricting the layout elements returned by ListLayoutElements()
Updating layout element properties
Getting a list of available printers
Printing maps with PrintMap()
Exporting a map to a PDF file
Exporting a map to an image file
Creating a map book with PDFDocumentCreate() and PDFDocumentOpen()
Chapter 6: Executing Geoprocessing Tools from Scripts
Introduction
Finding geoprocessing tools
Retrieving a toolbox alias
Executing geoprocessing tools from a script
Using the output of a tool as an input to another tool
Setting environment variables and examining tool messages
Chapter 7: Creating Custom Geoprocessing Tools
Introduction
Creating a custom geoprocessing tool
Chapter 8: Querying and Selecting Data
Introduction
Constructing proper attribute query syntax
Creating feature layers and table views
Selecting features and rows with the Select Layer by Attribute tool
Selecting features with the Select by Location tool
Combining a spatial and attribute query with the Select by Location tool
Chapter 9: Using the ArcPy Data Access Module to Select, Insert, and Update Geographic Data and Tables
Introduction
Retrieving features from a feature class with a SearchCursor
Filtering records with a where clause
Improving cursor performance with geometry tokens
Inserting rows with InsertCursor
Updating rows with an UpdateCursor
Deleting rows with an UpdateCursor
Inserting and updating rows inside an edit session
Reading geometry from a feature class
Chapter 10: Listing and Describing GIS Data
Introduction
Getting a list of feature classes in a workspace
Restricting the list of feature classes returned with a wildcard
Restricting the list of feature classes returned with a feature type.
Getting a list of fields in a feature class or table
Using the Describe() function to return descriptive information about a feature class
Using the Describe() function to return descriptive information about an image
Returning workspace information with the Describe() function
Chapter 11: Customizing the ArcGIS Interface with Add-Ins
Introduction
Downloading and installing the Python Add-In wizard
Creating a button add-in
Installing and testing an add-in
Creating a tool add-in
Chapter 12: Error Handling and Troubleshooting
Introduction
Exploring the default Python error message
Adding Python exception handling structures (try/except/finally)
Retrieving tool messages with GetMessages()
Filtering tool messages by severity level
Testing for and responding to specific error messages
Returning individual messages with GetMessage()

Book Details

ISBN 139781849694445
Paperback304 pages
Read More