Automation in ArcGIS using Arcpy

3,051 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,051
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
151
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Automation in ArcGIS using Arcpy

  1. 1. Automation inArcGIS usingArcpyRui RuaGeodata As
  2. 2. Presentation topics In this presentation I will talk about: – How automation can be used to execute some geodatabase tasks; – Python, ArcPy and its interaction with the geodatabase; – Use cases.
  3. 3. What can we use automation for with geodatabases? In a general way, we use automation with geodatabases to: – Explore geodatabase content; – Simplify the execution of frequent administration tasks: • Create indexes; • Set privileges. – Implement data workflows: • conversion; • distribution;
  4. 4. How can automation be done? Automation of these tasks can be done using the Python programming language. Why Python? – Simple and easy to learn; – Widely adopted and well documented; – Powerfull, with many available built-in and external modules; – Fast to implement.
  5. 5. How can python be used with Arcgis and the geodatabase? The use of Python with Arcgis and the geodatabase is simplified by the fact that: – Python is available by default with all ArcGis 9.X and 10.X Desktop installations; – ‘Coding’ can be done using ArcGis Desktop ‘Python Window’ or one of the many development environments available: • Wingware • pyDev • or even Notepad++
  6. 6. How can python be used with Arcgis and the geodatabase? – All the interaction with the geodatabase, feature classes, rasters or even the mxds is done through a single python package, named ArcPy – and not with a vast library, making it easy to access the right function or geoprocessing tool. – If needed, in addition, specific modules provide a direct interaction with the databases themselves: • cx_oracle for Oracle; • pymssql for SQL Server.
  7. 7. What is ArcPy? This means that most of the time while scripting we will be using ArcPy, which is: – ESRIs python package for ArcGis 10 products - a set of modules, classes and functions; – ‘Upgraded’ from Arcgis version 9.X ‘arcgisscripting’. ArcPy is divided in a small number of modules, with names familiar to all ArcGis users: – Mapping (to interact with mxds); – Geostatistical analyst; – Spatial analyst.
  8. 8. What is arcpy main purpose then? ArcPy main purpose then is to: – provide easy programming access to all common data structures, geoprocessing tools and map documents (.mxd); – Simplify the execution of repetitive manual tasks by using scripts that are relatively fast to implement and that can be runned over and over.
  9. 9. Whats needed to use automation with the geodatabase? This means that to use automation with the geodatabase we need: – Good understanding of geodatabases; – Learn general python concepts and the language itself; – Become familiar with the ArcPy package. An easy way to start is to use both: – Geoprocessing tools help; – ArcPy page.
  10. 10. Use cases : To demonstrate how ArcPy interacts with the geodatabase, we’ll look into some examples where we use: – functions to explore the geodatabase; – geoprocessing tools to automate administrative tasks; – Both functions and geoprocessing tools to implement a ‘data distribution’ workflow.
  11. 11. Use case #1 - explore the geodatabase : In the first case we will see that ArcPy can be used to explore geodatabase objects and the data itself. It has its own functions to List: – Datasets; – Feature class or tables; – Fields; – or Rasters.
  12. 12. Use case #1 - explore the geodatabase : It also has some specific functions to: – ‘Describe’ the data, as the ones used to: • Get a feature class spatial reference; • or to Check if its versioned; – Read and Write data, allowing us to: • Get attribute values; • Update or insert features.
  13. 13. Use case #2 – administrative tasks: In this second example we will see how Arcpy can be used to run administrative tasks on datasets or feature classes. This can be done by using standard geoprocessing tools, as we know them in ArcToolbox: – Create or remove indexes; – Set privileges;
  14. 14. Use case #3 – automate workflow In this third example we will see how ArcPy can be used to make some operational workflows easyer to manage. As an example problem: – suppose we need to provide our operational teams with the most updated GIS data each time they go out to the field; – Consider that after their job is done, while still in the field, they will update the spatial data related to the job they executed; – In the end we want this new data in our main geodatabase.
  15. 15. Use case #3 – automate workflow One possible workflow could be to: 1. Make a python script to create a geodatabase on the team portable device and a ‘check-out’ replica between the main (parent) and the team (child) geodatabase, providing them with the data; Replicate Main data Team geodatabase geodatabase (Parent) (Child)
  16. 16. Use case #3 – automate workflow 2. Create another python script to ‘Synchronize changes’ between the geodatabases, updating the data, after the job is completed; Synchronize Main data Team geodatabase geodatabase (Parent) (Child)
  17. 17. Use case #3 – automate workflow 3. To make the process simple to our users, we can also create a custom toolbox with tools to run the scripts that check out and then check in the data.
  18. 18. Additional resources Python concepts and language – Google python class http://code.google.com/edu/languages/google-python-class/ – Dive into python www.diveintopython.net/ Arcpy – Visit ArcGis help library, and under Professional Library -> Geoprocessing > The Arcpy site package http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html# /Welcome_to_the_ArcGIS_Help_Library/00r90000001n00000 0/
  19. 19. Questions? Rui Rua rui.rua@geodata.no +47 41 64 82 09

×