Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By : Eric Pimpler
Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By: Eric Pimpler

Overview of this book

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.
Table of Contents (17 chapters)
16
Index

Adding Python scripts to batch files

Scheduling your Python scripts to run at prescribed times will require that you create a batch file containing one or more scripts and or operating system commands. These batch files can then be added to the Windows scheduler to run at a specific time interval.

Getting ready

Batch files are text files containing command-line sequences to run Python scripts or perform operating system commands. They have a file extension of .bat, which Windows recognizes as an executable file. Since batch files simply contain command-line sequences, they can be written with any text editor, though it is recommended that you use a basic text editor, such as Notepad. This is done so that you can avoid the inclusion of invisible special characters, which are sometimes inserted by programs, such as Microsoft Word. In this recipe, you will create a simple batch file that navigates to the directory containing your ListFields.py script and executes it.

How to do it...

Follow these...