330 likes | 633 Views
Python, ArcToolBox, & Geoprocessing. MapMyRun.com. Overview. ArcToolbox overview ArcGIS Python scripting The arcgisscripting module & Geoprocessor object Environment settings Accessing system/custom tools Workspaces Case sensitivity Geoprocessing / Python helpful resources. Example:.
E N D
Overview • ArcToolbox overview • ArcGIS Python scripting • The arcgisscripting module & Geoprocessor object • Environment settings • Accessing system/custom tools • Workspaces • Case sensitivity • Geoprocessing / Python helpful resources
Example: ArcToolbox & Geoprocessing * ArcToolbox Toolbox * * Tool Toolset Tools may have same nameif they are in different toolboxesExample: Clip_analysis Clip_management System tool Model Toolboxes, Toolset, Tools depend on license Script
Accessing Geoprocessing in ArcGIS • GUI • Command line • Models • Scripts
Scripts and ArcToolbox • Scripts can be added as tools to ArcToolbox • Should be fully debugged before they are added as a tool • Use PythonWin, for example, to run the script interactively until it is working perfectly • Can add flow control to your models • Branching with “if … elif … else” and output parameters (e.g. boolean) can be used to control flow • Repetition with “for” or “while”(Geoprocessing at 9.4 will offer iterators)
arcgisscripting module The arcgisscripting module provides the method for you to create a Geoprocessor object PYD files are in the format of a .DLL file.
arcgisscripting.create() Creating an ArcGIS Geoprocessor object …
Geoprocessor Dynamic Methods & Properties • Environment/Tool are dynamic methods/properties of the Geoprocessor • Names and values are dynamic as we will see in next few slides
Environment settings • Parameters for a geoprocessing session • Saved in MXD/MXT, model, or script
9.2 had enumerations None envs.next() Enumeration objects have next and reset methods envs.next() envs.reset() envs.next() envs.next() None 9.3+ has Python lists
Geoprocessor Dynamic Methods & Properties • Environment/Tool are dynamic methods/properties of the Geoprocessor • Names and values are dynamic as we will see in next few slides
Accessing system tools in Python • gp.<ToolName>_<ToolboxAlias> Use Toolbox alias on your toolboxes and tools.
Workspaces • As far as the geoprocessor is concerned, a workspace is a: • Folder as described above • A file-based geodatabase • A geodatabase in Microsoft Access format • An SDE database connection
Accessing a Workspace • gp.Workspace specifies the default workspace containing your data • This is optional … it does not need to be set to do geoprocessing • You can process data in different folders in the same geoprocessing command.
.Exists and .OverWriteOutput • gp.Exists(object) • Test whether or not an object exists (folder, geodatabase, file, toolbox, etc.) • gp.OverWriteOutput = True (1) or False (0) • Specifies whether or not output files will overwrite files of the same name.
Overview • ArcToolbox overview • ArcGIS Python scripting • The arcgisscripting module & Geoprocessor object • Environment settings • Accessing system/custom tools • Workspaces • Case sensitivity • Geoprocessing / Python helpful resources
Be sensitive to case sensitivity • Geoprocessor properties / methods ARE NOT case sensitive • Path names ARE NOT case sensitive • Any variables that you use ARE case sensitive Either of these works fine …
Geoprocessing help – ArcGIS Tutorial Focus is mostly on solving geoprocessing problems with models. However, does show how to use scripts in models.
Geoprocessing help – Overlay & Extract poster Nice one-pager that graphically showsoverlay and extract functions.
Geoprocessing help – 9.3 Geoprocessor OMD Geoprocessing help – 9.3 Geoprocessor OMD
Overview • ArcToolbox overview • ArcGIS Python scripting • The arcgisscripting module & Geoprocessor object • Environment settings • Accessing system/custom tools • Workspaces • Case sensitivity • Geoprocessing / Python helpful resources