Create List of Unique Table Values using Python for ArcGIS Analysis

Necessity is the mother of invention and as of late, this means I have learned to use Python with ArcGIS. Early on, an issue I ran across was needing a list of all unique values in a field to be used in further analysis. Unfortunately there is not a pre-built method for this. Still, it did not take long to figure out the following function to accomplish this.


# Return list all permutations of field in input feature class or table
def getValueList (inputTable, field):

    valueList = [] # array to hold list of values collected
    valueSet = set() # set to hold values to test against to get list
    rows = arcpy.SearchCursor(inputTable) # create search cursor

    # iterate through table and collect unique values
    for row in rows:
        value = row.getValue(field)

        # add value if not already added and not current year
        if value not in valueSet:
            valueList.append(value)

        # add value to valueset for checking against in next iteration
        valueSet.add(value)

    # return value list
    valueList.sort()
    return valueList

Hopefully if you have run across this problem, you find this useful. If you know of a better method, please comment and let me know!

Iranian Ballistic Missile Range

Being a GIS geek, when reading the New York Times and The Economist on my iPad, current events in the Middle East always get me to thinking about how the geography all fits together. During the last few weeks and especially the last few days, tensions with Iran are at an all time high. Out of curiosity, I decided to further investigate using the toys at work, primarily ArcGIS 10 for Desktop, specifically the Multiple Ring Buffer geoprocessing tool.

To perform this analysis, first I need to establish what I am interested in, then find the data, prepare the data, analyze the data and finally output the results. The first part is easy, I know what I want to investigate. What areas are affected by the capabilities of Iran’s missile program? Continue reading

Green Narrows Trail Map

Saturday 05 Nov 2011 at high noon the first racer will leave the eddy above Bride of Frankenstein on the Green River in North Carolina just outside of Hendersonville and head into the Narrows. Less than six minutes later, after descending over 500 feet through close to 10 class V rapids, the first racer will have finished the course. There rapids include friendly names such as Frankenstein, Go Left and Die, Gorilla and Scream Machine.

Every minute for the next few hours, another racer will start. All the safety is voluntary. There is no entry fee, no race sponsors and no prize money. The hike in to watch is a two mile walk ending with a quarter mile scramble dropping over 400 feet down into the gorge. Yet there will be over 200 racers and over 1,500 spectators for the Green Race, arguably the most prestigious extreme race in the country.

For the paddlers, getting there is not very difficult. However, for many of the spectators, this will be their first time trying to figure out how to get into the gorge. Although there is the generally accepted regular route down the Pulliam Creek trail, there are also other alternatives for getting into the gorge provided you do not mind walking a little further.

If interested in these other routes, want to figure out driving directions, or want to figure out another way in and out of the gorge, hopefully this map can be of assistance.


View Larger Map with ability to Print

Learn LiDAR Principles

LiDAR, if you work in GIS and pay any attention to digital elevation model (DEM) data, you have heard of LiDAR. Although many people know it has something to do with bouncing light off terrain and it is very accurate, many times knowledge ends there. Fortunately there is an outstanding resource for learning about LiDAR.

The USGS put together this very well organized resource. Although it focuses on applications of LiDAR for natural resources, over 75 percent of the lesson focuses on data collection methods, factors of accuracy and other technical aspects of LiDAR applicable to anybody who uses LiDAR data. Fully narrated with animated visual aids it is a great resource, one I highly recommend.

Run ArcGIS Models as Scheduled Tasks

ModelBuilder in ArcGIS Desktop is great. It enables the functionality of scripting without needing to know scripting. If you know how to use tools in ArcToolbox, typically in less than 30 minutes you can start automating redundant and long multi-step workflows using ModelBuilder. When it comes to taking this automation one step further, to have the computer automatically perform this workflow at a scheduled time, this is where difficulty can arise.

Windows cannot run a model as a scheduled task. Windows can however, run a Python script as a scheduled task. A Python script can run a model as a scheduled task. Using a three line Python script, a model can effectively be run as a scheduled task. The scheduled task calls the Python script and the Python script calls the model. The script looks like this…

import arcpy
arcpy.ImportToolbox(r"C:\pathToToolbox\Toolbox.tbx", "TBX")
arcpy.Model_TBX() <a href="http://joelmccune.com/2011/05/05/run-models-as-scheduled-tasks/#more-116" class="more-link">Continue reading <span class="meta-nav">&rarr;</span></a>

Esri Disaster Response

Today I received an email highlighting the assistance Esri is standing by ready to offer for those assisting with disaster response. This email included a link directly to the Esri Disaster Response Webpage. Types of assistance include everything from software to data and even consulting. Most all types of disasters are included, wildfires, earthquakes, flooding, hurricanes and cyclones, spills and volcanic eruptions.  All you have to do is ask. Nothing is guaranteed, but if you have a need, you never know unless you ask!

Creating Map Books Using Data Driven Pages

With the release of ArcGIS Desktop 10 comes the ability to create data driven pages. Data driven pages facilitate creation of multiple maps from a single layout. This means the layout only has to be created once. Referencing a layer in the map, data driven pages moves from one feature to the next, creating a new page for every feature. Once created, these pages can be printed or exported individually or collectively.

Believing experience is the best teacher, the rest of this post is a tutorial of how to use data driven pages. To be able to complete the tutorial, you will need a copy of ArcGIS Desktop 10 at any license level (ArcView, ArcEditor or ArcInfo). The data will be downloaded directly from ArcGIS Online as a map package. With the data in hand, you will create data driven pages, a page definition query, an extent indicator in a locator map and add dynamic text to the layout. Additionally, I am assuming familiarity with ArcGIS Desktop. As a result, details of tasks typical to using ArcGIS Desktop are not detailed. Only the unique steps of creating data driven pages are detailed.

Continue reading

Lat/Long Table to Feature Class using Modelbuilder

Going from a flat table with latitude and longitude to a point feature class in ArcGIS Desktop using ModelBuilder can, at first, be a somewhat daunting task. My first attempt at this took most of a morning. Accomplishing this requires using the Make XY Event Layer and Copy Features Tool together as shown in the image below.

The reason for needing both of these tools is Make XY Event Layer only creates an event layer, a representation of the locations stored in RAM. The data is not permanent yet. To make the data permanent as a feature class, this is what Copy Features does. Hopefully this makes your life easier than my own, so you do not spend the better part of a morning trying to figure this out.