Programming ArcGIS with Python Cookbook - Second Edition
eBook - ePub

Programming ArcGIS with Python Cookbook - Second Edition

  1. 366 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Programming ArcGIS with Python Cookbook - Second Edition

About this book

About This Book

  • Become a more efficient GIS professional by automating your geoprocessing tasks with Python and ArcGIS Desktop
  • In addition to the fundamentals, learn advanced, in-demand GIS skills sought by many employers
  • Step-by-step recipes that provide real-world solutions to common geoprocessing tasks

Who This Book Is For

Programming ArcGIS with Python Cookbook, Second Edition, is written for GIS professionals who wish to revolutionize their ArcGIS workflow with Python. Whether you are new to ArcGIS or a seasoned professional, you almost certainly spend time each day performing various geoprocessing tasks. This book will teach you how to use the Python programming language to automate these geoprocessing tasks and make you a more efficient and effective GIS professional.

What You Will Learn

  • Manage your map document files, layer files, feature classes, and tables
  • Programmatically update layer properties and symbology
  • Find and fix broken data links in your map document files
  • Automate map production, printing, and the creation of PDF map books
  • Develop custom geoprocessing tools that can be shared with others
  • Query and select data from feature classes and tables
  • Create new feature classes or tables and add, update, and delete records
  • Customize the ArcGIS for Desktop interface with Python add-ins

In Detail

The book kicks off with the fundamentals of starting to use Python with ArcGIS, followed by recipes on managing map documents and layers, including how to find and fix broken data links in these files.

In the second part of the book, you will learn to create custom geoprocessing tools and how to use the Attribute and Location tools to select specific features.

The third part of the book covers topics for advanced users including the REST API, and also teaches you how to use Python with ArcGIS Pro. The book finishes with appendices covering how to automate Python scripts, and the five things that should be at the back of every GIS programmer's mind.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Programming ArcGIS with Python Cookbook - Second Edition by Eric Pimpler in PDF and/or ePUB format, as well as other popular books in Computer Science & Application Development. We have over one million books available in our catalogue for you to explore.

Programming ArcGIS with Python Cookbook Second Edition


Table of Contents

Programming ArcGIS with Python Cookbook Second Edition
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
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
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
Using the ArcGIS Python window
The ArcGIS Python window
Displaying the ArcGIS Python window
Python language fundamentals
Commenting code
Importing modules
Variables
Built-in data types
Strings
String manipulation
Numbers
Lists
Tuples
Dictionaries
Classes and objects
Statements
Decision support statements
Looping statements
Try statements
With statements
Statement indentation
File I/O
Summary
2. 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…
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…
Zooming in to selected features
Getting ready
How to do it…
How it works…
Changing the map extent
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…
Working with time-enabled layers in a data frame
Getting ready
How to do it...
How it works…
3. 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 broken data sources in all map documents in a folder
Getting ready
How to do it...
How it works...
4. 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 the properties of layout elements
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…
Exporting a report
Getting ready
How to do it…
How it works…
Building a map book with Data Driven Pages and ArcPy mapping
Getting ready
How to do it…
How it works…
Publishing a map document to an ArcGIS Server service
Getting ready
How to do it…
How it works…
5. 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...
6. Creating Custom Geoprocessing Tools
Introduction
Creating a custom geoprocessing tool
Getting ready
How to do it…
How it works…
There's more...
Creating a Python toolbox
Getting ready
How to do it…
How it works…
7. Querying and Selecting Data
Introduction
Constructing a 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 it works…
Combining a spatial and attribute query with the Select by Location tool
Getting ready
How to do it...
How it works...
8. Using the ArcPy Data Access Module with Feature Classes and Tables
Introduction
Retrieving features from a feature class with SearchCursor
Getting ready
How to do it…
How it works…
Filtering records with a where clause
Getting ready
How to do it…
How it works…
Improving cursor performance with geometry tokens
Getting ready
How to do it…
How it works…
I...

Table of contents

  1. Programming ArcGIS with Python Cookbook Second Edition