70% of respondents are male. I suppose this is better than it was 10 years ago, but we really need to attract more women to the field.

41% of you are between the ages of 30-39. 24% are between the ages of 40-49. Less than 2% are above the age of 60.

Salaries appear to be widely dispersed with 29% between $50,000-$70,000/year. I was surprised to see almost 13% below $20,000/year.

ESRI is far and away the most popular platform with 93% of respondents indicating this as one of their primary platforms. This question allows more than one platform to be selected. Open Source GIS software came in second at 14%. I suspect this will grow quite a bit in the coming years.

Primary programming languages in use include .NET (55%), Python (50%) , JavaScript (27%), Java (20%), and Flex (17%). You can learn more about Python, JavaScript, and Flex through our training classes.

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:

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.

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 10Traditional Face to Face
May 23rd – May 25th
King County GIS Center
Seattle, WA$1,350
Contact sales at geospatialtraining.com for more information on this session or to register.

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.

ConvertToMSD
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.

PublishMSDToServerAfter 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.

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.

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.

DataFrame
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.

GraphicElement
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.

LegendElement
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.

MapsurroundElement
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
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
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.