Using Python with ArcGIS

Similar documents
Python Getting Started

Python Getting Started

Python: Getting Started. Ben

Using Python with ArcGIS

Using Python with ArcGIS

PYTHON. Scripting for ArcGIS. writeoutput = Inputfc = ar. .ext.{) OUtpUt fc =.. Paul A. Zandbergen. axcpy random. .arcpy, Describe (' is.

Using Python in ArcGIS Oli Helm May 2, 2013

Using Python in ArcGIS Steven Beothy May 28, 2013

What s New for Developers in ArcGIS Maura Daffern October 16

What s s Coming in ArcGIS 10 Desktop

Python Map Automation Beyond the Basics of arcpy.mapping

PYTHON: BUILDING GEOPROCESSING TOOLS. David Wynne, Geri Miller

Building Geoprocessing Tools with Python: Beyond the Basics. Dave Wynne

ArcGIS Viewer for Microsoft Silverlight An Introduction

ArcGIS Pro Terminology Guide

ArcGIS Pro Terminology Guide

Creating Mosaic Datasets and Publishing Image Services using Python

Python - Raster Analysis

ArcGIS Desktop The Road Ahead. Amadea Azerki

ModelBuilder: An Introduction. Kevin Armstrong

Python Map Automation: Introduction to arcpy.mapping / arcpy.mp. Jeff Barrette

Python: Beyond the Basics. Michael Rhoades

An Introduction to Data Interoperability

Creating Geoprocessing Services and Web Tools. Darren Baird, PE, Esri

Python Raster Analysis. Kevin M. Johnston Nawajish Noman

Parallel Python: Multiprocessing With ArcPy. Clinton Dow Geoprocessing Neeraj Rajasekar Spatial Analyst

ArcGIS Pro. Terminology Guide

Advanced Parcel Editing. Amy Andis Tim Hodson

Python: Working with Raster Data. Nawajish Noman Elizabeth Graham

Python Raster Analysis. Kevin M. Johnston Nawajish Noman

Getting Started with the ArcGIS Runtime SDKs. Dave, Will, Euan

Applications of Python Scripting: Creating Custom Map Books in ArcGIS 10

ArcGIS Desktop: Introduction to Geoprocessing with ModelBuilder Kevin Armstrong ESRI

Enabling High-Quality Printing in Web Applications. Tanu Hoque & Scott Moore

Developers Road Map to ArcGIS Desktop and ArcGIS Engine

Extending ArcGIS for Server. Jon Satchwell, Esri Switzerland Cédric Despierre Corporon, Esri France

Python: Working with Raster Data

Working With Raster Data Using Python. Nawajish Noman Ryan DeBruyn

ICIT. Brian Hiller ESRI Account Manger. What s new in ArcGIS 10

Designing and Using Cached Map Services

Enabling High-Quality Printing in Web Applications

Enabling High-Quality Printing in Web Applications

Python Raster Analysis

ArcGIS for Developers: An Introduction. Moey Min Ken

ArcGIS 10.1 for Desktop Artie Robinson

Lecture 12 Programming for automation of common data management tasks

What s New in Desktop 10.1

Automating Geodatabase Creation with Geoprocessing

Creating Web Mapping Applications. Nikki Golding

Working with the ArcGIS Viewer for Flex Application Builder

Introduction to Geodatabase and Spatial Management in ArcGIS. Craig Gillgrass Esri

ArcMap: Tips and Tricks

Building tools with Python

Data Interoperability An Introduction

PUG List. Raster Analysis 3D Analysis Geoprocessing. Steve Kopp

Deploying ios Apps. Al Pascual

What is map scripting (aka arcpy.mapping arcpy arcpy.mapping)? mapping)? mapping)? A new mapping module that is part of the geoprocessing ArcPy site s

Web Mapping Applications with ArcGIS. Bernie Szukalski Derek Law

Getting Started with ArcGIS Runtime SDK for Qt. Thomas Dunn & Nandini Rao

Developing Qt Apps with the Runtime SDK

ArcGIS Enterprise Extending Services. Bill Major

Basics of Using LiDAR Data

Best Practices for Designing Effective Map Services

WEB GIS DEVELOPER SPECIALIST ONLINE TRAINING. GIS Training. Course. .com

ArcGIS Runtime SDK for Qt: Building Apps. Koushik Hajra and Lucas Danzinger

Transitioning to the ArcGIS Runtime SDK for.net. Antti Kajanus & Mike Branscomb

Delineating Watersheds from a Digital Elevation Model (DEM)

Working with Metadata in ArcGIS

3D Analysis Tools and Visualization with ArcGIS. Jie Chang Jinwu Ma

Encoded URLs in hyperlinks. TerraGo Publisher for ArcGIS TerraGo Publisher for ArcGIS Server TerraGo Arc2Edge Version 7.3.

ESRI Technology Update. Joe Holubar Larry Young

Mid-West ESRI Utility User s Group Conference. March 26, 2014

hereby recognizes that Timotej Verbovsek has successfully completed the web course 3D Analysis of Surfaces and Features Using ArcGIS 10

ArcGIS Pro: Mapping & Visualization. David Watkins, Edie Punt &

Working with Feature Layers. Russell Brennan Gary MacDougall

Esri Developer Summit in Europe Building Applications with ArcGIS Runtime SDK for Java

PYTHON: BUILDING GEOPROCESSING TOOLS. David Wynne, Andrew Ortego

Automated detection and enumeration of marine wildlife using unmanned aircraft systems (UAS) and thermal imagery

Web AppBuilder Presented by

Building WPF Apps with the new ArcGIS Runtime SDK for.net. Antti Kajanus Mike Branscomb

Developing Add-Ins for ArcGIS Pro (.NET) Toronto Esri Canada UC Presented by: Gandhar Wazalwar & Kern Ranjitsingh October 11, 2018

Data Interoperability An Introduction

Map Algebra: Getting Started. Nawajish Noman

Python: Beyond the Basics. John Lam Esri China (Hong Kong) Richard Chau Esri China (Hong Kong)

Module 7 Raster operations

ArcGIS Runtime SDK for.net: Building Xamarin Apps. Rich Zwaap Thad Tilton

Getting Started with Spatial Analyst. Steve Kopp Elizabeth Graham

USING PYTHON WITH ARCGIS ADVANCED LEVEL ONLINE TRAINING GIS. Course. Training. .com

Building Applications with the ArcGIS Runtime SDK for WPF

Introduction to Web AppBuilder for ArcGIS: JavaScript Apps Made Easy

Working with Scientific Data in ArcGIS Platform

LocateXT Version 1.3 Quick Start

ArcGIS Viewer for Silverlight Advanced Topics

ArcGIS Viewer for Flex An Introduction

ArcGIS Enterprise: Portal Administration BILL MAJOR CRAIG CLEVELAND

Hit the Ground Running. ArcGIS Runtime SDK for Android

A Second Look at DEM s

Getting Started with ArcGIS Runtime SDK for the Microsoft.NET Framework. Morten Nielsen Mike Branscomb Antti Kajanus Rex Hansen

ArcGIS Runtime SDKs Building Offline Apps. Nick Furness

What s New in ArcGIS Server 10

Transcription:

Using Python with ArcGIS Drew Flater, Nobbir Ahmed Offering 184

Agenda Python essentials Arcpy, functions & classes Script geoprocessing workflows Automate map management & production Customize Desktop with Python Add-ins Analyze rasters with map algebra Extend ArcGIS with Python

Python Essentials Getting started with Python in ArcGIS

What is Python? Python is an easy to learn, powerful language (with) high-level data structures and a simple but effective approach to object-oriented programming. Python s elegant syntax and dynamic typing make it an ideal language for scripting in many areas and on most platforms. python.org Scripting language of ArcGIS Free, cross-platform, easy to learn, widely useful, great community

Python 101 Where do I write Python code? Python file is text with.py extension Edit in IDE like PyScripter, Wing IDE Logic for testing conditions If, else statement Operators like >, <, ==,!=, in Techniques for iteration or looping While loop; for loop Building blocks Function, Module, Package math.sqrt(100) 10 Python Standard Library / Built-ins os, sys, math, datetime, urllib2

ArcPy Site package included with ArcGIS that enables interaction with Python The access point to 900+ geoprocessing tools A package of functions, classes and modules Helper functions that perform useful tasks and enable automation (ListFeatureClasses, Describe, SearchCursor) Classes that can be used to create complex objects (SpatialReference, Geometry, FieldMap) Modules that provide specialized functionality (mapping, SpatialAnalyst, data access) Enhancement of arcgisscripting module (pre-10.0) Your old scripts will work

Why use Python and ArcGIS? Automate repetitive tasks Batch processing Develop workflows that leverage hundreds of tools and functions Add geoprocessing services to your application Customize Desktop apps with a language Esri is committed to support Extend the capabilities of ArcGIS

Script Geoprocessing Workflows Calling geoprocessing tools through ArcPy and stringing them together

Geoprocessing and Python import arcpy Follow tool syntax arcpy.toolname_toolboxalias() Enter input and output parameters How do I use a specific tool? Tool help page Copy as Python Snippet help(arcpy.buffer_analysis) Use geoprocessing environments as global parameters Accessed from arcpy.env Productivity / code cleanup tool workspace, extent, cellsize, mask

Demo Script Geoprocessing Workflows Perform batch processing, and string together multiple tools to perform spatial analysis

Tips & Tricks Use the result object of geoprocessing tools Returned by all tools Maintains messages, parameters, and outputs result = arcpy.buffer_analysis( ) Write intermediate tool output to in_memory workspace Automatic cleanup Faster read-write

Automate Map Management & Production Working with maps and layers using arcpy.mapping

ArcPy Mapping module arcpy.mapping Module that contains functions and classes used to automate mapping tasks Manage map documents, layers, and data Find and fix broken data sources Update layer symbology across many maps Export and print map documents Automate map production / map series

ArcPy Mapping module MapDocument object is essential References.mxd on disk; has methods and properties Needed to perform most mapping tasks MapDocument as input to function Functions called from MapDocument md = arcpy.mapping.mapdocument(" /NtlParks.mxd") # Set map document properties md.description = "Map of National Parks" # List layers in the map maplayers = arcpy.mapping.listlayers(md) # Fix Data Sources md.replaceworkspaces( ) # Export the map to PDF arcpy.mapping.exporttopdf(md, " /NtlParks.pdf")

Mapping module resources Download sample tools

Demo Automate Map Management & Production Make a multi-page map book using arcpy.mapping and data driven pages

Customize ArcGIS Desktop with Python Add-ins Run Python code in response to button clicks and application events

ArcGIS Desktop Add-ins Add-in framework provided to customize and extend ArcGIS Desktop applications Easy to build, install and share Secured through digital signing Supports C#, VB.NET, Java, and Python Python makes add-ins easier! No dlls, compiling, or ArcObjects, and less code

Python Add-in Types Button Tool Toolbar Tool Pallet Combo Box Menu Extension Dockable windows are not supported No custom UI support

Python Add-In Classes and Methods Button Tool onclick() oncircle(), online(), onrectangle() onmousedown(), onmousedownmap() Application Extension startup() newdocument(), opendocument(), closedocument() contentschanged(), itemadded(), itemdeleted() Full documentation of all functions and classes

Python Add-In Wizard Add-ins are built using the Python Add-in wizard The wizard generates fully stubbed out add-in projects including the config.xml, folders, and the Python script Download the Python Wizard from arcgis.com Extract the contents of the.zip Launch the addin_assistant.exe from the bin folder

Demo Customize ArcGIS Desktop with Python Add-ins Python Add-in toolbar with buttons to select and zoom to next or previous feature

Analyze Rasters with Map Algebra Using arcpy.sa (Spatial Analyst) to efficiently work with rasters

Spatial Analyst Module from arcpy.sa import * arcpy.checkoutextension("spatial") Includes all Spatial Analyst tools Helper classes that can be used to support complex parameter in scripting Integrates Map Algebra into Python Defines geographic analysis as algebraic expressions Supports mathematical, relational, other operators Output on the left-side sloperas = Slope("elevRas") * 100.0

Raster Class Reference to raster on disk, created in two ways: Returned output from arcpy.sa functions Cast using arcpy.raster() function Necessary for map algebra expressions using operators Temporary raster dataset that can be saved Has properties and method raster.minimum, raster.format, raster.extent raster.save() dem = arcpy.raster("elevation_meters.tif")) demft = dem * 3.28 # Rescale elevation to 0 1 scale rescale = (dem - dem.minimum)/(dem.maximum-dem.minimum) rescale.save("elevation_rescale_0_1.tif")

Demo Analyze Rasters with Map Algebra Use raster processing with Python to perform probabilitybased site suitability

Extend ArcGIS with Python Using Python to do stuff that's not in the ArcGIS box

Python packages ArcGIS includes several 3 rd -party Python packages and modules No separate install or config required, just import NumPy Matplotlib PyPI - official Python Package Index Vast collection of 3 rd -party packages with easy browse/search Windows binaries Statistical computation, powerful array object Data presentation and graphing Xlrd, Xlwt Excel spreadsheet read/write (new at 10.2) UC-Irvine maintains unofficial package installs for Windows "A simple approach for including 3 rd party Python libraries with your scripts"

NumPy NumPy is useful for mathematical & statistical computation Feature, table, and raster data can be converted to NumPy arrays 1 3 2 4 1 3 2 4 3 4 3 4 Raster Numpy Array To NumPy From ArcGIS arcpy.da.featureclasstonumpyarray arcpy.da.tabletonumpyarray arcpy.rastertonumpyarray To ArcGIS From NumPy arcpy.da.numpyarraytofeatureclass arcpy.da.numpyarraytotable arcpy.numpyarraytoraster

ArcGIS, Python, and Beyond Use Python as a communication language between ArcGIS and other APIs, packages, or applications "Extend ArcGIS with R" "Call a dll from a script tool using ctypes" Python Retrieves and organizes parameters/arguments from ArcGIS Converts data as needed (shapefiles, IMG, NetCDF, etc.) Constructs strings and uses operating system or class for execution After execution, applies symbology, coordinate system, and creates reports

Demo Extend ArcGIS with 3 rd -Party Python Libraries ArcGIS and NumPy roundtrip and using 3 rd -party packages

Resources resources.arcgis.com Python community arcpy.wordpress.com GIS Stack Exchange, Stack Overflow Python References Learning Python by Lutz The Python Standard Library by Example by Hellmann Python Scripting for ArcGIS by Esri press diveintopython.org python.org Working with the ArcPy DA Module Wed 1:00pm Smoketree A-E Creating Tools in a Python Toolbox Wed 2:30pm Mesquite GH Creating Geoprocessing Services Tue 1:00pm Smoketree A-E Python Scripting for Map Automation Wed 1:00 pm Mojave Learning Ctr Developing Python Add-ins Tue 4:00pm Primrose A Working with Raster Data Using Py Thu 8:30am Primrose A Integrating Open Source Stats Pkgs Tue 1:30pm Demo Theater 1, Oasis 1 Offering 184