Lecture 22: Using ArcToolbox Tools in Python Jeffery S. Horsburgh CEE 5190/6190 Geographic Information Systems for Civil Engineers Spring 2016
Objectives Create a Python script that automates a complex geoprocessing task not easily accomplished with core GIS software functionality Introduction to the Python programming language Write and execute computer code to automate repetitive tasks Become proficient in the use of GIS tools to conduct spatial analyses
Python Programming Challenge Using the DEM and outlet shapefile provided, write a Python script that extracts streams and delineates the watershed above the outlet Fill pits Calculate flow direction raster Calculate flow accumulation raster Extract stream network raster (Threshold = 500) Snap outlet point to outlet raster Delineate watershed raster Convert watershed raster to polygon Run the tools from ArcToolbox and copy the code Generate one .py script file and save Load and execute in ArcMap Python window
Result Watershed
Hints If you run the tools and create the datasets, you will have to delete them before you try to run your script or you will get errors Check to make sure the geoprocessing Environment setting “Processing Extent” and “Snap Raster” are set to process the extent of the NED grid