350 likes | 368 Views
Automating Processes with ArcPy to do work so I don’t have to. Joe Guzi GIS Systems Analyst Stark County GIS Department. 2015 Ohio GIS Conference. September 21 - 23, 2015 | Hyatt Regency Columbus| Columbus, Ohio. Why Automate processes?. Not only to do work so I don’t have to
E N D
Automating Processes with ArcPy to do work so I don’t have to Joe Guzi GIS Systems Analyst Stark County GIS Department 2015 Ohio GIS Conference September 21 - 23, 2015 | Hyatt Regency Columbus| Columbus, Ohio
Why Automate processes? • Not only to do work so I don’t have to • But mainly to Free me up to do more work
Why do more work? • Because work leads to Taking Over the world!
Automaton Strategies • Walk through Process • Test • Be prepared • Task Scheduler and BAT Files • Maintenance • Excel Sheet To Maintain Schedule • Code Examples
Automaton Strategies:Task Scheduler and BAT Files • Bat Files • Just Text Files saved with a bat extension • Written using DOS Commands • Syntax
Automaton Strategies:Task Scheduler and BAT Files • Task Scheduler Parameters: • Trigger – Declare when the task will run and how frequently • Actions – Declare what the Task will do • Conditions – Declare computer setting for power or idle • Settings – Determine how the task can be treated • Allow the task to run on demand • Stop the task if it takes forever
Python Tips and Tricks • Section your code • Comment Comment Comment • Use Print Command • Error Block • Email Notification • Create Logs • Time • Use Resources
Python Tips and Tricks:Section your code • Description • Import Section • Variables • Processes • Output • Error Reporting
Python Tips and Tricks: Comment Comment Comment • Comment everything • If you change your code comment the change • You never know when you will have to come back to your code and commenting will be the best way to remember why you did something • Also commenting is good back up in case something happened to the author (God forbid)
Python Tips and Tricks: Time • Time Libraries: • Time • Datetime • Time.gmtime • datetime.datetime.utcnow() • datetime.timedelta(minutes = 15) • str(DayAgo)[0:19] • "( LAST_EDITED_DATE >= '" + DayAgoFormat + "' )"
Python Tips and Tricks: Use Resources • Python Window in ArcGIS desktop • ArcGIS Resources Python Section • Geoprocessing Tool References • GitHub • Friends • Python Documentation Site
Questions? • Joe Guzi • jsguzi@starkcountyohio.gov • 330-451-7188