In this video, Jennifer Harrison discusses the value of the for loop in python, which can be used to repeat bits of code. Learn how to use the for loop with list functions in ArcPy to loop through a set of feature classes, data frames, layers, and even fi
- [Instructor] A list loop loops through a list of values,…executing a section of code once for each value in the list.…This type of loop is especially powerful…when working with ArcGIS and GIS data.…Because ArcPy has a set of list functions,…they return lists of things…so the for loop can easily execute code on that list.…The ArcPy list functions can list FeatureClasses, Layers,…BrokenDataSources, DataFrames,…and even Files in a workspace.…
I'm in IDLE…and I have a script that I've already started here.…I'll use this to demonstrate how to use a list…to work through the return elements…from a list function in ArcPy.…I'll write a script…that lists out all of the layers in a map document.…First, I'll need to import the ArcPy module.…Next, I'll instantiate the map document object.…I'll touch the map document…and make an open connection to it.…
I'll use an mxd variable.…That's just a name I chose, mxd,…to hold the map document object.…You create the map document object…by using the MapDocument method…from the mapping object.…
- Writing and running Python scripts in IDLE
- Making scripts flexible with variables
- Commenting scripts
- Manipulating string data
- Object-oriented programming in Python
- Creating loops
- Reading and writing text files
- Capturing input at runtime
- Documenting your scripts
Skill Level Beginner
1. Python for ArcGIS Basics
2. Strings, Numbers, and Variables
Work with numeric values5m 22s
3. Syntax Rules
4. Manipulating Strings
5. Object-Oriented Programming
6. Using Loops
7. Generate Log Files
8. Input at Run Time
9. Help Documents
Documenting a script1m 59s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.