From the course: Learning ArcGIS Python Scripting
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Conditional statements - ArcGIS Pro Tutorial
From the course: Learning ArcGIS Python Scripting
Conditional statements
- [Instructor] Sometimes you need your Python code to stop and make a decision before moving on. For example, suppose you write a Python script that's going to run the erase geoprocessing tool which requires at least a standard ArcGIS Pro license. How do you make sure the script doesn't try to run the erase tool unless the user has a license to run it? Well, you could use a conditional statement, sometimes called an if-then statement. If statements let you control the flow of your script, you can use them to check that a feature class' properties match what you expect, check that projects exist before you try to use them, or check that methods return values that you can use in your script. For example, suppose your script "Ask the user for a road name," then it checks to see if a road name was entered. Did you get a value from them? Yes, okay, good. Try to select the road. No, ask them again. "Hey, you didn't give me the name of a road." So the syntax for an if statement looks like…
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)
-
-
-
-