![Page 1: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/1.jpg)
Automating Processes with ArcPy Automating Processes with ArcPy to do work so I don’t have toto do work so I don’t have to
Joe Guzi
GIS Systems Analyst
Stark County GIS Department
2015 Ohio GIS ConferenceSeptember 21 - 23, 2015 | Hyatt Regency Columbus| Columbus, Ohio
![Page 2: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/2.jpg)
Why Automate processes?
•Not only to do work so I don’t have to•But mainly to Free me up to do more work
![Page 3: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/3.jpg)
Why do more work?
•Because work leads to Taking Over the world!
![Page 4: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/4.jpg)
![Page 5: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/5.jpg)
Automaton Strategies
•Walk through Process•Test•Be prepared•Task Scheduler and BAT Files•Maintenance•Excel Sheet To Maintain Schedule•Code Examples
![Page 6: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/6.jpg)
Automaton Strategies:Walk through process
![Page 7: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/7.jpg)
Automaton Strategies:Walk through process
![Page 8: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/8.jpg)
Automaton Strategies:Walk through process
![Page 9: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/9.jpg)
Automaton Strategies:Test
![Page 10: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/10.jpg)
Automaton Strategies:Test
![Page 11: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/11.jpg)
Automaton Strategies:Test Again
![Page 12: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/12.jpg)
Automaton Strategies:Task Scheduler and BAT Files
![Page 13: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/13.jpg)
Automaton Strategies:Task Scheduler and BAT Files•Bat Files
▫Just Text Files saved with a bat extension▫Written using DOS Commands ▫Syntax
![Page 14: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/14.jpg)
Automaton Strategies:Task Scheduler and BAT Files
![Page 15: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/15.jpg)
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
![Page 16: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/16.jpg)
Excel Sheet to Maintain Schedule
![Page 17: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/17.jpg)
Code Examples
![Page 18: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/18.jpg)
Code Examples:Layer Update Automation
![Page 19: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/19.jpg)
Code Examples:Feature Update Email Notification
![Page 20: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/20.jpg)
Code Examples:Automation of Tax Map Updates
![Page 21: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/21.jpg)
Code Examples:Cache Error Detection
![Page 22: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/22.jpg)
Python Tips and Tricks
•Section your code•Comment Comment Comment•Use Print Command•Error Block•Email Notification•Create Logs•Time•Use Resources
![Page 23: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/23.jpg)
Python Tips and Tricks:Section your code
•Description•Import Section
•Variables•Processes•Output•Error Reporting
![Page 24: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/24.jpg)
![Page 25: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/25.jpg)
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)
![Page 26: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/26.jpg)
Python Tips and Tricks: Comment Comment Comment
![Page 27: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/27.jpg)
Python Tips and Tricks: Use the print Command
![Page 28: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/28.jpg)
Python Tips and Tricks: Error blocks
![Page 29: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/29.jpg)
Python Tips and Tricks: Email Notification
![Page 30: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/30.jpg)
Python Tips and Tricks: Create logs
![Page 31: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/31.jpg)
Python Tips and Tricks: Time• Time Libraries:
▫ Time▫ Datetime
• Time.gmtime• datetime.datetime.utcnow
()• datetime.timedelta(minute
s = 15)• str(DayAgo)[0:19]• "( LAST_EDITED_DATE
>= '" + DayAgoFormat + "' )"
![Page 32: 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](https://reader035.vdocuments.site/reader035/viewer/2022062408/56649efc5503460f94c0fbb8/html5/thumbnails/32.jpg)
Python Tips and Tricks: Use Resources•Python Window in ArcGIS desktop•ArcGIS Resources Python Section•Geoprocessing Tool References•GitHub•Friends•Python Documentation Site