Introduction to ArcPy. Topics What is ArcPy? Accessing geoprocessing tools using ArcPy Writing scripts using ArcPy.

Slides:



Advertisements
Similar presentations
WITHOUT LANGUAGE [ DEVELOPING GEO-PROCESSING MODELS USING ARCGIS MODELBUILDER 10 ] PROGRAMMING R. RYAN STEVENS / GIS RESEARCH ANALYST / THE POLIS CENTER.
Advertisements

1 of 22 Tough love Grandma. 2 of 22 Extraordinary People Iceman Blind painter Human calculator Human camera Human compass Spiderman Roofballers.
NSF DUE ; Module 4.3. NSF DUE ; GeoTEd Partners Module name and number.
Geoprocessing; Useful Tools You Should Know in ArcToolbox Unlock the hidden secrets of ArcToolbox to discover tools that make your work easier and analysis.
Environmental GIS Nicholas A. Procopio, Ph.D, GISP Some slides from Lyna Wiggins (Rutgers University)
Why python? Automate processes Batch programming Faster Open source Easy recognition of errors Good for data management What is python? Scripting programming.
Introducing ArcGIS Desktop
GIS Topics and Applications
Spatial Analyst Raster vs. Vector. Spatial Analyst Extension.
Geography 465 Working with ArcGIS Tools and Environment Settings.
Python & ModelBuilder. Overview Python/ModelBuilder Concepts – The Geoprocessor – Checking some environment variables – Providing feedback from your model/script.
GIS Customization I. Binaural recording + reconstructing performances Holophonics - Virtual Barber Shop John Q. Walker: Re-creating great performances.
ModelBuilder In ArcGIS 9.x By Tim Weigel GEOG 407/607 April 3 rd, 2006.
Spatial Analysis, Geoprocessing,
What Geoprocessing? Geoprocessing is the processing of geographic information. Commonly used to describe a process when geographic objects are manipulated.
ModelBuilder at ArcGIS 9.2 Lyna Wiggins Rutgers University May 2008.
arcpy.Describe and arcpy.List*
@ 2007 Austin Troy. Geoprocessing Introduction to GIS Geoprocessing is the processing of geographic information. – Creating new polygon features through.
@ 2007 Austin Troy. Geoprocessing Introduction to GIS Geoprocessing is the processing of geographic information. Perform spatial analysis and modeling.
Introduction to ArcGIS for Environmental Scientists Module 3 – GIS Analysis ArcGIS Toolbox.
Habitat Analysis in ArcGIS Use of Spatial Analysis to characterize used resources Thomas Bonnot
Advance Model Builder Features. Advance Features Using Lists (also Batching) Iteration Feedback Model Only Tools Inline Variable Substitution Preconditions.
Sharing imagery and raster data in ArcGIS
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.
1/29 Former leader of the “free” world … “I know what I believe. I will continue to articulate what I believe and what I believe.
Introduction to Spatial Analysis and Spatial Modeling
Copyright © 2002, 2003, 2004 ESRI. All rights reserved. What's New in ArcGIS 9 Introduction to Geoprocessing in ArcGIS 9 Jason Grootens ESRI-Minneapolis.
Network Analysis with Python
Overview Cursors arcpy.da module Geometrys Arrays SpatialReferences
Python: An Introduction
Introduction to ArcGIS. Goals Become familiar with ArcGIS ▫Locating and running the program ▫Introduction to the 3 ArcGIS interfaces ▫Experience with.
Using Describe. Topics How to use describe? Retrieving Descriptive Information about data.
ArcGIS Network Analyst: Automating Workflows with Geoprocessing
Python – Raster Analysis Kevin M. Johnston Nawajish Noman.
Exploring ArcToolbox Presented by: Isaac Johnson.
ArcGIS Pro: A Quick Tour of Python David Wynne.
Automating Processes with ArcPy to do work so I don’t have to Joe Guzi GIS Systems Analyst Stark County GIS Department 2015 Ohio GIS Conference September.
Building Site Selection Tool using Python
Esri UC2013. Technical Workshop. Technical Workshop 2013 Esri International User Conference July 8–12, 2013 | San Diego, California Building Map Books.
Finding Geospatial Data A closer look at several useful sources of free geospatial data René Duplain Data Analyst,
Introduction of Geoprocessing Lecture 9. Geoprocessing  Geoprocessing is any GIS operation used to manipulate data. A typical geoprocessing operation.
Desktop Mapping: Building Map Books Jeff Barrette Michael Grossman.
Geoprocessing Geoprocessing is a fancy name for Spatial Operations So what is Geoprocessing? Processing or manipulating of geographic/spatial data to.
Python: Building Geoprocessing Tools David Wynne, Ghislain Prince.
Intro. To GIS Pre-Lab Spatial Analysis April 1 st, 2013.
William Perry U.S. Geological Survey Western Ecological Research Center Geography 375 Final Project May 22, 2013.
Lecture 10: Geoprocessing with Python (II) Dr. Taysir Hassan Abdel Hamid Associate Professor, Information Systems Dept., Faculty of Computers and Information.
Introduction to GIS Programming Final Project Submitted by Todd Lenkin Geography 375 Spring of 2011 American River College.
Lecture 9: Geoprocessing with Python
Desktop Mapping: Building Map Books
GIS Institute Center for Geographic Analysis
Geography 385 Introduction to ArcGIS Web Application Design
PYTHON: AN INTRODUCTION
Environmental GIS Nicholas A. Procopio, Ph.D, GISP
Final Project: Read from a csv file and write to a database table
Lecture 9 Using Python for Geoprocessing
This lecture Introduction to arcpy Debugging Using arcpy.
GIS Institute Center for Geographic Analysis
Building Map Books in ArcGIS
Automating Geodatabase Administration with Python
Network Analysis using Python
PYTHON: BUILDING GEOPROCESSING TOOLS
Building Map Books in ArcGIS
Network Analyst – Automating Workflows with Geoprocessing
GIS Institute Center for Geographic Analysis
Clip & Convert to ASCII Program Kelly Knapp Spring 2010
Desktop Mapping: Building Map Books
Presentation transcript:

Introduction to ArcPy

Topics What is ArcPy? Accessing geoprocessing tools using ArcPy Writing scripts using ArcPy

What is ArcPy? ArcPy was introduced with ArcGIS10 It’s Python site package With ArcPy, you’ve access to the – Geoprocessing tools – Extensions – Functions & classes

Access to Geoprocessing Tools ArcPy provides access to all geoprocessing tools - Based on license level Tools return an object Tools can also produce messages -- Object & messages can be manipulated from Python script

ArcPy Functions Functions perform a specific task as a part of larger program All geoprocessing tools are functions -- Union, Buffer, Clip etc. But not all functions are geoprocessing tools -- List datasets, describe dataset, create cursor

ArcPy Classes Classes provide a framework for creating object - referred to as an instance Examples of classes - SpatialReference, Extent etc. Classes have methods & properties -- Spatialreference.name -Spatialreference.type

ArcPy Modules Modules are Python libraries containing functions and classes 3 modules --Mapping modules: arcpy.mapping - Spatial Analyst module: arcpy.sa - Geostatistical module: arcpy.ga Example: -- arcpy.sa.Slope is same as using the Slope tool from Spatial Analyst toolbox

How to use ArcPy You have to import the ArcPy package before using it Simply type “import arcpy” in Python Window in ArcGIS

How to use a tool? Two ways to call a tool Example: arcpy.Buffer_analysis() Example: arcpy.analysis.Buffer()

Tool Syntax Each tool needs specific parameters to run correctly Buffer_analysis (in_features, out_feature_class, buffer_distance_or_field, {line_side}, {line_end_type}, {dissolve_option}, {dissolve_field}) Buffer tool needs 3 required parameters: 1.Input features 2.Out feature class 3.Buffer distance There are a number of optional parameters too!!

Environment Setting Set your workspace pathname for reading input & writing output file: arcpy.env.workspace = “C:\\GIS222” arcpy.env.workspace = “C:\\Test.gdb” # Read and write files from GIS222 folder # Read and write files from Test.gdb arcpy.env.overwriteOutput = 1 # Will overwrite the output file

Let’s try it! a.Run buffer in Python Window b.Write a script to run buffer in PythinWin

Using List Functions

Topics How to get a list of data layers? Iterate through the list

Getting a list Getting the list of available data is often the first step of many tasks ArcPy provides functions for getting − Lists of fields − Lists of datasets − List of feature classes − List of Files − List of Tables − And more

Important Note YOU MUST set the workspace before calling any list function import arcpy arcpy.env.workspace = "C:\\temp" fcs = arcpy.ListFeatureClasses()

Iterating through the list Python ‘for’ loop can be used to loop through your list import arcpy arcpy.env.workspace = “C:\\Auburn.gdb” for fc in arcpy.ListFeatureClasses(): print fc

Other List Methods ListDatasets –Lists all datasets from a workspace –Feature, TIN, Raster, or CAD ListRasters –Lists all rasters in a workspace –PNG, TIFF, JPG, BMP, GIF, IMG, GRID, others ListFields –Lists the fields in a feature class, shapefile, or table in a specified dataset ListTables –Lists all tables in the workspace ListWorkspaces –Lists workspaces within a workspace –Folders, file geodatabases, personal geodatabases

Let’s try it!