Control Structures • Data Types • Syntax • Tools Missing Colon : for ds in datasets: for fc in arcpy.ListFeatureClasses(feature_dataset=ds) path = os.path.join(arcpy.env.workspace, ds, fc) print(path)
Pseudocode which answers: § What is going to be performed? • Calculate the area of Very High and High risk features of all polygon feature classes in a hazard geodatabase. • What needs to be imported? § What ingredients do we need? • Explore the geodatabase, feature classes, fields, domains, etc. • What variables does the computer need defined? § What are the instructions for mixing those ingredients? • How will you find Very High and High? • How will you find polygon feature classes? • What functions will be performed using what modules? § How do we check to see that things are going well? • What statements will prove useful?
Control Structures: Indent Lines for domain in domains: if domain.domainType == ‘CodedValue’: coded_values = domain.codedValues for val, desc in coded_values.items(): if desc in (“High”, “Very High”): dl = (domain.name) print (“Found domain : “ + dl) print (‘(0) : 910’.format(val,desc)) Interpret to code It MOST LIKELY won’t run the first time…THAT’S OK! for domain in domains: if domain.domainType == ‘CodedValue’: coded_values = domain.codedValues for val, desc in coded_values.items(): if desc in (“High”, “Very High”): dl = (domain.name) print (“Found domain : “ + dl) print (‘(0) : 910’.format(val,desc))
find any domain(s) with the words "high" or "very high" in the description of a coded value C: loops through all feature classes in a workspace to find which ones contain a field using that domain(s). B: print the domain, the code and description D: determine if the feature class is polygon features and if so: E: select the features where the field is equal to the domain value and print the number of selected features and calculate the area of all of the selected features and print that sum the sum is added to a list F: that list is summed at the end A B C D E F Test Your Work
Management Use Walk on a Geodatabase List the Domains in a Geodatabase Download the Sample Data Here: https://drive.google.com/file/d/1vnmlxInX46ItDBv90yfsKbgDQ_Core90/view?usp=sharing
• Spring every year § Scripting for GIS • Fall every year § More info: • http://www.austincc.edu/gis § Continuing Education • Multiple short courses offered on a wide range of topics • http://continue.austincc.edu/gis