Transcription
Advanced Python Scripting for ArcGIS Pro
Ready for something more complex? An easy-to-follow guide to writing specialized Python scripts and developing tools for spatial data in ArcGIS Pro.
Advanced Python Scripting for ArcGIS Pro builds on Python Scripting for ArcGIS Pro (Esri Press, 2020). Learn how to create a geoprocessing tool out of your script and automate tasks in ArcGIS Pro and how to share your tools with others, as well as master a number of more specialized tasks.
Some of the key topics you will learn include:
- Writing specialized scripts using ArcPy
- Creating Python script tools
- Writing Python toolboxes
- Sharing scripts and tools
- Managing Python packages and environments
- Creating custom functions and classes
- Migrating scripts and tools from ArcGIS Desktop to ArcGIS Pro
- NumPy, Pandas, and Matplotlib
- ArcGIS API for Python and Jupyter Notebook
Helpful points to remember, key terms, and review questions are included at the end of each chapter to reinforce your understanding of Python. Companion data and exercises are available online.
Advanced Python Scripting for ArcGIS Pro is perfect for more experienced developers who are looking to upgrade their skills.
Dr. Paul A. Zandbergen is a professor in the GIS program at Vancouver Island University. His teaching includes courses in introductory GIS, spatial analysis and modeling, spatial statistics, and GIS programming. His research focuses on the robustness of spatial analytical techniques in the areas of crime analysis, environmental science, public health, spatial ecology, and water resources. His research has been funded by the National Science Foundation, the National Institute of Justice, and the National Institutes of Health. He has published over 50 journal articles and book chapters. Zandbergen is the author of Python Scripting for ArcGIS, published in 2013 by Esri Press. He lives with his family in Vancouver, British Columbia, Canada.
Published by Esri Press.
Acknowledgments
A book of this scope materializes only with the support of many individuals.
First, I would like to recognize the numerous students in my courses over the years at several institutions. You learn something best by teaching it to others, and Im fortunate to have worked with many aspiring GIS professionals interested in learning Python. Much of what I know about what needs to go in a book like this, I have learned from them.
The contributions of the staff at Esri Press cannot be underestimated. Their ongoing feedback throughout the writing and editing of the manuscript has been invaluable. Other Esri staff members also have left their mark on the book, especially David Wynne and Atma Mani. Their insider perspectives have made the book more accurate and more complete.
Since the publication of the first book, Python Scripting for ArcGIS, I have received a lot of feedback from numerous students, instructors, GIS professionals, and anonymous reviewers. Ive done my best to incorporate all that Ive learned from them into this new book.
I also would like to thank my parents, who always encouraged me to seek a career path that would allow me to fulfill my curiosity about the world while at the same time trying to make it a better place.
Most importantly, this book would not be possible without the continued support of my family. Marcia, Daniel, and Sofia, thank you for believing in me and allowing me to pursue my passions.
Paul A. Zandbergen
Vancouver, BC, Canada
Preface
Programming has become an increasingly important aspect of the skillset of GIS professionals in many fields. Most GIS jobs require at least some experience in programming, and Python is often at the top of the list. Python scripting allows you to automate tasks in ArcGIS Pro that would be cumbersome using the regular menu-driven interface. Python Scripting for ArcGIS Pro, also published by Esri Press (2020), covers the fundamentals of learning Python to write scripts but does not get into the more advanced skills to develop tools to be shared with others. This is where the current book, Advanced Python Scripting for ArcGIS Pro, comes in. If you are looking to take your GIS programming skills to the next level, this book is for you.
Before getting further into the contents of the book, a bit of history is in order. In 2013, Esri Press published Python Scripting for ArcGIS. I wrote the book to serve as an easy-to-understand introduction to Python for creating scripts for ArcGIS Desktop using Python 2. The book quickly became popular among students and professionals, but several years later the book was no longer current.
ArcGIS Pro was released in 2015 and further established Python as the preferred scripting language within the ArcGIS platform. ArcGIS Pro uses Python version 3, which is significantly different from version 2. As the industry started to shift from ArcGIS Desktop to ArcGIS Pro, interest grew in an updated version of the book. Both the changes in ArcGIS and the differences in Python versions necessitated a completely new booknot just a second edition of the existing book with minor code updates. That new book is Python Scripting for ArcGIS Pro.
In addition, the interest in using Python in the geospatial community continues to grow. This has led to an increasing interest in developing Python tools to share with others, using third-party packages created by the open-source geospatial community, and applying Python to new areas such as web GIS. The current book, Advanced Python Scripting for ArcGIS Pro, covers these topics while at the same time teaching best practices in Python coding.
The current book is written for ArcGIS Pro 2.5, which uses Python 3.6.9. As new functionality is added to future releases of ArcGIS Pro, the code in this book will continue to work for the foreseeable future. However, much of the code will not work in ArcGIS Desktop 10.x, although sometimes only minor changes are needed. One chapter in this book is specifically dedicated to explaining the differences between the versions of Python and ArcGIS and how to migrate existing scripts and tools from ArcGIS Desktop 10.x to ArcGIS Pro. In addition, some of the code in this book uses the ArcGIS API for Python 1.7.0, which installs with ArcGIS Pro 2.5.
This book is designed to enhance the skills of those who already have a good foundation in Python to write scripts for ArcGIS. The book covers how to take those scripts and develop them into tools and notebooks to share with others, as well as several other more advanced tasks. A good familiarity with ArcGIS Pro is assumed, including managing data, creating cartographic output, and running tools. You should be familiar with the basic concepts of GIS, including coordinate systems, data formats, table operations, and basic spatial analysis methods. You also need a good foundation in Python and the use of ArcPy for basic tasks, including all the topics covered in Python Scripting for ArcGIS Pro.
The primary audience for this book is experienced ArcGIS Pro users who have already been using Python for some time to write scripts to automate their workflows. If you are already familiar with writing scripts in Python for ArcGIS Desktop 10.x, you may still want to consider the Python Scripting for ArcGIS Pro book, which contains several chapters on topics that have changed significantly between working with Python in ArcGIS Desktop 10.