Tuesday, March 15, 2016

Python Scripting One: An Introduciton to Coding for ArcMap

As a basis for future GIS work having a basic understanding of the coding language called Python as it relates to ArcGIS is indispensable.  This post is collective of some introductory exercises that were completed for lab. Python is a coding language used in ArcGIS as a way to complete tasks which would otherwise be very difficult or time consuming if using the more conventional functions of ArcGIS programs. While Python scripting has a much steeper learning curve relative to using GIS tools individually and using a model builder, it is not limited in the same ways. For example, one can create a script to automate complex yet tedious and repetitive tasks. 

Figure one: Collective demos for python scripting. 
There were three different sections for the introductory Python scripting material.  The first section was simply running ESRI ArcMap tools with a script. One will notice this as the green, pound signed block located roughly in the middle of the figure one (it was pound signed so as to speed up diagnostics for later operations). A buffer tool was run shortly before a clip tool.
The second part is listed above the clip and buffer tools is where variables are being defined so the tools can be used for multiple datasets without being rewritten for each time. One only needs to redefine the set parameters for each dataset making it fairly easy to adapt from one place to another.

The third and final section of this short introduction to Python was coding to automatically fetch and display file metadata such as projection. A secondary line of code was used to list raster files in a geodatabase and display the file name and spatial reference. In figure one this is expressed below the green buffer and clip tool code. 

No comments:

Post a Comment