Slide 1

Slide 1 text

Programming with GIS?! Yes You Can! Stephanie Long, GISP [email protected] https://www.linkedin.com/in/stephaniereneelong/

Slide 2

Slide 2 text

Source: http://carlcheo.com/startcoding

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Yes You Can! This is How… §Like Riding a Bike • Fundamentals are key

Slide 5

Slide 5 text

Like Riding a Bike: Fundamentals are key § Grasp the fundamentals for long-term benefits • Variables • Control Structures • Data Types • Syntax • Tools

Slide 6

Slide 6 text

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:

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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)

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

Yes You Can! This is How… §To Scratch (Code by Hand) or Not to Scratch (Use the Samples)

Slide 12

Slide 12 text

To Scratch or Not to Scratch: Use the Samples

Slide 13

Slide 13 text

To Scratch or Not to Scratch: Use the Samples

Slide 14

Slide 14 text

To Scratch or Not to Scratch: Use the Samples >>> aprx =arcpy.mp.ArcGISProject("CURRENT") >>> lyt = aprx.listLayouts(“Yose*")[0]

Slide 15

Slide 15 text

To Scratch or Not to Scratch: Use the Samples

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

To Scratch or Not to Scratch: Code by Hand § Start with pseudocode § Interpret to code § Test your work

Slide 18

Slide 18 text

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?

Slide 19

Slide 19 text

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))

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Yes You Can! This is How… §Who You Calling Crazy? • Ask for Help • Talk it Out • Take Breaks • Celebrate Success

Slide 22

Slide 22 text

Who You Calling Crazy? Ask for Help §In the Code §Documentation §Online Resources

Slide 23

Slide 23 text

Who You Calling Crazy? Talk It Out §Peers

Slide 24

Slide 24 text

Who You Calling Crazy? Take Breaks §Walk Away for Sanity

Slide 25

Slide 25 text

Who You Calling Crazy? Celebrate §Celebrate Success • Do a little dance!

Slide 26

Slide 26 text

Yes You Can! This is How… §Time is a Virtue • Automate What You Can • Schedule What You Can

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Time is a Virtue: Automate What You Can § External Map Elements Text Element

Slide 30

Slide 30 text

Time is a Virtue: Automate What You Can § Internal and External Map Elements Map Extent

Slide 31

Slide 31 text

Time is a Virtue: Automate What You Can § Simple GIS Workflow Tasks Proximity Analysis

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

Time is a Virtue: Automate What You Can § Data Management Connection Properties Query Connection Properties Fix

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

Time is a Virtue: Automate What You Can § Web GIS Analysis Routing Analysis

Slide 38

Slide 38 text

Time is a Virtue: Schedule What You Can § Schedule Tasks

Slide 39

Slide 39 text

Yes You Can! This is How… §Knowledge is Power • Use it or Lose it • Take a Class

Slide 40

Slide 40 text

Knowledge is Power: Use it or Lose it

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

Thanks!! Questions? Most Popular Programming Languages 1965 - 2019 https://www.youtube.com/watch?v=Og847HVwRSI&feature=yout u.be

Slide 43

Slide 43 text

Programming with GIS?! Yes You Can! Stephanie Long, GISP [email protected] https://www.linkedin.com/in/stephaniereneelong/