learning python: automating the gis update of computer aided dispatch (911) software in route...

25
LEARNING PYTHON Automating the GIS Data Update of Computer Aided Dispatch (911) Software in Routt County Emy Keeling GIS Analyst

Upload: geco-in-the-rockies

Post on 19-Jun-2015

255 views

Category:

Technology


3 download

DESCRIPTION

Emy Keeling

TRANSCRIPT

Page 1: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

LEARNING PYTHON

Automating the GIS Data Update of Computer Aided Dispatch (911) Software in Routt County Emy Keeling GIS Analyst

Page 2: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Biographical Information

5 years as a GIS Analyst for Routt County, Steamboat Springs, Colorado

Focus on addressing and GIS for 911/Fire/Law

2008 graduate from Metropolitan State University of Denver in Land Use/GIS

Background in emergency services

Love all things outdoors!

Page 3: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Background

Spillman Technologies was selected in 2011 to provide a CAD/RMS/Jail software solution.

Go-live was March, 2012

Spillman Sentryx 6.1 requires ArcGIS Engine 10.0 or 9.3. Routt County has ArcGIS Server and ArcGIS Desktop installed, as well

Locations are validated against GIS database.

Page 4: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Spillman Data Flow

Page 5: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Original Update Process

•A new geodatabase has to be created to update data (not a live connection)

•Model builder and Spillman Toolbar used to complete process

•Took as many as 4 hours

•Human error prone

•As a result we completed geobase builds once a month

Page 6: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Processes Include

Appending 2 agencies’ data

Creating 10.0 fgdb

Copying data to 10.0 fgdb

Copying fgdb to another server

Populate point fields from polygon layers*

Create Intersections*

Create Alternate Names Tables*

Rebuild geolocators

*Spillman Toolbar Functions

Page 7: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Script It!

Months after go-live I thought there has to be a better way

Python had always been a buzzword but I had never used it

After some preliminary investigation I determined I could learn Python and script most of the update process

Page 8: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Where did I start?

Colorado Mountain College – Ed2Go Online

Affordable, 6-week courses

Introduction to Programming

Variables, conditions, loops

Introduction to Python 3 Programming

Learn unique Python data structures

Ed2Go.com

I highly recommend these courses if you looking to learn more about a field or need a good base. They are less than $150 and easy to keep up with.

Page 9: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Where did I start?

A Python Primer for ArcGIS (book) Provides good base

understanding for how Python and ArcGIS work together

Easy to read with exercises and data to practice

I found it lacking in a few subjects

I am a hands on learner. I got to the point of trying my own scripts on my own data and using the book as reference.

Page 10: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Starting the Automation

ArcGIS comes with IDLE, a Python GUI, with syntax highlighting, autocompletion, smart indent, and more. I used this for most of my scripting work

I started with copied data on my client

I practiced with simple processes such as buffering

arcpy.Buffer_analysis(in_features, out_feature_class, buffer_distance_or_field, {line_side}, {line_end_type}, {dissolve_option}, {dissolve_field})

It worked! It was fun to see this work.

Example of using Python

Page 11: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Creating the scripts

I created an outline of all of the processes that needed to be completed. To start, this can be very simple

As you work on each task you can further detail the needs of each task, usually right in your script

1. Append agencies’ data

2. Create 10.0 fgdb

3. Copy data to new fgdb

4. Calculate zone fields

5. Calculate critical fields such as JoinID and CompleteAddress

6. Create Alt Names Tables

7. Create Intersections

Page 12: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Creating the scripts (cont.) I found that most of my desired tasks could be simply completed with ArcPy. The syntaxes are easily found in the help subject for processes. Script example

Page 13: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Outside Resources

I was able to figure out most of my outlined tasks on my own. Simple web searches usually helped with problems.

Creating the alternate names table and the intersections were a bit above my skill level.

We decided to ask Spillman and ESRI for help with these tasks.

Page 14: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Outside Resources (cont.)

Spillman agreed to provide the C# code behind the Spillman Toolbar.

We contracted with an ESRI developer who used this code to write a script to create the intersections.

Chris Klaube with Monmouth County, NJ created a python script for the Spillman alternate names tables. He agreed to share this with other Spillman users. I was able to adapt this to our needs.

Page 15: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Introduction to Geoprocessing Scripts Using Python

ESRI class, November 2013

This class really helped reinforce ArcPy and I grasped new concepts.

I was able to refine my Python scripts and do some new things after this class

I would recommend this to anyone wanting to do more with Python and ArcGIS.

Page 16: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Wrapping Up the Project

Started classes in December 2012

Completed most of the scripts by August 2013

Tested code and documented processes

The scripts now run on a weekly basis, in the early morning hours.

A geobase update now takes about 15 man-minutes as compared to 4 man-hours prior.

Human-error factor greatly reduced!

Page 17: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Automation

Created a “batch file” used by Windows Scheduler to run scripts

A user not familiar with scripts/Python can just click batch file to run scripts. Handy if the usual person is not available.

Can build logging files into your scripts to QA/QC your automatic scripts.

Page 18: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Tips and Tricks

Scripting

You can export model builder projects to Python code but beware! This is a great way to get started as a learning aid but do not depend on it. For instance, models with field mappings will not convert neatly. http://blogs.esri.com/esri/arcgis/2011/06/24/exportmodeltopy/

Page 19: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Tips and Tricks Scripting

Field mapping: only map fields with different names

Page 20: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Tips and Tricks

Calling other modules Keep modules in the same directory

I have found it easier to manage my different tasks, like creating alternate names tables and appending data, by saving the unique scripts in their own files. You can then call them in your “master” file as module.

#Call the AppendAll module

import AppendAll

print AppendAll

Page 21: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Tips and Tricks

Automation

Create batch file and scheduled task with a administrative Windows account so others can manage the task and if your profile is removed the tasks will still run

Page 22: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Tips and Tricks

Automation

Add the C:\Python27\ArcGIS10.2 path to the Environment Variables “Path” under System variables. Command line error when this is not done: python not found http://pythongisandstuff.wordpress.com/2013/07/10/locating-python-adding-to-path-and-accessing-arcpy/

Page 23: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Tips and Tricks Automation

If scripts use data in SDE make sure the connection name in ArcCatalog matches the variables path names

Page 24: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Wrapping Up

Learning Python is a good next step after one has a solid understanding of ArcGIS and ModelBuilder.

Python is fun to use and has made my job easier.

We have reduced errors and time by implementing Python scripting.

I am starting to use Python in other projects.

Page 25: Learning Python:  Automating the GIS update of Computer Aided Dispatch (911) Software in Route County

Questions & Contact Information

Emy Keeling, Routt County GIS

[email protected]