Reader small image

You're reading from  Learning ArcGIS Geodatabases

Product typeBook
Published inJun 2014
Publisher
ISBN-139781783988648
Edition1st Edition
Right arrow
Author (1)
Hussein Nasser
Hussein Nasser
author image
Hussein Nasser

Hussein Nasser is an Esri award-winning senior GIS solution architect working in the GIS field since 2006. He is the author of three books in the ArcGIS technology: Administering ArcGIS for Server, Learning ArcGIS Geodatabases, and Building Web Applications with ArcGIS, all by Packt Publishing. In 2007, he won the first place at the annual ArcGIS Server Code Challenge, conducted at the Esri Developer Summit in Palm Springs, California. In 2014, he started the IGeometry YouTube channel, where he periodically publishes educational GIS videos.
Read more about Hussein Nasser

Right arrow

Chapter 5. Programming Geodatabases

During the course of this book, you have learned about the key tools to author, manage, and administer ArcGIS geodatabases. You have learned how to create a geodatabase, add datasets, create relationships, and much more. In the previous chapter, you learned some techniques that can be applied to the geodatabase to optimize and keep your geodatabase healthy. You might have noticed that running all these tools manually, especially in bulk mode, can be a hectic process. That is why Esri, the company that created ArcGIS, has made all these geodatabase functionalities available as geoprocessing tools. These tools can be combined and joined together to form other tools with different functionalities. They can also be called from various programming platforms such as Python to solve interesting problems, as we will see later in this chapter.

Note

A geoprocessing tool is a component that accepts input parameters and produces an output by performing operations on...

Using Python scripting


Due to the simplicity of Python, the 23-year-old scripting language has been widely used to build various applications. Python has also been embedded into other products as a way to extend its functionality. ArcGIS is one of these products that adopted Python for this purpose. In this section, we will learn about a basic Python script to call existing geoprocessing tools, and then we will use these scripts to create a small tool that automatically backs up our Bestaurant geodatabase on a daily basis.

Note

To learn more about advanced Python scripting techniques, you can visit www.Python.org.

You don't have to install Python for the upcoming exercises; if you have ArcGIS for Desktop 10.x, Python 2.7 is installed and configured and ready for use. Let's do some basic warm up exercises on Python before we start on the real work:

  1. Click on the Start menu, expand the ArcGIS folder, expand Python 2.7, and then click on IDLE (Python GUI) to open the Python editor, as shown in the...

Using the model builder


Besides Python scripting, the model builder is a nice way to aggregate multiple geoprocessing tools without the need to have programming skills. If you found it difficult to write Python scripts, you can always use the model builder to create interesting models. In this section, we will use the model builder to build a sample model to create a file geodatabase and a feature class.

Creating a model

You can create a model from either ArcMap or ArcCatalog. To create a model, perform the following steps:

  1. Create a folder in the c:\gdb folder and name it myTools.

  2. Open ArcCatalog, point the cursor to the Geoprocessing menu, and then click on ModelBuilder.

    Note

    You can also use ArcMap to work with ArcToolbox.

  3. Bring up the ArcToolbox window as well since we will use both. Keep both windows next to each other.

  4. In the ArcToolbox window, expand Data Management Tools and Workspace, and then drag the Create File GDB tool to the Model window as illustrated in the following screenshot:

The...

Summary


In this chapter, we discussed some programming flavors. You perceived working with geodatabases from a completely different angle. The chapter demonstrates two methods for programming geodatabases, Python and model builder. Python took the lion's share in this chapter; at first, you learned how to work with basic Python scripting. Then, you were introduced to the arcpy module built by Esri, which allows Python to tap into the power of ArcGIS and do much more. You dove deep into Python by solving a real-world problem from the ground up using Python. Then, you learned about the model builder and how you can combine and mash up multiple geoprocessing tools to create more sophisticated tools. Unlike Python, the model builder requires no programming skills to work on, which makes it desirable for many users.

In the next chapter, we will discuss how to install, configure, and administer an enterprise geodatabase with Microsoft SQL Server Express from scratch. Enterprise geodatabases are...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning ArcGIS Geodatabases
Published in: Jun 2014Publisher: ISBN-13: 9781783988648
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Hussein Nasser

Hussein Nasser is an Esri award-winning senior GIS solution architect working in the GIS field since 2006. He is the author of three books in the ArcGIS technology: Administering ArcGIS for Server, Learning ArcGIS Geodatabases, and Building Web Applications with ArcGIS, all by Packt Publishing. In 2007, he won the first place at the annual ArcGIS Server Code Challenge, conducted at the Esri Developer Summit in Palm Springs, California. In 2014, he started the IGeometry YouTube channel, where he periodically publishes educational GIS videos.
Read more about Hussein Nasser