Scripting/Automating/ Customizing ArcGIS

And other ways of streamlining your workflow Tom Schwartzman ESRI Boston July 13, 2005

Goals
Learn about:
• Geoprocessing (automation) • Scripting (automation) • Customizing

Expectations We’re not going write code today We will look at some samples and learn how to install them This is basic/intermediate user-level .

Geoprocessing Framework Tools Commands Models Scripts Analysis platform Flexible Extendable .

ArcToolbox A dockable window in ArcMap and ArcCatalog .

ArcToolbox Can create your own toolboxes • Store on disk or in a geodatabase • Holds tools and models • Can be shared with others .

The Command Line It’s back. and has “intellisense” .

Using Modelbuilder Models are created in the Modelbuilder window Color coded by object type • • • Data Tool Result Models can be converted to scripts • Python • vbScript • Jscript Run processes in batch .

Modelbuilder Functionality Models can be made flexible with parameters that can be input at run time Variables can hold user defined constants Tests of conditions can be used for branching Preconditions can be set on processes Models can call other Models .

Adding Data Add feature classes to model • Drag and Drop • Add from file system • Add Layer from ArcMap .

Adding Tools Add tools to model • Drag and Drop from Toolbox • Connect pieces .

Model Parameters Data and variables can be used as model parameters • Data to be input at run time • Data to be output at the end to another destination .

Variables and Preconditions Variables hold constant values. or can be set as parameters Preconditions determine the order of execution for processes • Drawn in diagram with a dashed line .

Export from Modelbuilder Models can be converted to scripts • • • Python vbScript Jscript Scripts cannot then be exported back to models Modified Script can then be added as a Script Tool in a toolbox .

simple syntax Lots of good books out there • O’Reilly Press: Learning Python – good for beginners • O’Reilly Press: Programming Python – good reference • Interactive execution window: PythonWin • Basic development environment: IDLE • Widely accepted scripting language .microsoft.mspx contains list of Windows samples scripts Easy to learn.python.org Microsoft Page http://www.com/technet/scriptcenter/sc ripts/python/default.Introduction to Python Free and powerful scripting language Can do many tasks in addition to working with the geoprocessing (gp) framework Python Page http://www.

object-oriented.The Python scripting language What is Python? • An open-source. can be broken apart Cross platform Ability to compile scripts Installed with ArcGIS 9 and ESRI samples provided . scripting language Can view and modify source code Easy to use Python Python script script Why use Python? • • • • • Offers IDEs with debugging tools Modular.

save. shareware. or paid • TextPad • UltraEdit • Komodo PythonWin and IDLE come with the installation Samples use PythonWin • Environments to write.Writing Python Scripts Python scripts can be written in Notepad. and debug code . free. run. or any text editor.

User Interface Customization Toolbars and some windows are dockable Double click title to autodock/undock Hold CTRL key down to avoid auto-docking .

Toolbars Change locations of buttons/tools. delete/add buttons/tools Create your own toolbar with your choice of buttons/tools Available by using “Customize” dialog • • • Tools Customize Double-click in empty area of toolbar Right-click and choose “Customize” .

Toolbars cont’d .

Examples: • Clear Selected • Zoom to Selected • Continuous Zoom •… .Toolbars Lots of useful buttons/tools exist but are not on any toolbar.

com) Some are VBA scripts (pasted into VBA editor in ArcMap) and run from a button-click . online http://edn.esri.com) • Users (http://arcscripts.Samples Lots of samples out there from: • ESRI (Developer Kit CD.esri.

Samples Some are simply added using “Add from file…” in the Customize Dialog .

etc) Hopefully this is documented with the sample! .Samples Some come with an installer of some sort (batch file.exe to register the compiled . • Regsvr32. sketch tool.dll with the system • Categories.exe to tell ArcGIS what part of the system it belongs in (e.g. etc) And some need more help getting “registered”. exe. renderer.

etc) • You won’t lose data .Templates Predefined map layouts that can be imported into your current doc Your layout will change to match the template • You may lose/gain elements (legend. north arrow.

Training Instructor Led: • Intro to ArcObjects: Aug 15-19 • Intro to Python: Sep 8-9 Virtual Campus: • • • • • Customizing ArcGIS 9 Customizing ArcMap Exploring VBA Working with Forms in VBA Working with Variables and Functions in VBA .

Training Instructor Led: • Intro to ArcObjects: Aug 15-19 • Intro to Python: Sep 8-9 Virtual Campus: • • • • • • Customizing ArcGIS 9 Customizing ArcMap Exploring VBA Working with Forms in VBA Working with Variables and Functions in VBA Getting Started with Scripting (free) .

Sign up to vote on this title
UsefulNot useful