From the course: Learning ArcGIS Python Scripting
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Nested loops - ArcGIS Pro Tutorial
From the course: Learning ArcGIS Python Scripting
Nested loops
- Let me show you how Python loops can be nested, which means putting a loop inside another loop. The indention is what controls the loop structure. Everything that's inside the loop must be indented with the same number of spaces. I'm going to write a script to make a list of all the label classes used in the layers of a map. This will involve some nested loops because I'm going to have to loop through the layers and then loop through the label classes for each layer. Let's review the steps to get to layer objects in a project. First, we'll need to get to the project. We do that with arcpy.mp.ArgGISProject, and then we need to get to the map. We do that with aprx.listMaps where aprx is the object variable, holding the open connection to the project. So aprx.listMaps and then we need to get the layers. We do that with the list layers method of the map object. And then finally, we need to get to the label classes. And you do that with the list label classes method of the layer object…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Working with lists6m 18s
-
(Locked)
List methods and functions8m 48s
-
(Locked)
Use loops to work with lists7m 50s
-
(Locked)
Write a script using list methods and a for-loop3m 39s
-
(Locked)
Nested loops8m 16s
-
(Locked)
Conditional statements7m 35s
-
(Locked)
Write a script using ArcGIS API10m 31s
-
(Locked)
Getting to the properties of GIS data with Describe3m 28s
-
(Locked)
Challenge: Properties of layers37s
-
(Locked)
Solution: Properties of layers3m 4s
-
(Locked)
-
-
-
-