Share
Embed
Programming with GIS?! Yes You Can!
Stephanie Long, GISP
Texas Natural Resources Information System
October 24, 2019
Transcript
43 slides
-
Programming with GIS?! Yes You Can! Stephanie Long, GISP [email protected]
https://www.linkedin.com/in/stephaniereneelong/ -
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 -
Yes You Can! This is How… §Like Riding a Bike
• Fundamentals are key -
Like Riding a Bike: Fundamentals are key § Grasp the
fundamentals for long-term benefits • Variables • Control Structures • Data Types • Syntax • Tools -
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: -
Like Riding a Bike: Fundamentals are key • Variables •
Control Structures • Data Types • Syntax • Tools -
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 -
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) -
Like Riding a Bike: Fundamentals are key • Variables •
Control Structures • Data Types • Syntax • Tools -
Yes You Can! This is How… §To Scratch (Code by
Hand) or Not to Scratch (Use the Samples) -
To Scratch or Not to Scratch: Use the Samples >>>
aprx =arcpy.mp.ArcGISProject("CURRENT") >>> lyt = aprx.listLayouts(“Yose*")[0] -
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 -
To Scratch or Not to Scratch: Code by Hand §
Start with pseudocode § Interpret to code § Test your work -
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? -
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)) -
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 -
Yes You Can! This is How… §Who You Calling Crazy?
• Ask for Help • Talk it Out • Take Breaks • Celebrate Success -
Who You Calling Crazy? Ask for Help §In the Code
§Documentation §Online Resources -
Yes You Can! This is How… §Time is a Virtue
• Automate What You Can • Schedule What You Can -
Time is a Virtue: Automate What You Can § Internal
Map Elements Update Labels Discover Properties -
Time is a Virtue: Automate What You Can § Internal
Map Elements Symbology Layers in the Map -
Time is a Virtue: Automate What You Can § External
Map Elements Text Element -
Time is a Virtue: Automate What You Can § Internal
and External Map Elements Map Extent -
Time is a Virtue: Automate What You Can § Simple
GIS Workflow Tasks Proximity Analysis -
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 -
Time is a Virtue: Automate What You Can § Data
Management Connection Properties Query Connection Properties Fix -
Time is a Virtue: Automate What You Can § Map
Deliverables Single PDF Map Series Pages -
Time is a Virtue: Automate What You Can § Web
GIS Visualization Web Scene -
Time is a Virtue: Automate What You Can § Web
GIS Analysis Viewshed On Click -
Time is a Virtue: Automate What You Can § Web
GIS Analysis Routing Analysis -
Yes You Can! This is How… §Knowledge is Power •
Use it or Lose it • Take a Class -
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 -
Programming with GIS?! Yes You Can! Stephanie Long, GISP [email protected]
https://www.linkedin.com/in/stephaniereneelong/