The purpose of this module will be to explore additional commands and functions of Python in ArcMap for Desktop. Some of the commands and method will be more complicated than those discussed to this point and will assume the knowledge of previous modules. In this module, the IDE will generally be used as the script editor working in the program mode. Other methods could be used, but only one will be demonstrated. All of the operations shown and discussed will require the use of the arcpy module. This module will cover more functions than covered in the previous modules since the foundations have now been set.
Functions to be Covered
- The cursor function has several different types, which include search, insert and update.
- Creating shapefiles without having ArcMap or ArcCatalog opened will be covered.
- Fixing broken links, which is a problem that is caused when files are moved.
- The mapping module will be covered which deals with final map creation.
- Exporting images and Adobe Acrobat files (pdf) as well as multiple exports for creating a map book.
- The layout of a map outside of ArcMap Desktop will also be cover.
- In addition, the with, del and da commands will be explored.
Del
The del statement will delete a variable and its content. When a variable is created, it is available even after the program has been completed. For example, if a variable containing your name was part of an executed script and the user changed to immediate mode and prints the variable it would still contain your name. It is always a good practice to delete the variable when they are no longer needed. It can also insure that information is not passed between different code steps, which would create inaccurate information. In addition, the del statement will release the locks on the file. The file is not being deleted from the hard drive, just from the program memory. If the del command is not used the variable may remain locked, i.e. such as a shapefile and not be able to be used in any other operations. The del command will be demonstrated in other pieces of code in this module and not as an independent command.
Da Module (Data Access)
The da module is the location of the cursor command that will be explored in this module. It works similarly to the arcpy module, and must be imported prior to using the functions contained within the module.