Python: Building Geoprocessing Tools David Wynne, Ghislain Prince.

Slides:



Advertisements
Similar presentations
Why python? Automate processes Batch programming Faster Open source Easy recognition of errors Good for data management What is python? Scripting programming.
Advertisements

Automating Tasks With Macros
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
Python & ModelBuilder. Overview Python/ModelBuilder Concepts – The Geoprocessor – Checking some environment variables – Providing feedback from your model/script.
ModelBuilder In ArcGIS 9.x By Tim Weigel GEOG 407/607 April 3 rd, 2006.
Geography 465 Overview Geoprocessing in ArcGIS. MODELING Geoprocessing as modeling.
Technical Workshops | Esri International User Conference San Diego, California Customizing ArcPad solutions Marika Vertzonis, Gareth Walters, Stephen Quan.
ModelBuilder at ArcGIS 9.2 Lyna Wiggins Rutgers University May 2008.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Advance Model Builder Features. Advance Features Using Lists (also Batching) Iteration Feedback Model Only Tools Inline Variable Substitution Preconditions.
Arc: Programming Options Dr Andy Evans. Programming ArcGIS ArcGIS: Most popular commercial GIS. Out of the box functionality good, but occasionally: You.
Editing With ArcGIS Pro
Python & ModelBuilder. Continuing Education Python and ModelBuilder Overview Python/ModelBuilder Concepts –The Geoprocessor –Checking some environment.
Esri International User Conference | San Diego, CA Technical Workshops | Python – Getting Started Drew Flater, Ghislain Prince July 12 - July 14, 2011.
Working with cursors in Python GISDE Python Workshop Qiao Li.
Troubleshooting SQL Server Enterprise Geodatabase Performance Issues
Troubleshooting Replication and Geodata Services
Network Analysis with Python
Introduction to ArcPy. Topics What is ArcPy? Accessing geoprocessing tools using ArcPy Writing scripts using ArcPy.
Python: An Introduction
Extending ArcGIS for Server
ArcGIS Network Analyst: Automating Workflows with Geoprocessing
ArcGIS Workflow Manager: Tasks and Enterprise Workflows Michael Broadbent.
Creating Apps Using ArcGIS Online Templates
Publishing to ArcGIS for Server
Data Interoperability Basics Bruce Harold & Dale Lutz.
Enabling High-Quality Printing in Web Applications
Leveraging ArcGIS Online Elevation and Hydrology Services
Working with Metadata in ArcGIS Aleta Vienneau. Working with metadata in ArcGIS View metadata Edit metadata Set your metadata style Leverage metadata.
Introduction of Geoprocessing Topic 7a 4/10/2007.
Python, Toolboxes, Tools & Script Tools
ArcGIS Pro: A Quick Tour of Python David Wynne.
ArcGIS Pro: Mapping and Visualization Craig Williams, Edie Punt, &
Esri Roads and Highways: An Introduction to Roadway Reporter
Preparing and Deploying Data to ArcPad Juan Luera.
Converting workflows from ArcSDE Command line in ArcGIS 10.3.x
Getting the most out of ArcGIS Web Application Templates
Introduction to Web AppBuilder for ArcGIS: JavaScript Apps Made Easy
Esri Production Mapping: Automate Map Production With ArcGIS Workflow Manager Joe Sheffield.
Esri UC 2014 | Demo Theater | Using ArcPad in the Field Juan Luera.
Introduction to ArcGIS for Environmental Scientists Module 3 – GIS Analysis Model Builder.
Network Analyst in ArcGIS Pro Scott Sandusky. Network Analyst in ArcGIS Pro This session covers how to use Network Analyst in ArcGIS Pro. It will also.
ArcGIS Workflow Manager: Getting Started with Out-of-the-Box Templates Michael Broadbent.
Extend the Operations Dashboard with Custom Widgets (and more)
Esri UC2013. Technical Workshop. Technical Workshop 2013 Esri International User Conference July 8–12, 2013 | San Diego, California Automating Geodatabase.
Working with Feature Services Gary MacDougall Russell Brennan.
Getting the most out of ArcMap Jack Horton & Jorge Ruiz-Valdepeña.
Esri UC 2014 | Technical Workshop | Creating Geoprocessing Services Kevin Hibma.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
ArcGIS Editor for OpenStreetMap: Contributing Data Christine White.
Extending the Operations Dashboard
Advanced workflows for creating 3D Web Scenes in ArcGIS Online Javier Gutierrez and Janett Baresel.
Developing Cross Platform Apps with the ArcGIS Runtime SDK for Qt
Esri Roads and Highways: Using Intersections to Locate Event Data Nathan Easley.
Esri UC 2014 | Technical Workshop | Python: Beyond the Basics David Wynne, Jon Bodamer.
Introduction of Geoprocessing Lecture 9 3/24/2008.
Technical Workshops | Esri International User Conference San Diego, California Branching and Iteration in ModelBuilder Shitij Mehta July 24, :15.
Excel Tutorial 8 Developing an Excel Application
PYTHON: AN INTRODUCTION
Shankar Chandrasekaran
String several geoprocessing processes
Creating Geoprocessing Services
Using Model Builder in ArcGIS
Network Analysis using Python
PYTHON: BUILDING GEOPROCESSING TOOLS
Network Analyst – Automating Workflows with Geoprocessing
Python – Beyond the Basics
ModelBuilder – Getting Started
Geocoding with ArcGIS Pro: Getting Started
Geocoding with ArcGIS Desktop: An Introduction
Presentation transcript:

Python: Building Geoprocessing Tools David Wynne, Ghislain Prince

Why we build geoprocessing tools Your work becomes part of the geoprocessing framework - Easy to access and run from within ArcGIS - Familiar look and feel - Make a mistake? Re-run from the previous result - Run from Python, ModelBuilder, as a service - Add to a tool bar No UI programming

What makes a good geoprocessing tool? Performs an essential and elemental operations on data - Can be combined with other tools to perform larger processes - Simple; isn’t overcomplicated Looks and feels like other geoprocessing tools (‘conventions’) - Such as has an output (‘required’ or ‘derived’) - Parameter type: Required → optional → derived - Parameter direction: Inputs → outputs Includes documentation

Deconstructing a geoprocessing tool A geoprocessing tool does three things 1. Defines parameters 2. Validates parameters 3. Executes source

Turning Python code into geoprocessing tools Demo

Script tools vs Python toolboxes Using Python, we can build tools in two ways: Which do I use? - “A tool is a tool” - From a development perspective, Python toolboxes are easier to manage/code * * Says Dave (use what suits you)

Parameters Parameters are how you interact with a tool Simple rules to guide behaviors - Does an input exist? - What are valid fields for this data source? - Is this value an expected keyword? A geoprocessing tool does three types of work: 1. Defines its parameters 2. Validates its parameters 3. Executes code that performs the actual work Data typeTypeDirectionDefaultDependencyFilterEnvironmentSymbologyMultivalue

Parameters Key parameter characteristics 1. Data type - Feature layers, raster layers, table views, … - String, Boolean, long, double, … 2. Direction - Input, output 3. Parameter type - Required, optional, derived

Parameters – Parameter Dependencies (‘obtained from’) Some data types are dependent on other parameters - Field, SQL Expression, Field Info provide little value on their own Set a dependency to a different data type

Parameters - Symbology Control the appearance of output by setting symbology Set using a layer file either a : 1. Parameter property 2. Or in your source code - Important if you want to vary the symbology based on logical criteria

Parameters - Filters Filters are used to limit choices to acceptable values For example: - A number between 1 and 10 - A string parameter with keywords - A file parameter that will only accept files with a.txt extension

Parameters - Environments Some parameter data types match closely with geoprocessing environments Can configure a parameter to use an environment (if set) by default

Parameter-izing a tool Demo

Validation Provide additional behavior for how parameters respond and interact to values and each other With Python code that you write - Control parameter interaction - Calculate defaults - Enable or disable parameters - Messaging (to guide parameter choices and protect against invalid ones) A geoprocessing tool does three types of work: 1. Defines its parameters 2. Validates its parameters 3. Executes code that performs the actual work

A quick note about Python toolboxes and script tools

Validation Parameter definitions provide common ‘validation’ requirements For additional control, use updateParameters and updateMessages Validation is run every time a value changes Validation logic is usually based on: - value (or valueAsText) - altered - hasBeenValidated

Validation: ModelBuilder Describe outputs for chaining in ModelBuilder Data variables in ModelBuilder include descriptions of data By updating the schema, subsequent tools can see pending changes prior to execution

Validation: Messages Messages are added in updateMessages A tool will not run while a parameter has an active error message setErrorMessage( ) setWarningMessage( )

Validation: Licensing Check if a tool is licensed to execute* If isLicensed returns False, the tool is blocked from executing * Python toolbox only

Validation – Feature Layers The type of a layer parameter changes depending if the input is a layer or feature class

Using parameter objects New at and Pro 1.1 Describe accepts parameter objects directly - For layers, using parameter.value is expensive - Using parameter directly is much faster (more noticeably in Pro)

Working with validation: Script tools and Python toolboxes Demo

Execution The ‘business logic’ of your tool A. Parameters are received by your code - parameter.value or parameter.valueAsText - arcpy.GetParameter(n) or arcpy.GetParameterAsText(n) B. The logic of your tool is performed - Communication can be added with messages and progressor C. Derived output values (if any) are pushed back A geoprocessing tool does three types of work: 1. Defines its parameters 2. Validates its parameters 3. Executes code that performs the actual work

Distributing your tools Easy to ‘share’ a toolbox. - Simply share the files or package a result But! To have your toolboxes blend seamlessly, distribute as a Python site-package - Are easily distributable - Toolboxes appear as System Toolboxes - Toolboxes become available through arcpy - Supports dialog side-panel help and localized messages Requires specific structure

Python at User Conference TuesdayWednesdayThursday 8:30Python: An IntroductionPython Map Automation: Introduction to… Python: An Introduction Python: Raster Analysis 10:15Python: Beyond the Basics Python Map Automation: Introduction to … 11:30ArcGIS Pro: A Quick Tour of Python 1:30Python: Building Geoprocessing tools Advanced Map Automation with Python 3:15Python: Raster AnalysisAdvanced Map Automation with Python (54 Python sessions)

Thank you… Please fill out the session survey in your mobile app Select Python: Building Geoprocessing Tools in the Mobile App - Use the Search Feature to quickly find this title Click “Technical Workshop Survey” Answer a few short questions and enter any comments