# Programming with GIS?! Yes You Can!

Stephanie Long, GISP

October 24, 2019

## Transcript

3. ### Yes You Can! This is How… §Like Riding a Bike

§To Scratch or Not to Scratch §Who You Calling Crazy? §Time is a Virtue §Knowledge is Power
4. ### Yes You Can! This is How… §Like Riding a Bike

• Fundamentals are key
5. ### Like Riding a Bike: Fundamentals are key § Grasp the

fundamentals for long-term benefits • Variables • Control Structures • Data Types • Syntax • Tools
6. ### Like Riding a Bike: Fundamentals are key • Variables •

Control Structures • Data Types • Syntax • Tools § Feature Class Name § Buffer Distance § Area of Buffer String Integer str(2351.45) + str(451.66) = 2351.45451.66 int(2351.45) + int(451.66) = 2803.11 Calculate Area:
7. ### Like Riding a Bike: Fundamentals are key • Variables •

Control Structures • Data Types • Syntax • Tools
8. ### Like Riding a Bike: Fundamentals are key • Variables •

Control Structures • Data Types • Syntax • Tools FC1 = “bus” FC2 = “route” FC3 = “pattern” FC4 = “trips” FC5 = “stops” featureclasses = arcpy.ListFeatureClasses() WRONG RIGHT
9. ### Like Riding a Bike: Fundamentals are key • Variables •

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)
10. ### Like Riding a Bike: Fundamentals are key • Variables •

Control Structures • Data Types • Syntax • Tools
11. ### Yes You Can! This is How… §To Scratch (Code by

Hand) or Not to Scratch (Use the Samples)

14. ### To Scratch or Not to Scratch: Use the Samples >>>

aprx =arcpy.mp.ArcGISProject("CURRENT") >>> lyt = aprx.listLayouts(“Yose*")[0]

16. ### To Scratch or Not to Scratch: Use the Samples §

Mobile GIS https://drive.google.com/fil e/d/1beZZKLNswqVhX_P vwlJGreQVA2vr9tW7/vie w?usp=sharing_eil&ts=5c a56b01 3:50

18. ### To Scratch or Not to Scratch: Code by Hand Write

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?
19. ### To Scratch or Not to Scratch: Code by Hand Missing

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))
20. ### To Scratch or Not to Scratch: Code by Hand A:

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
21. ### Yes You Can! This is How… §Who You Calling Crazy?

• Ask for Help • Talk it Out • Take Breaks • Celebrate Success
22. ### Who You Calling Crazy? Ask for Help §In the Code

§Documentation §Online Resources

25. ### Who You Calling Crazy? Celebrate §Celebrate Success • Do a

little dance!
26. ### Yes You Can! This is How… §Time is a Virtue

• Automate What You Can • Schedule What You Can
27. ### Time is a Virtue: Automate What You Can § Internal

Map Elements Update Labels Discover Properties
28. ### Time is a Virtue: Automate What You Can § Internal

Map Elements Symbology Layers in the Map
29. ### Time is a Virtue: Automate What You Can § External

Map Elements Text Element
30. ### Time is a Virtue: Automate What You Can § Internal

and External Map Elements Map Extent

32. ### Time is a Virtue: Automate What You Can § Data

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
33. ### Time is a Virtue: Automate What You Can § Data

Management Connection Properties Query Connection Properties Fix
34. ### Time is a Virtue: Automate What You Can § Map

Deliverables Single PDF Map Series Pages
35. ### Time is a Virtue: Automate What You Can § Web

GIS Visualization Web Scene
36. ### Time is a Virtue: Automate What You Can § Web

GIS Analysis Viewshed On Click
37. ### Time is a Virtue: Automate What You Can § Web

GIS Analysis Routing Analysis

39. ### Yes You Can! This is How… §Knowledge is Power •

Use it or Lose it • Take a Class

41. ### Knowledge is Power: Take a Class § Programming for GIS

• 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

u.be