Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Programming with GIS?! Yes You Can!

Programming with GIS?! Yes You Can!

Stephanie Long, GISP

More Decks by Texas Natural Resources Information System

Other Decks in Technology

Transcript

  1. Programming with GIS?! Yes You Can! Stephanie Long, GISP [email protected]

    https://www.linkedin.com/in/stephaniereneelong/
  2. 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
  3. Like Riding a Bike: Fundamentals are key § Grasp the

    fundamentals for long-term benefits • Variables • Control Structures • Data Types • Syntax • Tools
  4. 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:
  5. Like Riding a Bike: Fundamentals are key • Variables •

    Control Structures • Data Types • Syntax • Tools
  6. 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
  7. 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)
  8. Like Riding a Bike: Fundamentals are key • Variables •

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

    Hand) or Not to Scratch (Use the Samples)
  10. To Scratch or Not to Scratch: Use the Samples >>>

    aprx =arcpy.mp.ArcGISProject("CURRENT") >>> lyt = aprx.listLayouts(“Yose*")[0]
  11. 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
  12. To Scratch or Not to Scratch: Code by Hand §

    Start with pseudocode § Interpret to code § Test your work
  13. 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?
  14. 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))
  15. 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
  16. Yes You Can! This is How… §Who You Calling Crazy?

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

    §Documentation §Online Resources
  18. Yes You Can! This is How… §Time is a Virtue

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

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

    Map Elements Symbology Layers in the Map
  21. Time is a Virtue: Automate What You Can § Internal

    and External Map Elements Map Extent
  22. Time is a Virtue: Automate What You Can § Simple

    GIS Workflow Tasks Proximity Analysis
  23. 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
  24. Time is a Virtue: Automate What You Can § Data

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

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

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

    GIS Analysis Routing Analysis
  28. Yes You Can! This is How… §Knowledge is Power •

    Use it or Lose it • Take a Class
  29. 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
  30. Programming with GIS?! Yes You Can! Stephanie Long, GISP [email protected]

    https://www.linkedin.com/in/stephaniereneelong/