Wednesday, June 26, 2013 at 15:04:44
It’s been on my “to-do” list for a while, but I finally got around to taking a more detailed look at Programming with ArcGIS 10.1 with Python Cookbook…… I was sent a review copy of the PDF, but as I regularly dip in-and-out of Python programming, and we teaching it as part of the MSc in GIS at Kingston University, it would have been on my list of resources to check out. And having done both the Esri Python and a longer, generic Python, course I was interested to see what it covered.
Subtitled “Over 75 recipes to help you automate geoprocessing tasks, create solutions, and solve problems for ArcGIS with Python” and at over 300 pagse long its not a slim tome and has a lot in it. The chapter headings go thus:
Chapter 1: Fundamentals of the Python Language for ArcGIS
Chapter 2: Writing Basic Geoprocessing Scripts with ArcPy
Chapter 3: Managing Map Documents and Layers
Chapter 4: Finding and Fixing Broken Data
Chapter 5: Automating Map Production and Printing
Chapter 6: Executing Geoprocessing Tools from Scripts
Chapter 7: Creating Custom Geoprocessing Tools
Chapter 8: Querying and Selecting Data
Chapter 9: Using the ArcPy Data Access Module to Select, Insert, and Update Geographic Data and Tables
Chapter 10: Listing and Describing GIS Data
Chapter 11: Customizing the ArcGIS Interface with Add-Ins
Chapter 12: Error Handling and Troubleshooting
Appendix A: Automating Python Scripts
Appendix B: Five Things Every GIS Programmer Should Know
Off-the-bat it’s written in an easy and accessible style that isn’t particularly technical - yes, its an introductory book targeted at those less familiar with programming, not too surprising given its likely audience of ArcGIS desktop users wanting to delve under the hood a little more. It’s also pleasingly typeset - it hasn’t had a pile of money ploughed in to design, but it is pleasantly produced with a reasonable use of clearly flagged titles and figures. The style is clearly practical based and wouldn’t look out of place in a university of user training course - there is informative writing and it flows quite well. There are “information” sections in square brackets which highlight key information and there is support in the form of downloadable code examples.
Chapter 1 provides a light and easy introduction to Python within the ArcGIS environment - it is firmly aimed at 10.1. And whilst no assumption of programming experience is made, there are references to other languages. There is then a short and swift run through modules, variables, datatypes (strings, numbers, lists, tuples, doctionaries), classes/objects and statements. And if there is a rush to get to statements then there is probably good reason as they allow you to develop the core-critical aspects of an algorithm - that is conditional statements and looping statements. These two things along turn a script in to a useful iterative function. That brings in to last element of the chapter: input/output (aka get data in, spit data out). If it feels like a whirlwind then it is, but readers will want to be through this introduction and diving in to running scripts straight away.
Chapter 2 then feels more like a practical - after your intro in Chapter 1 you’ll be itching to get going and this is precisely what this “practical style” chapter does based upon availble scripts/MXDs that you can download. It covers the use of the Python window in ArcGIS, loading a script and running it. It then moves on to getting you to write and run a simple buffering script and using the online help system. The chapter then moves on to the use of variables and adding modules. Its a gentle introduction but flows nicely from the introduction.
Now that you are gently eased in to the driving seat of scripting, the book takes a fairly even path in working with ArcGIS: Ch3 deals with managing map documents (disk access, data frame, layers, tables, symbology), Ch4 looks at fixing broken data links (dealt with early on as its a “gotcha” when someone on your network sends you an MXD and it doesnt work; brilliant use of scripting to automate the fix process…. although Esri shouldnt put us in this positionin the first place!), with Ch6 moving on to automating the production of maps (and their printing). With these essential tasks covered, many users will be happy to stop at this point safe in the knowledge that their lives are suddenly much easier!! But onwards….
….because Python and geoprocessing runs much deeper! Ch6 deals with running geoprocessing tools, surely the bread-and-butter of Python work. Develop your geoprocessing workflow then automate it in Python….then create your own geoprocessing tool (Ch7) so you (and other users) can access it over and over. Ch8 and 9 then branch on to the more complex stuff…. querying and selecting data, then updating and inserting new data. This requires a more intricate knowledge of cursors and then variables, conditional statements and looping. But is incredibly useful. Ch 10, 11 and 12 then mop up with listing data, add-ins and error handling.
As an introduction its accessible and easy to follow with well worked examples. It does feel like one long practical and it is…. its designed for users new to scripting who need hands-on experience. Its not a text book or a reference book…. you’ll need to go elsewhere for those. But for getting a first foot on the ladder of scripting and expanding your toolset of CPD its a good place to start and well priced.