Friday, December 3, 2010

Getting Installation Information in ArcGIS 10

At v10 there is a very Arcpy way of getting the installation directory for ArcGIS Desktop.  It's very easy and it goes as follows:

Now we want to see what software is installed on the machine:

You'll ge a list of software installed on the machine.

Happy Coding!

Thursday, October 28, 2010

Dynamic Label Tip

When working with data driven pages, you might want to put the adjacent grid cells on the page layout. What happens is the cell is empty? By default, the value "[EMPTY]" will appear, which is not very pleasing. To get around this issue, there is a property called emptystr. If you set the emptystr=" " you will see nothing instead of "[EMPTY]."

Code sample below:

< dyn emptystr=" " property="PageNumber_E" type="page" >

Tuesday, October 26, 2010

Assigning Alias to Custom Toolboxes

I create lots of custom scripts and toolboxes to help out with various tasks, and I noticed the following message the other day when I exported a script from model builder to python:
# Warning: the toolbox toolbox.tbx DOES NOT have an alias.
# Please assign this toolbox an alias to avoid tool name collisions
# And replace with arcpy.toolname_ALIAS(...)

Basically, the system is asking for an Alias to provide an additional unique identifier because tools within the same toolbox cannot have the same name, but tools in other toolboxes can have the same name. 

To define an alias, open ArcCatalog and right click on the tbx file.  Select properties, you'll see this:

Enter in an alias and press ok.

That easy!

Friday, October 8, 2010

Alternate Access Mapping for SharePoint

Alternate Access Mapping enables you to access your Sharepoint site via a typical URL like instead of hitting the server name at http://mysharepointserver. In combination with DNS A host entries you can also define URLs like even though your My Site web application is hosted on a different port.

Let's start:

  1. Go to Central Administration 
  2. Click on the Operations Tab
  3. Click on Alternate Access Mappings under Global Configuration
  4. You should now see a list of your web applications, switch over to the one you want to map to the new URL by selecting it from the drop down on the right side.
  5. Click on Edit Public URLs and change the desired zone URL type to your new domain name. You can also change your internal URLs also by clicking Add Internal URLs.
  6. Now you’ll have to switch over to your DNS server.
  7. Within the DNS Management Console and Under Forward Look up Zones:
  8. Add a new Primary Zone with your new domain name.
  9. Add a new Host (A) to the records and point the IP Address to the SharePoint server.

SharePoint 2007 - Enable Anonymous Access

1). To enable anonymous on the IIS web site do the following:
  • Launching Internet Information Services Manager from the Start -> Administration Tools menu
  • Select the web site, right click and select Properties
  • Click on the Directory Security tab
  • Click on Edit in the Authentication and access control section
1a). Or enable anonymous in SharePoint using the Central Administration section:
  • First get to your portal. Then under “My Links” look for “Central Administration” and select it.
  • In the Central Administration site select “Application Management” either in the Quick Launch or across the top tabs
  • Select “Authentication Providers” in the “Application Security” section
  • Click on the “Default” zone (or whatever zone you want to enable anonymous access for)
  • Under “Anonymous Access” click the check box to enable it and click “Save”
NOTE: Make sure the “Web Application” in the menu at the top right is your portal/site and not the admin site.
You can confirm that anonymous access is enabled by going back into the IIS console and checking the Directory Security properties.
2). Enable anonymous access in the site.
  • Return to your sites home page and navigate to the site settings page. In MOSS, this is under Site ActionsSite SettingsModify All Site Settings. In WSS it’s under Site ActionsSite Settings.
  • Under the “Users and Permissions” section click on “Advanced permissions”
  • On the “Settings” drop down menu (on the toolbar) select “Anonymous Access”
  • Select the option you want anonymous users to have (full access or documents and lists only)
Now users without logging in will get whatever option you allowed them.
A couple of notes about anonymous access:
  • You will need to set up the 2nd part for all sites unless you have permission inheritance turned on
  • If you don’t see the “Anonymous Access” menu option in the “Settings” menu, it might not be turned on in Central Admin/IIS. You can manually navigate to “_layouts/setanon.aspx” if you want, but the options will be grayed out if it hasn’t been enabled in IIS
  • You must do both setups to enable anonymous access for users, one in IIS and the other in each site

Thursday, October 7, 2010

Searching Esri ArcObject Help With Google

Here is a great tip I've picked up over the last couple of months.  When working with the online help system for ArcObjects, you can sometimes get tons of search results for unrelated topics.  For example, say you search Point or Polygon, you will get about 10,000 results from the forums, other help topics.  It's basicly information overload!

Let's say you need to search the .NET ArcObjects help, so to streamline the search process, you can utilize Google's search engine by doing the following:
  1. In order for google to work, you need the site.  For this example, we will use You can to remove the http:// and the ao_home.html for your site reference.
    • The result should be this:
  2. With our site in hand, navigate to google ( and create a new search entry as follows: " TEST" 
  3. Copy the resulting URL and ignore the search results
For IE:
  1. Go to:
  2. Paste the resulting Google Search URL into the URL box
  3. Give it a descriptive name. Ex: Search .NET ArcObjects
  4. Click install

Tuesday, October 5, 2010

Counting Values Script - Finding Likely Voters

It's election time in the United States, and some of you might be helping out with campaigns.  A colleague of mine who helps out with campaigns asked for my advice on how to make a quick utility to examine who voted in the last four general elections.  From that information, he would categories likely, unlikely, very likely voters. 

Of course I said use python.  It's quick, easy, and reusable:

# Input Parameters #
inputTable = arcpy.GetParameterAsText(0)
CountFields = arcpy.GetParameterAsText(1)
VotedValues = arcpy.GetParameterAsText(2)
# Local Variables #
ElectionCountFieldName= "ElectionCount"
# Logic #
fields = arcpy.ListFields(inputTable)
for field in fields:
if == ElectionCountFieldName:
arcpy.DeleteField_management(inputTable, ElectionCountFieldName)
del fields

arcpy.AddField_management(inputTable, ElectionCountFieldName, "TEXT")

rows = arcpy.UpdateCursor(inputTable)
splitVal = VotedValues.split(',')
for row in rows:
count = 0
for f in CountFields:
if str(row.getValue(f)) in splitVal:
count = count + 1
del row, rows
arcpy.SetParameterAsText(3, inputTable)

where the inputTable is the table which contains the data you wish to sum up, CountFields is a collection of field names (multi-value object), and VotedValues is a comma separated string (value1,value2, etc...) that represents the values of a voter voted.

Now that the script is created, you need to create the toolbox in ArcCatalog or ArcMap:

Parameter NameSetup
1Input Table/FCType: Feature Class or Table
2FieldsType: Field,
Obtained From: Parameter 1,
MultiValue: Yes
3Voted ValuesType: String
4Return Table/FCType: Table/FC,
Direction: Output

Enjoy and Happy GISing

Friday, September 10, 2010

2010 Census TIGER/Line Shapefiles

I know everyone is as excited as I am the the first round of TIGER data from the 2010 census starts being released in December 2010 to February 2011.

For the complete schedule: check out this.


Wednesday, September 8, 2010

Working with Special Characters

Every once in awhile you need to work with the following characters in XAML:
  • >
  • <
  • "
  • &
You would get these errors if you put them in a text value:
Error 5 Entity references or sequences beginning with an ampersand ‘&’ must be terminated with a semicolon ‘;’.
Error 4 ‘"’ is an unexpected token. The expected token is ‘;’.

You can encode invalid characters for use in XAML by using the following encoding syntax:













(numeric character mappings)

&#[integer]; or


(nonbreaking space)

&#160; (assuming UTF-8 encoding)

Thursday, August 19, 2010

Social Networking Map

This is from:

Wednesday, August 11, 2010

Creating Private Methods in Python

Python, as you may or may not know, is a fully object oriented language and with the newly created ArcPy module for ESRI's ArcGIS Suite, users should start creating programs following some sort of OO design. 
One design pattern to follow is the singleton pattern, which can be found here

Once you have started diving into the world of classes, name spaces, and methods, it's time to figure out how to make methods private.  It's surprisingly simple to do this.  To make something private in python, just put two underscores in front of your method.  That's it, now only that class can access that method. 

Here is a small example:
This class contains two functions.  One that will make the text upper case, and the other lower case.  The capital method has the two __ in front of the method, and should not be seen by the user, and lower() has no underscores that therefore is public. Using the idle's we can easily show that __capital cannot be used publicly by a user:


Thursday, July 29, 2010

Developer Cheat Sheets

Tired of googling for answers, check out this site:

It has all kinds of programming reference sheets which are good for quick look ups about various concepts.


Friday, July 23, 2010

PyDev and Installing New Libraries/Modules

If you use PyDev to create python scripts, and you add new libraries to your development system, you will need to update the interpreter.

To do this do the following:
1) Click on Project -> Properties
2) Select PyDev - Interpreter/ Grammar
3) Under the interpreter combo box, click on the text that says: "Click here to configure an interpreter not listed."
4) Press Apply -> It will take a couple of minutes to look through your PythonPaths -> Press Ok
5) Begin Coding


MVVM for Silverlight

MV-VM is a design pattern for Silverlight and WPF.  I have recently ventured into this domain, and I found a good resource to reference:
Check it out and Post you own links in the comments to help other with MVVM design patterns!


Wednesday, July 21, 2010

Wednesday, July 7, 2010

Web ADFs Will be Deprecated

The future of the Web AdfDF has been written on the wall.  It shall be put to rest after version 10 of ArcGIS Server.  Also, many of the new features like time awareness and feature service usage will not be supported at 10.

Check it out here.

Wednesday, June 23, 2010

Question for readers

I want to hear from you, leave a comment answering this question:

How do you envision GIS being used with SharePoint?


Thursday, June 10, 2010

Spatial Web Parts with Silverlight in SharePoint 2010

In SharePoint 2010 (SP2010) you can create a silverlight web part pretty easy by just creating a custom control, then deploy the XAP file to the clientbin folder.  I should note that the pre-canned silverlight web part that I am using does not allow for DCOM bridges to be used, so to communicate between multiple silverlight web parts you would have to the Messaging API, which is quite easy, but that's for another day.

Getting Started, Open Visual Studios 2010, and create an empty SharePoint Project and a Silverlight Application.  For the Silverlight Application project ensure that the "Host the Silverlight Application in the new Web Site" is unchecked.

Now we are cooking with fire, and we can create our Silverlight application.  For this example, I will just add a map and one layer to the project. 
The next step is to place the XAP file in a location that can be used by SharePoint.  Right click on the Silverlight Application we just created and select Properties.  Click on the build tab and change the output path to: "..\..\..\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin\".  Remove the quotes when you put this into the Output Path.

Save and compile the project.  If you get any errors, it's most likely you need to reference the proper ESRI silverlight libaries.
The next step is to configure the SharePoint Project. Add a new item to the SharePoint project and select Module. Double click on the Elements.xml file.

Configure the elements file to match the above image, you need to change the path of the Url to "_layouts/clientsbin/ XAPFILENAME.XAP" and change the Path from the textfile name to the XAP file name.

Click on the module and select the Project Output Refer -> Add a member -> Choose the Silverlight Application name -> in the Deployment Type Select ElementFile -> press OK
Select Build From main toolbar -> Configuration Manager -> Uncheck all the builds except for the SharePoint Project Name and make sure the SharePoint Project has deploy checked.

Save the Project and deploy to SharePoint. 

Open your SharePoint site -> Edit Page -> Add Silverlight Web Part -> enter in the text box the following "_layouts/clientbin/XAPFILENAME.XAP".  You should now see your web part.

Tuesday, May 11, 2010

Serialization With Silverlight

Say you want to serialize an object using silverlight, well you can't use the binaryformater() like in windows forms development, so what to do.  Silverlight has a the DataContractSerializer class which "Serializes and deserializes an instance of a type into an XML stream or document using a supplied data contract."  So this means that you are passing XML string data.

From the windows help: "Use the DataContractSerializer class to serialize and deserialize instances of a type into an XML stream or document. For example, you can create a type named Person with properties that contain essential data, such as a name and address. You can then create and manipulate an instance of the Person class and write all of its property values in an XML document for later retrieval, or in an XML stream for immediate transport."

Here is my code:

Getting Started with Geoprocessing and ArcObjects in .NET

Not a programmer and don't know where to start?
Here is a great "how to get started" article for from ArcUser magazine.


Thursday, April 29, 2010

The Joys of Installs

Today I decided to roll up my sleeves and install SharePoint 2010 beta.
First I decided that I wanted to use Windows 7 64-bit, which was a mistake. All the documents point to the fact that you can do an install on win7-64bit, but you can't. You need to alter the config.xml file.

So I alter everything, and now the setup likes it, yippee, and get the 300 prerequisites installed. (See: for pre-reqs) Now I'm ready to install SP 2010 and configure it. Oh wait, I'm not... error after error, and most of the answers are found here, because Microsoft's help is crap.

Getting sick of the errors, and a glutton for punishment, I decided to format my HD and install Windows 2008, which is the desired OS for sharepoint.

Installation was long, but it went like a breeze, and I did have one funny moment when this appeared:

Take a close look, it says the file should be less than 1 mb, but it was well over 6 mb and growing. Thanks Microsoft.

Now on to installing Silverlight and the MapIt Demo.

Tuesday, April 27, 2010

Google Charts

Google charts is a great/free resource for doing charting.  Many organizations have restrictions on what software you can install, but with google charts no software is needed, just an internet connection.  See this link.  

Here is a simple example:
To get this image, all you have to do is reference this url:,40&chs=250x100&chl=Hello|World

You can simply couple this with python using the webbrowser library. To open the image in a web browser via python try this:

import webbrowser
url =,40&chs=250x100&chl=Hello|World

Thursday, April 15, 2010

Don't Buy This

This is the worst children's toy ever. I hate cubicles because they prevent creativity. I would never buy my child this.

Here is more information.

Monday, April 12, 2010

Working with ArcPy

If you haven't heard, ArcPy is the new geoprocessing module that will be out with version 10 of ArcGIS Desktop.

ArcPy has some great new features, especially if you use eclipse to program in python. It is intellasense capable, which makes programming nice and easy. It is also a well organized set of functions with libraries, class, functions, etc... Basically it follows OOP patterns.

What I don't like, is the case sensitivity. This can get annoying, since I'm a lazy programmer. Really, who has time to be pushing that shift key and another letter on the key board?


I think the future looks bright for ArcPy, but only time will tell.

Thursday, March 25, 2010

Visual Studios 2010 Release Date

The release date for Visual Studios 2010 is set for:

Monday, 12 April 2010

Mark it down

Tuesday, March 23, 2010

Reinstalling VS 2008

Here's what I think of the stupid people images on the VS 2008 install:
I put the I love Microsoft because apparently it makes some people warm and fuzzy.  Maybe they should improve the installer so it doesn't take 1/2 your work day.

Using Kernel Density

Has anyone ever been able to get the kernel density function to work in a python script?  It appears that the function does not honor the inputs, but I could be mistaken.  Post some code if you got it working.

The script I'm using is published to ArcGIS Server, and the kernel density if performed from the ArcToolbox, it returns the proper image, while the python call returns a black or blank tile, depending on how ArcGIS Server want to behave that minute. 

It's very frustrating because no errors are returned, and both the script and arctoolbox function work in desktop.

Wednesday, March 10, 2010

ArcGIS Explorer 1200 Released

A new version of ArcGIS Explorer (build 1200) is now available for download at:

If you've not installed ArcGIS Explorer before, you can run the system check utility or review the platform requirements before you install. If you are already using ArcGIS Explorer on the same machine as ArcGIS Desktop, please note that the uninstall may take a few minutes...

Find the Official Announcement Here.

Friday, March 5, 2010

What the Heck is *args and **kwargs in my Function?

Take the following code example:

Let's call this function:
c = Child()
You'll notice that method3() will not be called because our super() is passing in a variable gp, and it is expecting all classes to accept one parameter in the __init__(). 
A small change to your program can be done to fix this problem by using *args and **kwargs.
The *args is used to pass a variable-length argument list, and the **kwargs form is used to pass a dictionary object of variable length.
By modifying the class SomeClass' __init__() by adding *args and **kwargs, you can now have functions that doesn't need variables to just ignore the variables being passed for this function.

In the other Classes you should use either the *args or **kwargs for your parameters too.  You can check if the len() of the list is correct, and if so, assign the values.

Thursday, March 4, 2010

Singleton Exmple

Building off of my last post, I am going to post a singleton example that performs geographic functions.

1) Create your Singleton classHere there is a singleton class that will return the same instance of the object every time a specific class is called.
2) Create your class and have it inherit from Singleton

Now to use this, simply create a __main__ declaration, and create the object GeometryObject()

This gives you the output of:

Notice that GO and GO2 are the same exact object. This is what you want if you create a Singleton, only one instance of the object.

Singleton Pattern Design for Python

There are three categoris of OO Patterns:
  1. Creational - patterns that can be used to create objects
  2. Structural - patterns that are used to combine object and classes in order to build structured objects
  3. Behavioral - patterns that can be used to build computation and control the flow of data
Creational Example:

A Singleton is a way to ensure that you cannot create more than one instance of a class. A class attribute could be used to check the number of instantiations of the class.
The singleton patter requires a mechanism to access the singleton class member without creating a class object and a mechanism to persist the value of class members among class objects. The singleton pattern is implemented by creating a class with a method that creates a new instance of the class if one does not exist. If an instance already exists, it simply returns a reference to that object. To make sure that the object cannot be instantiated any other way, the constructor is made protected.
As a note: "The singleton pattern must be carefully constructed in multi-threaded applications. If two threads are to execute the creation method at the same time when a singleton does not yet exist, they both must check for an instance of the singleton and then only one should create the new one. If the programming language has concurrent processing capabilities the method should be constructed to execute as a mutually exclusive operation." ~From

Here are two examples of Singleton Patterns:

This will produce an output of:
Here is a second singleton implementation that returns the same instance of the singleton instead of throwing an error:

I would recommend starting to use Design Patterns in your ArcGIS Python code. With the coming of 10, it will be more important than ever to have code that conforms to standard coding practices.

The goal of any OO programming is the following:
  1. Genericity - is a technique to define parameters for a module exactly as you define parameters for a function thus making the module more general
  2. Flexibility - very difficult to achieve, but functions should be written as general as possible to allow for multiple data types
  3. Inheritance - is the ability in OO Programming to derive a class from another, either by extending it or specialize it
  4. Overloading - refers to the possibility for an operator or method to behave differently according to the actual data types of their arguments
  5. Polymorphism - is the possibility for something to have several forms.

Monday, February 22, 2010

Fun With Adding Fields

A common process that can be done multiple times during analysis is creating new feature classes. To strealine this process, I have developed a class that can create a feature class and add fields.

1). Create a python class and create the following Enum Classes

class SomeClass:

     def __init__(self, GP):

          self.GP = GP

    class FeatureType:



        POINT = "POINT"

    class AddFieldTypesEnum:

        TEXT = "TEXT"

        FLOAT = "FLOAT"

        DOUBLE = "DOUBLE"

        SHORT = "SHORT"

        LONG = "LONG"

        DATE = "DATE"

        BLOB = "BLOB"

        RASTER = "RASTER"

2). Add the following code below the class AddFieldTypesEnum

def CreateFeatureClass(self, workspace="in_memory", fileName="temp", FeatureType=FeatureType.POLYGON, SpatialReference="", Fields=[],overwrite=True):

        gp = self.GP

        if gp.exists(workspace + os.sep + fileName) == True and overwrite == True:

            if gp.overwriteoutput != 1:

                gp.overwriteoutput = 1

            #gp.delete(workspace + os.sep + fileName)

        elif gp.exists(workspace + os.sep + fileName) == True and overwrite == False:

            gp.adderror("Feature with name: " + fileName + " alread exists")

        if SpatialReference == "":

            desc = gp.describe(self.FC)

            SpatialReference = desc.SpatialReference

        gp.createfeatureclass(workspace, fileName, FeatureType, "","","",SpatialReference)

        if len(Fields) > 0:

            for field in Fields:

                gp.addfield(workspace + os.sep + fileName, field[0], str(field[1]))

        return workspace + os.sep + fileName


The class is ready to use

Here is a simple example:

import Arcgisscripting as Arc

gp = Arc.create(9.3)
myClass = SomeClass(gp)

print 'dah da'

Tuesday, January 19, 2010

Graphing in python

Ever want to graph your results and you don't want to use the Google API or some other API like that, well along comes MatPlotLib.

Before I continue, make sure you have the ESRI media just in case your geo-statistics fails because numpy 1.3.0 and above are not supported officially be ESRI.

You'll need 3 things:
Python - v2.5.4
Matplotlib -v0.99.1
numpy - v1.3.0

You can install each version over top the older versions, so there is no need to uninstall anything.

Once setup, you can now create graphs in python to compliment your geoprocessing data.

There are great examples of how to use Matplotlib on the website. For example, you can do histograms, box plots, etc.. Also, you can include graph items like legends.

Happy Coding

Wednesday, January 13, 2010

ArcGIS 9.4 changed to ArcGIS 10.0

ESRI announced today that the next release will change from 9.4 to 10. You can here the official announcement here. Enjoy

Monday, January 11, 2010

FDO Error Guide for ArcSDE

Sometimes you want to know more about an SDE error, and here is a guide to help you. Click this link to go to the ESRI FDO user guide.