Good programming language books are scarce. They become outdated pretty fast because of new software or programming language versions, or contain code errors or example code on disk doesn’t correspond with what’s written in the book, leaving you, the reader, confused and frustrated. Some books they’re badly written: too much information is covered in little text, or the organization of the materials is poorly thought-through. All books I’ve read on ArcPy more or less suffered from these shortcomings, except for one: “Programming ArcGIS with Python Cookbook”, written by Eric Pimpler. If you’re thinking of learning ArcPy, there´s no better to place to start than with this book.
Cookbook style format
Most programming books combine theory with practice, or come as a reference book with code snippets scattered throughout the main text. This book takes a more practical approach, being written in a cookbook style format that focuses primarily on the end results: a well-written, finished and working Python script that accomplishes a specific task. The 85+ “recipes” instruct you how to put together such as script and explain in plain English how the code functions when running the finished script.
This cookbook style format means that it’s a hands-on book, requiring a lot of activity from the reader: after all, you are the cook! You are instructed to reproduce example code in the ArcGIS Python window or IDE of your choice and run the code when finished. All scripts are deconstructed into small chunks and are built from the ground up, step by step. Of course you can cheat by copy-pasting it into an IDE directly from a PDF version of the book, but this is not a good idea – you learn more by typing code yourself (and then fix your own typos when the code doesn’t work). The author provided all scripts in a separate directory so you can always compare your own code with his, which is very handy.
The fact that all recipes are entire scripts rather than small code snippets (such as provided in the Help section of ArcGIS Desktop) give the book lots of added value. I should also point out that the scripts focus on one specific task at a time instead of combining multiple tasks. This makes this book a good choice for beginning coders.
What the book covers
The 85+ “recipes” are organized into thirteen chapters in such a way that things start off easy and get more complex later on. The author wisely chose to start with the Python window in ArcGIS Desktop, which is the best place to start working with ArcPy. The ArcPy mapping module is covered first so that you can see the results of your code directly in the map window. Other topics covered are fixing broken data paths, listing and describing data, as well as handling errors and exceptions. Finally, the book also covers creating Python add-ins, working with cursors and executing geoprocessing tools from scripts. The book starts with a short rundown of Python fundamentals for ArcGIS, so for more background on ArcPy and/or Python itself, you have to look elsewhere. The book ends with an appendix covering automation of python scripts and five Python recipes every GIS programmer should know. The book looks beyond the ArcPy site package : some scripts make use of the requests module, that needs to be installed separately from Python. The json module is covered as well.
Some practical information
The second edition of this book was published in July 2015. It was written for ArcGIS Desktop version 10.3. I personally used version 10.4 when running the scripts which worked fine in 95% of all scripts, which is a high percentage compared to other programming books on the market.
This book is available in paperback and a range of digital formats. With the book comes a ZIP file containing example code that can be downloaded from the publisher’s website (instructions are available in the book). A paperback version allows for a free download of the book, which comes in handy if you need to copy long URLs or file paths.
Conclusion
It should be clear by now that this book is a great start for every ArcPy novice. The recipes are clear, short and useful. They cover a broad range of geoprocessing tasks that get you up to speed quickly. The author focuses on one specific task at a time, keeping things simple. All code examples come with an answer sheet, so you can always check your code with a correctly working script. The example data and code are organized in a clarifying way and the same goes for the book content. There are some typos throughout the text but the publisher´s website has a special page where you can check for errata. Apart from some minor flaws, this book is an excellent source for new and experienced ArcPy programmers.