Spring Training Schedule from GeoSpatial Training Services

Posted on March 3, 2011. Filed under: AGIS Server API for Flex, ArcGIS Server, ArcGIS Server for Silverlight, ESRI, Geoprocessing, GeoSpatial Training Services, JavaScript, Python |

Our Spring 2011 training schedule has been released.  Most of these courses are taught in a web based environment but we do have one traditional face to face session of GIS Programming 101 for ArcGIS 10 scheduled for the King County GIS Center in Seattle, WA.  Here is the upcoming schedule:

Download a beta chapter from our upcoming book on the AGIS JavaScript API

Read Full Post | Make a Comment ( None so far )

Adding a Python Script to a New Toolbar in ArcView 9.3.1 (Tutorial)

Posted on February 10, 2011. Filed under: Geoprocessing, Python |

From time to time we like to feature guest posts.  Today I’d like to draw your attention to a tutorial from Bob Roberts at the Python and Then Some blog.  We’re going to be re-posting several of Bob’s tutorials.  I think you’ll find them quite helpful.  The first post will teach you how to add a Python script to a toolbar in ArcView 9.3.1.  You could easily apply the same concept to ArcGIS 10.0.  And now…more from Bob.

So you finished your Python ArcToolbox tool and now you want to add a shortcut to the toolbar. This tutorial is based on the assumption that you have already added your script to the ArcToolbox tools. If not I will cover that in another tutorial. I will show how to add a button in addition to how to add a menu to ArcView toolbar. Both are convenient ways to launch your Python script tools without having to open ArcToolbox.

First we will create a button to launch your tool.

  • Go to Tools > Customize.  This will open up the Toolbars tab.  If you do not want to add your own Toolbar, skip this section.
  • Click New for new toolbar:
  • Save it to either the current project (the .mxd) or to the Normal.mxt for use in all projects.
  • This will create an empty toolbar. Drag the toolbar to the top of ArcView.

Now that you have a new and empty toolbar we need to create the button for the Python tool.

  • Click on the Commands tab under Customize:
  • Scroll to the bottom of the Categories window:
  • Highlight [UIControls] and at the bottom click New UIControl
  • Select UIButtonControl and hit Create
  • Click in the box for the name if you wish to rename the tool
  • Next, click and drag the new UIButtonControl1 to your toolbar that was just created.

Now that the button is one the toolbar, we need to set it up to launch your Python tool.

  • Right click on the new button and you should see several options here.
  • You can change the button image to whatever you would like or you can just use “Text Only” for the name of the tool.

Now that we have the button on the toolbar and changed the way that it displays, it is time to add the Visual Basic snippet to launch the tool.

  • Click on “View Source”. This should open up the Microsoft Visual Basic editor:
  • Copy and Paste the following script between the Private Sub UIButtonControl1_Click() and End Sub:
  • You will need to replace “mypythontoolname” with the name of your Python tool.
  • Click the save button at the top of the VB editor.
  • Click on your button and it should open

There are a few things that can cause the button not to open your Python tool. The most common that I have seen is that the Visual Basic reference is not selected as available for using the ESRI GeoprocessingUI Object Library. This can be added by going into the Visual Basic editor again. At the top there is an option for Tools and then select references. Make sure that the ESRI GeoprocessingUI Object Library is checked. If not, check it to make the library available.

If you want to add a drop down menu for listing multiple Python tools the steps are mostly the same. After creating a new toolbar, you can create a new menu before you create the tool buttons.

On the Customize > Commands tab in the left hand pane there is an option for [New Menu]. Create the new menu in the same manner as creating the UIControls button. Add the menu to the toolbar and then you can add tool buttons to the drop down menu by clicking and dragging them to the drop down.

Hope that helps!

Additional Python and ArcGIS tutorials:

The next session of our instructor guided, Internet based course Programming 101 for ArcGIS 10: Mastering Python begins February 21st, 2011.  We still have a few seats available.  A self-paced version of this course is also available.

Read Full Post | Make a Comment ( None so far )

2011 Schedule of Instructor Led Courses (1st Quarter)

Posted on January 5, 2011. Filed under: AGIS Server API for Flex, ArcGIS Server, ESRI, Geoprocessing, GeoSpatial Training Services, JavaScript, Python |

Here is our schedule of instructor led courses for January-March 2011 in both web based and traditional face to face formats.

Mastering the ArcGIS Server JavaScript API
Web Based
January 10th – February 18th
Still 5 Seats Available

Programming the ArcGIS Server API for Flex
Web Based
January 10th – February 18th

ArcGIS Server Bootcamp
Web Based
February 14th – March 18th
$715 when you register by January 15th

GIS Programming 101 for ArcGIS 10
Web Based
February 21st – March 18th
$567 when you register by January 15th

GIS Programming 101 for ArcGIS 10
Traditional Face to Face
February 7th – February 9th
Keck & Wood Headquarters
Duluth, Georgia
More Information
Click here to register

This last one is in May but it’s already on the calendar so we’re including it as well.

GIS Programming 101 for ArcGIS 10
Traditional Face to Face
May 23rd – May 25th
King County GIS Center
Seattle, WA
Contact sales at for more information on this session or to register.

Read Full Post | Make a Comment ( None so far )

Use ArcPy Mapping to Publish Map Documents to ArcGIS Server

Posted on November 15, 2010. Filed under: ArcGIS Server, ESRI, Geoprocessing, GeoSpatial Training Services, Python |

The ArcPy Mapping module, released with ArcGIS 10 provides a number of capabilities including the management of map documents and layers, printing, exporting, and ArcGIS Server publishing as well as map automation and the creation of PDF map books. In this post you will learn how to use Python and the ArcPy Mapping module to convert a map document file to an ArcGIS Server service. At the end of this post you will have learned the following related to publishing your map document to ArcGIS Server:

  • How to analyze a map document for warnings and errors
  • Convert a map document file to a map service definition file (MSD)
  • Publish a MSD file to ArcGIS Server as a service

Publication of a map document to ArcGIS Server with Python involves a three step process.  The goal of the first two steps is to convert a map document file to a map service definition file (MSD).  The analysis process scans the map document file for any warnings or errors.  Errors must be resolved before publication to an MSD file and warnings should also be carefully examined because they can lead to performance problems in ArcGIS Server.  Once errors and warnings have been resolved, the ConvertToMSD() function can then be called against the file.  This function will create a new MSD file which can then be published to ArcGIS Server through the PublishMSDToServer() function.

Analyze the Map Document for Warnings and Errors
The AnalyzeForMSD() function analyzes the map document for suitability and performance issues before conversion to MSD.  This function returns a Python dictionary containing the warnings, errors, and general messages.  All errors must be repaired before publication.  The code sample below shows an example of calling the AnalyzeForMSD() function.

The AnalyzeForMSD() function takes a map document as a parameter. It analyzes the document and returns information, warnings, and errors in a Python dictionary which in this case is stored in the variable ‘analysis’. We then loop through this dictionary variable and print out the information contained within.  You can see an example of the information returned in the figure below.

You will want to pay particular attention to the ERRORS section. Each error that has been found must be fixed before the document can be published to ArcGIS Server. In this case the background symbol for our data frame is not a solid fill.   A solid fill is required for background symbols.  You can change that in ArcMap by clicking the active data frame and selecting Properties.  All errors listed in the ERRORS section must be fixed before publication can occur.

Once you’ve fixed all errors that have been identified you can convert to your MXD file to an MSD file through the ConvertToMSD() function.  You can specify a specific data frame as the active data frame for the service that will eventually be published to ArcGIS Server.  Again, no errors can be present in the MSD file.  The code example below shows how to convert an MXD file to an MSD.

ConvertToMSD() accepts several arguments including object variables for the mxd and msd files, the data frame to be used as the active data frame for the published service, and two parameters that deal with anti-aliasing. In this case we want the active data frame to be used as the active data frame in the published map service. Therefore, we can simply use a double quote (“”) as the third parameter of ConvertToMSD(). Anti-aliasing is a method for creating a better visualization of text and vector features. I normally just use “Normal” for both these parameters.

After checking your map document for errors, resolving any errors, and converting the map document to an MSD file you are finally ready to publish the document to ArcGIS Server.  There are several administrative tasks that you must do before performing this final step.

  • ArcGIS Server 10 must be installed
  • Your data and MSD file must be in a location accessible to ArcGIS Server.  More information about this can be found here
  • The username running the publish script must be a member of the ArcGIS Server admin group.  More information about that here.

In your script you’ll need to call PublishMSDToServer() to actually publish the MSD file as a service in ArcGIS Server 10.  You must supply connection information and information about the service to this function.

The code example below represents the general nature of the script you will need to write.  Obviously the path to the MSD file and your server names and service name and folder will be different.

Want to learn more about the ArcPy Mapping module and other programming ArcGIS Desktop with Python topics?  The next session of our Internet based, instructor led course “GIS Programming 101: Mastering Python for Geoprocessing in ArcGIS” begins February 21st.  We also provide a self-paced version of this course which you can find here.

Read Full Post | Make a Comment ( None so far )

Print and Export Maps from ArcMap with ArcPy Mapping

Posted on November 1, 2010. Filed under: ESRI, Geoprocessing, GeoSpatial Training Services, Python |

Printing and exporting maps is obviously one of the most commonly performed ArcGIS tasks.  The new Arcpy.mapping module provides several functions that you can use to automate your routine print and export tasks.  In this post we’ll examine Arcpy.mapping functions you can use for printing and exporting either maps from either the data or layout view in ArcMap.

Arcpy.mapping provides a PrintMap() function for printing page layouts or data frames within ArcMap and a host of Export functions that export the page layout or a data frame to various image formats and PDF files.  Before calling PrintMap() it is common practice to call the ListPrinterNames() function which returns a list of the available printers for the local computer.  A particular printer can then be found by iterating the list of printers and used as input to the PrintMap() function.

PrintMap() can print either a specific data frame or the page layout of a map document.  By default this function will use the printer saved with the map document or, if not present in the map document, the default system printer.  As I mentioned you can also use ListPrinterNames() to get a list of the available printers and select one of these printers as input to PrintMap().  In the code example on below PrintMap() uses the default printer as specified through the use of double quotes as the second parameter to PrintMap().

You can use one of the many Export functions provided by Arcpy.mapping to export a data frame or page layout to an image file.  Available formats include AI, BMP, EMF, EPS, GIF, JPEG, SVG, and TIFF.  The parameters provided for each function will vary depending upon the type of image.  Examples of these function names include ExportToJPEG, ExportToGIF, ExportToBMP, and all the others you see listed here.

You can also export your data frames or page layout to PDF format with ExportToPDF().  PDF is obviously a very popular interchange format so you will likely need to become familiar with this function.  Calling ExportToPDF() is much the same as calling any of the image export functions since it takes an mxd and path to output the file along with optional properties for the PDF.

In addition to exporting your maps to PDF you can also manipulate existing PDF documents or create new PDF documents.  You can merge pages, set document open behavior, add file attachments, and create or change document security settings.  The PDFDocumentOpen() function is used to open an existing PDF file for manipulation.  PDFDocumentCreate() creates a new PDF document.  These functions are often used in the creation of map books.

You’ll need to use PDFDocumentCreate to create a new PDF document by providing a path and filename for the document.  The PDF is not actually created on disk until you insert or append pages and then call PDFDocument.saveAndClose().  The appendPages() and insertPages() functions are used to insert and append pages. 

PDFDocumentOpen accepts a parameter that specifies the path to a PDF file and returns an instance of PDFDocument.  Once open you can make modifications to PDF file properties, add or insert files, and attach documents.  Make sure you call PDFDocument.saveAndClose() after all operations to save the changes to disk.

A number of properties can be set on a PDF Document through the PDFDocument object including getting a page count, attaching files, updating title, author, subject, keywords, open behavior, and the layout.  You can also update the document security by calling PDFDocument.updateDocSecurity() to set a password, encryption, and security restrictions.

Other ArcPy Mapping articles.

Want to learn more about the ArcPy Mapping module and other programming ArcGIS Desktop with Python topics?  The next session of our Internet based, instructor led course “GIS Programming 101: Mastering Python for Geoprocessing in ArcGIS” begins October 25th, 2010.  You can still register even though class has already begun.

Read Full Post | Make a Comment ( None so far )

Working with Layout Elements in the ArcPy Mapping Module

Posted on August 9, 2010. Filed under: ESRI, Geoprocessing, Python |

In my last post I introduced the ArcPy Mapping module, released with ArcGIS 10, which provides a number of capabilities including the management of map documents and layers, printing, exporting, ArcGIS Server publishing, map automation, and the creation of PDF map books.  Today we’re going to take a closer look at the Layout classes provided by the module.

The ListLayoutElements() function returns a list of Layout elements in the form of various Layout classes.  Each element can be one of: GraphicElement, LegendElement, PictureElement, TextElement, MapSurroundElement, or PictureElement as seen in the graphic below.

ListLayoutElements() is a versatile function which in its most basic form is used to return a list of all the layout elements on the page layout of a map document.  However, there are two optional parameters that you can supply to filter this list.  The first type of filter is an element type filter in which you specify that you only want to return one of the layout element types.  You can also apply a wildcard to filter the returned list.  These two types of filters can be used in combination.  For example, in the code below we are specifying that we only want to return LEGEND_ELEMENT objects with the name “Legend Crime”.  This would likely result in a highly filtered list, and as we can see only a single item was returned.

Each graphic on a layout has a ‘name’ property that you can view in ArcMap by right clicking the element and selecting Properties.  Most elements are assigned a default name if you don’t specifically supply one.  You should make it a best practice to assign a unique ‘name’ to each element on your page layout.  This will make it easier for you to access particular elements from your Python scripts.

Each element on the page layout has various properties that can be set through your Python code.  For example, in the code block below we are accessing a specific Legend element (“Legend Crime”) and assigning a new title to the legend.

In this case we are only changing the Legend title.  However, LegendElement provides other properties that enable it to be repositioned on the page layout as well as getting legend items and the parent data frame.

Below is a brief description of each of the layout elements accessible through Python.

The DataFrame class provides access to data frame properties in the map document file.  This object can work with both map units and page layout units depending upon the property being used.  Page layout properties such as positioning and sizing can be applied to the properties on this slide including elementPositionX, elementPositionY, elementWidth, and elementHeight.

The GraphicElement object is a generic object for various graphics that can be added to the page layout including tables, graphs, neatlines, markers, lines, and area shapes.  You’ll want to make sure that you set the ‘name’ property for each graphic element (and any other element for that matter) if you intend to access it through a Python script.

The LegendElement provides operations for positioning of the legend on the page layout, modification of the legend title, and also provides access to the legend items and the parent data frame.  A LegendElement can be associated with only a single data frame.

The MapsurroundElement can refer to north arrows, scale bars, and scale text and like LegendElement is associated with a single data frame.  Properties on this object enable repositioning on the page.

PictureElement represents a raster or image on the page layout.  The most useful property on this object allows for getting and setting the data source which can be extremely helpful when you need to change out a picture such as logo in multiple map documents.  For example, you could write a script that iterates through all your map document files and replaces the current logo with a new logo.  You can also reposition the object.

TextElement represents text on a page layout including inserted text, callouts, rectangle text and titles, but does not include legend titles or text that is part of a table or chart.  Properties enable modifying the text string which can be extremely useful in situations where you need to make the same text string change in multiple places in the page layout or over multiple map documents, and of course repositioning of the object is also available.

The next session of our Internet based, instructor led course, GIS Programming 101: Mastering Python for Geoprocessing in ArcGIS begins October 25th.  This course is only $499 when you register by August 31st.  The regular price of this course is $667.

Read Full Post | Make a Comment ( None so far )

Benefit from GIS E-Learning Opportunities

Posted on June 17, 2008. Filed under: ESRI, Geoprocessing, GeoSpatial Training Services, Google Earth, Google Maps |

In recent years there has been a large movement towards e-learning in many industries, and GIS is no exception. Although computers will never completely eliminate the need and desire for human interaction between instructor and student, the many benefits it offers far outweigh the limitations of the medium. In this post we will examine the benefits, drawbacks, availability, and types of e-learning currently available to GIS professionals.

Features Unique to E-Learning
Knowing a little bit about learning styles can help you determine if e-learning is for you. The interaction and delivery methods used in online classes are dramatically different from traditional classes, so understanding how you learn is a good part of the decision-making process. The three predominant learning styles are visual, auditory, and tactile/kinesthetic. Visual and auditory learning styles fall into the category of passive learning modes while the tactile/kinesthetic learning style is an active learning mode. An active learning mode implies that learning is accomplished by doing or practicing a task and/or speaking about what we learn. Most people tend to fall into this category. However, some people learn best through a passive learning mode which is done through seeing and reading.

Like no other training form, e-learning promises to provide a single experience that accommodates the three distinct learning styles of auditory learners, visual learners, and kinesthetic learners. Other advantages created by the advent and development of e-learning are more efficient training of a globally dispersed audience; reduced publishing and distribution costs as Web-based training becomes a standard; and decreased costs of training from a travel and training materials standpoint.

E-learning also offers individualized instruction, which print media cannot provide, and instructor-led courses allow clumsily and at great cost. In conjunction with assessing needs, e-learning can target specific needs. And by using learning style tests, e-learning can locate and target individual learning preferences.

Additionally, synchronous e-learning is self-paced. Advanced learners are allowed to speed through or bypass instruction that is redundant while novices slow their own progress through content, eliminating frustration with themselves, their fellow learners, and the course.

In these ways, e-learning is inclusive of a maximum number of participants with a maximum range of learning styles, preferences, and needs.


Some of the advantages to the learner include:

  • Reduced cost
    This is the single most influential factor in adopting e-learning. The elimination of costs associated with student travel, lodging, and meals are directly quantifiable. With the cost of gasoline now reaching over $4.00/gallon and airfare costs increasing weekly this adds up to big savings. The reduction of time spent away from the job by employees may be the most positive offshoot.
  • Learning times reduced
    An average of 40 to 60 percent, as found by Brandon Hall (Web-based Training Cookbook, 1997, p. 108).
  • Increased retention
    Retention averages an increase of 25 percent over traditional methods, according to an independent study by J.D. Fletcher (Multimedia Review, Spring 1991, pp.33-42).
  • On-demand availability
    Enables students to complete training conveniently at off-hours or from home.
  • Self-pacing
    For slow or quick learners reduces stress and increases satisfaction.
  • Interactivity
    Engages users, pushing them rather than pulling them through training.
  • Confidence
    Responsibility of mastery is reduced since materials are available as a refresher or quick reference materials.

The ways in which e-learning may not excel over other training include:

  • Technology issues
    Some learners are fearful or intimidated by technology or the technology is unavailable for use.
  • Portability
    E-Learning is not as portable as printed workbooks or reference material, but the limitations of portability have been greatly reduced through wireless connections, network links, notebook computers, PDAs and mobile phones.
  • Reduced interaction
    Social and cultural interaction can be a drawback. The impersonality, suppression of communication mechanisms such as body language, and elimination of peer-to-peer learning that are part of this potential disadvantage are lessening with advances in communications technologies.

Types of E-Learning and Delivery Methods
E-learning takes many forms including the following:

  • Web based (Blackboard, Moodle, WebCT)
  • Computer-based (CD-ROM)
  • Blended learning – combination of online and face to face
  • Video/audio
  • Blogs, Chat, and Discussion Forums
  • Hard-copy Workbooks
  • Videoconferencing and/or Teleconferencing

It is not uncommon for more than one of these delivery formats to be used in the same course of study to supplement the learning experience.

Availability of GIS E-Learning Opportunities
A number of GIS e-learning opportunities exist from commercial and academic institutions. We don’t have room in this article to highlight all the available distance learning programs offered by colleges and universities so we have highlighted a few of the better known options.


  • GeoSpatial Training Services
    Our company, GeoSpatial Training Services, provides both web-based and computer-based e-learning opportunities focusing primarily on Google Earth, Google Maps, and ESRI technologies.
  • ESRI Virtual Campus
    The ESRI Virtual Campus hosts a number of self study courses through their virtual campus.
  • New Urban Research
    New Urban Research offers twelve advanced topic ArcGIS Tele-Classes.

University Distance Learning Programs

  • UNIGIS International
    UNIGIS is a worldwide network of educational institutions which offer distance learning courses in GIS. Institutions within the UNIGIS network offer internationally recognized qualifications for GIS professionals and those seeking to enter the field.
  • Penn State University
    Penn State offers a Masters Degree in GIS through their World Campus program.
  • Institute for Advanced Education in Geospatial Sciences
    IAEGS was established as a collaborative course development center, based at the University of Mississippi in Oxford, Mississippi and hosts a number of courses on topics such as remote sensing, photogrammetry and digital image processing, and other geospatial technology topics.
  • University of Southern California
    USC offers both a Master of Science + Technology degree along with a GIST certificate program.
  • Elmhurst College
  • University of Denver

GeoSpatial Training Services: Our Approach to GIS E-Learning
At GeoSpatial Training Services, we focus on the development of Internet based and computer based (CD-ROM) courses for the geospatial industry and we focus heavily on Google Earth, Google Maps, and ESRI technologies. Through our Virtual GIS Classroom we offer Internet based courses such as “GIS Programming 101: Mastering Python for Geoprocessing in ArcGIS” and will soon have additional offerings. In addition, we offer a wide array of computer based GIS training options available by e-delivery (download) or traditional via traditional CD-ROM. Furthermore, we develop custom training solutions for geospatial custom off-the shelf products (COTS) and organizations and conversion of instructor led training materials to various e-learning formats.

Read Full Post | Make a Comment ( None so far )

Executing ArcGIS Tools from Geoprocessing Scripts (Part 5)

Posted on February 28, 2008. Filed under: ESRI, Geoprocessing | Tags: , , , , |

Other posts in this series: 
Scripting Your ArcGIS Geoprocessing Tasks (Part 1)
Scripting Your ArcGIS Geoprocessing Tasks with Cursors (Part 2)
More ArcGIS Geoprocessing Concepts – Enumeration Objects (Part 3)
Obtaining Descriptive Information About GIS Datasets with ArcGIS Geoprocessing Objects (Part 4)

In this final post in our five part series on scripting your geoprocessing tasks in ArcGIS we will take a look at how you can take advantage of the built in geoprocessing tools in ArcGIS through your scripts.  These are the tools available through ArcToolbox. 

Each of these tools is accessible from your Python scripts through dynamic methods on the Geoprocessor object.  We’ll take a look at the tools that are available, the syntax you need to use to access them, aliases for the toolboxes that you can use in referencing the tools, and some examples of how you can use these tools in your code. 

Dynamic Tools
The arcgisscripting/GpDispatch object on the Geoprocessor OMD contains a section called Dynamic Methods and Properties.  The Tool method seen below is a generic method meant to imply the existence of multiple tools. 


This generic “Tool” method can be a bit confusing until you understand some additional information.  There is a single “Tool” method on the OMD for two reasons.  First, there are simply too many geoprocessing tools to fit on the OMD.  Remember, if you have the ArcInfo license this would mean you’d have access to approximately 200 tools.  In addition, the tools available will depend upon the license level that you have.  Not only does this include the basic license level (ArcView, ArcEditor, ArcInfo), but also the ArcGIS extensions that you are licensing (3D Analyst, Spatial Analyst, many others).  So, as you can see it simply makes sense to group all these tools into a single generic “Tool” method.

Toolbox Names and Aliases
All system toolboxes have an alias property.  This alias is important because it is possible to have multiple tools with the same name.  For instance, a Buffer tool can be found in both the Analysis and Coverage toolboxes.  Therefore, to distinguish the correct tool in your code you’ll need to add the suffix “_<alias>” when calling a tool.  For example:

gp.buffer_analysis(“Roads.shp”,”Road_Buff.shp”, “150 feet”)

This specifically tells the geoprocessor to execute the buffer tool found in the analysis toolbox.  This is a bit inefficient though and most people prefer to set the Toolbox parameter in their code before calling the tool.  For example:

gp.toolbox = “analysis”
gp.buffer(“Roads.shp”,”Road_Buff.shp”, “150 feet”)

The alias for each toolbox can be found by right-clicking the toolbox in ArcToolbox and selecting Properties.

Tool Syntax
To run a tool from the geoprocessing library you need to know the correct syntax for doing so.  For example, the Buffer tool requires several inputs including the input features to buffer, an output feature class, and a buffer distance.  You must give Python the parameters it needs to run the tool correctly.  There are a number of ways that you can access syntax information for a tool, but perhaps the easiest is to use the online ArcGIS Desktop help system.   Here is the link to help information for the Buffer(Analysis) tool.  The help system contains an illustration, usage tips, command line syntax and examples, scripting syntax, and script examples for each tool.  For this post we’ll concentrate on the scripting syntax.  Scroll down near the bottom of the help page until you get to the Scripting syntax section.  In this case you should see the following:

Just below this you’ll see an explanation of each paramter including required or optional information, a descriptive explanation, and the data type.  Required parameters must be included when you call the tool while optional parameters are just that.  In some cases you may have a need to include these parameters and sometimes you won’t.   So, a very simple buffer script could look something like the figure below.

More Information
We will be presenting a new Virtual GIS Classroom course, “GIS Programming 101: Mastering Python for Geoprocessing in ArcGIS” starting March 24th and ending April 18th.  We still have 2 seats of available so hurry to reserve your seat now.  We do offer a 15% discount for government, educational, and non-profit entities.

We also offer an e-learning course entitled “Introduction to Geoprocessing with Python” which contains even more detailed information on ArcGIS geoprocessing with approximately 200 slides of audio and video lectures, visual software demonstrations, exercises and data.

Read Full Post | Make a Comment ( None so far )

Obtaining Descriptive Information About GIS Datasets with ArcGIS Geoprocessing Objects (Part 4)

Posted on February 17, 2008. Filed under: ESRI, Geoprocessing | Tags: , , , |

Other posts in this series: 
Scripting Your ArcGIS Geoprocessing Tasks (Part 1)
Scripting Your ArcGIS Geoprocessing Tasks with Cursors (Part 2)
More ArcGIS Geoprocessing Concepts – Enumeration Objects (Part 3)

The arcgisscripting/GpDispatch object contains a Describe method that can be used to return an object that describes data.  The Describe method takes a single argument which is a pointer to a data source.  This method is intelligent enough to determine the type of data being referenced and return an object that describes the type of data.   Each descriptive object returned contains information about the particular dataset specified in the InputValue parameter passed into the Describe method.


For instance, if you use the Describe method with a  pointer to a feature class, a FeatureClass Properties object will be returned containing information about that dataset.  This object is often used to test for the type of data (either point, line, or polygon) before further processing.  Various read-only properties are available through this object including ShapeType which returns the basic data type such as point, line, or polygon, FeatureType, ShapeFieldName, and others. 

 This class also has access to two other classes in the Describe object model diagram.  These two classes are Table Properties and Dataset Properties.  The Table Properties object supplies a Fields object containing the Fields in the feature class as well as an Indexes property that returns an Indexes object containing all indexes on the feature class.    The Dataset Properties object contains properties for the spatial reference, extent, and dataset type.

Other Describe Objects
There are a number of other describe objects that can be returned by the Describe method including Tables, Datasets, Workspaces, Relationships, Raster Catalog, Raster Dataset, Raster Band, Coverages, and Layers.  For specific information about these objects please see the green colored objects on the OMD.

Common Describe Object Properties 
All objects returned by the Describe method on GpDispatch can access two additional properties.  These properties are DataType and CatalogPath.  DataType is used to distinguish between types of features classes such as shapefiles, coverages, personal geodatabases, CAD data, and others.  It is often used in if..elif..else decision statements to branch code based on the type of data.  CatalogPath can be used to obtain the full path to the data based on an ArcCatalog connection.  This information is identical to what you would find if you were viewing the data in ArcCatalog.

More Information
We will be presenting a new Virtual GIS Classroom course, “GIS Programming 101: Mastering Python for Geoprocessing in ArcGIS” starting March 24th and ending April 18th.  We still have 5 seats of available so hurry to reserve your seat now.  We do offer a 15% discount for government, educational, and non-profit entities.

We also offer an e-learning course entitled “Introduction to Geoprocessing with Python” which contains even more detailed information on ArcGIS geoprocessing with approximately 200 slides of audio and video lectures, visual software demonstrations, exercises and data.

Read Full Post | Make a Comment ( None so far )

More ArcGIS Geoprocessing Concepts – Enumeration Objects (Part 3)

Posted on February 8, 2008. Filed under: ESRI, Geoprocessing | Tags: , , , , |

Other posts in this series on scripting your ArcGIS geoprocessing tasks:
Scripting Your ArcGIS Geoprocessing Tasks (Part 1)

Scripting Your ArcGIS Geoprocessing Tasks with Cursors (Part 2)

We all make lists in our daily lives.  Perhaps we create a grocery or shopping list, a “to do” list, a list of goals, or wish lists.  Whatever the case may be we are all familiar with the concept of lists.  Enumeration objects in the geoprocessing framework are essentially the same concept in that these objects contain lists of objects.  These may be lists of feature classes, fields, indexes, rasters, toolboxes, and many others.  As you can see below the GpDispatch/arcgisscripting object contains a number of methods that can be used to generate these enumeration objects.

We’ll start first with the ListFields and ListIndexes methods which return specific enumeration objects. 

ListFields Method
The ListFields method on GpDispatch takes three arguments as you can see below.

  • InputValue – a string representing the path to a feature class or table
  • wildCard – an optional parameter used to limit the fields returned.  If no value is given, all fieds are returned.  Using a combination of * and characters can be used to limit the fields returned
  • fieldType – an optional parameter used to limit the fields returned by data type (i.e. integer, string, date)

A Fields object is returned by the ListFields( ) method.

The Fields object is a type of enumeration which contains a list or collection of individual Field objects.  What you’ll notice about each of the enumeration objects is the existence of the Next and Reset methods.  These methods allow you to navigate the structure of the enumeration, and return the objects contained within as seen in the diagram below.


 Below you will see a visual depiction of the process for navigating an enumeration.  Although we are depicting the navigation of a Fields enumeration, the same process occurs in any other enumeration object.  In this example, we’re using the ListFields method to return an object named lstFields.  This object contains a list of individual Field objects for the shapefile that we specified in the ListFields method.  Each enumeration object contains a pointer that is used to access individual members of the collection.  This pointer is initially set just above the first object in the collection.  The first call to the Next method return the first Field object in the collection.  In this case, we’re returning a field named Pop1990.  A second call to the Next method will return the Pop2000 Field object.  Each successive call on the Next method will return the next Field until the end of the collection is reached at which point a None reference will be returned.  These are forward moving enumerations meaning that you can’t move back through the list.  You can however use the Reset method to move the pointer back to the top of the list.

Once the individual Field objects are retrieved from the enumeration you have read only access to the field information.  Notice on the figure below that each of the properties have a single sided barbell indicating that they are read only properties.  You can obtain a lot of information about the individual field objects including the name, aliasname, domain, length, type, and several others.

ListIndexes Method
The concepts that we discussed above in relation to the ListFields method and the Fields enumeration object returned as a result also apply to the ListIndexes method.  Instead of returning a Fields object we get an Indexes object which is also an enumeration object with the same Next and Reset methods.


The only difference in the method signatures between ListIndexes and ListFields is that ListIndexes does not have the optional dataType parameter. 

As you can see above the Indexes enumeration object contains individual Index objects which you can access from the collection.  Each index has a number of read only properties including the name, ascending and unique status, and the Fields on which the index operates.

Other Enumeration Methods
The remaining enumeration methods on GpDispatch return a generic enumeration object containing objects of type featureclass, raster, table, dataset, workspace, environment, toolbox, or tool.  One important thing to note on these methods is that you will need to specify the workspace before calling this methods.

import arcgisscripting
gp = arcgisscripting.create()
gp.toolbox = “analysis”

# Set the workspace
gp.workspace = “c:\\Houston\\CrimeData”

# Call ListFeatureClasses
fcs = gp.ListFeatureClasses( )

#loop through the feature classes and buffer
fc =

while fc:
     outName = “buffered_” + fc
     gp.buffer(fc, outName, ‘500 Feet’)
     fc =

More Information
We will be presenting a new Virtual GIS Classroom course, “GIS Programming 101: Mastering Python for Geoprocessing in ArcGIS” starting March 24th and ending April 18th.   This class has a maximum size of 10 students and is filling up quickly.  We do offer a 15% discount for government, educational, and non-profit entities.

We also offer an e-learning course entitled “Introduction to Geoprocessing with Python” which contains even more detailed information on ArcGIS geoprocessing with approximately 200 slides of audio and video lectures, visual software demonstrations, exercises and data.

Read Full Post | Make a Comment ( None so far )

« Previous Entries

Liked it here?
Why not try sites on the blogroll...