Taking advantage of Python in ArcGIS

May 12, 2011 by  
Filed under Programming

Python is the next big programming language for ArcGIS. With the addition of the ArcPy module in ArcGIS 10 there is so much more that can be done with Python. In previous version of ArcGIS VBA made is easy to customize the interface and basic processes. At the release of ArcGIS 10.1 VBA will no longer be supported.

So now that Python has been proven as a great tool, who do you begin.  Sure you can start with www.python.org but the is so much information is on the site you are not sure where to start.  Well, there is a endless source for finding code samples.  Search the ArcGIS Help Library to find the tool you would like to use.  Then scroll to near the bottom and there is a code sample to use in the Python Window or as a stand-alone script for that particular tool.

Another  method that saves a lot of time is to use ModelBuilder and create a model for the desired process.  Once you get the model working then export the model as a script (Model > Export > Script).  The output of this export provides a great starting point for expanding on the python code to get the task accomplished.

Here is a quick example from the Buffer tool help document:

Python Widnow Script
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.Buffer_analysis("roads", "C:/output/majorrdsBuffered" "100 Feet", "FULL", "ROUND", "LIST", "Distance")

Stand-alone Script
# Name: Buffer.py
# Description: Find areas of suitable vegetation which exclude areas heavily impacted by major roads
# Author: ESRI

# import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = “C:/data/Habitat_Analysis.gdb”

# Select suitable vegetation patches from all vegetation
veg = “vegtype”
suitableVeg = “C:/output/Output.gdb/suitable_vegetation”
whereClause = “HABITAT = 1″
arcpy.Select_analysis(veg, suitableVeg, whereClause)

# Buffer areas of impact around major roads
roads = “majorrds”
roadsBuffer = “C:/output/Output.gdb/buffer_output”
distanceField = “Distance”
sideType = “FULL”
endType = “ROUND”
dissolveType = “LIST”
dissolveField = “Distance”
arcpy.Buffer_analysis(roads, roadsBuffer, distanceField, sideType, endType, dissolveType, dissolveField)

# Erase areas of impact around major roads from the suitable vegetation patches
eraseOutput = “C:/output/Output.gdb/suitable_vegetation_minus_roads”
xyTol = “1 Meters”
arcpy.Erase_analysis(suitableVeg, roadsBuffer, eraseOutput, xyTol)

ArcMap Erase Tool – Video Tutorial

March 31, 2009 by  
Filed under ArcToolbox, GIS Tips, Videos

The erase tool can help save a ton of editing time.  Its main purpose is to perform an overlay analysis.  The most common tool used for this is Clip, but output of this tool is just the overlap portion of your feature class.  To be able to carry out the opposite of this, you must use the Erase Tool.  The Erase Tool will remove the overlapped portion from the feature class and leave a shape that resembles a doughnut.

Although this demonstration show you how to use the erase tool at the ArcInfo license level, you can also do this at the lower levels such as ArcView or ArcInfo.  James Fee provided a great resource.  You can find the link at the bottom of this page.

To use the Erase Tool:

  1. Open ArcToolbox -> Analysis Tools -> Overlay ->Erase Tool
  2. Fill in Dialog Box
    • Input Features
    • Erase Features
    • Output Feature Class
  3. Click OK

Note: Videos are broadcast through youtube.com.  Some browsers may block this content.

Download the video to your computer: ArcMap Erase Tool

If you do not have access to the ArcInfo software license, you can also learn how to Perform an Erase in ArcView.

Buffering Features in ArcGIS

March 23, 2009 by  
Filed under Analysis, GIS Tips

Buffering is a useful technique in GIS.  It is referred to as a proximity tool in ArcToolbox.  It can be applied to points, polylines, and polygons.  Some valuable uses include: Right-of-ways, Tree diameters, Sex Offender Exclusion Zones, Study Areas, Impervious Surfaces from a Centerline, Evacuation Zone of Weather Events,  etc.

To perform a single distance buffer:

1. Open the Buffer Tool – ArcToolbox >Proximity >Buffer

buffer1

2. Fill Inputs

  • Input Features (Points, Polylines, Polygons)
  • Output Feature Class
  • Linear Unit (Distance of Buffer) This can also come from a attribute field value.

The remaining entries are optional.

buffer2

The new output layer from the buffer will be added to the map (circles around red dots).

buffer3a

To perform a multiple distance buffer:

1. Open the Multiple Ring Buffer Tool – ArcToolbox >Proximity >Multiple Ring Buffer

buffer6

2. Fill Inputs

  • Input Features (Points, Polylines, Polygons)
  • Output Feature Class
  • Enter each buffer distance.

The remaining entries are optional.

buffer4

The new output layer from the buffer will be added to the map.  Notice that I have used the dissolve option.  This causes the buffer rings to dissolve based up distance.

buffer5

ArcToolbox Batch Tool Process

October 23, 2008 by  
Filed under ArcGIS, ArcToolbox, GIS Tips, Videos

Have you ever needed to run an ArcToolbox tool multiple times?  Here is an illustration for adding multiple fields to multiple shapefiles within one simple process.  The demonstration uses the ArcCatalog interface and uses the batch process to carry out the desired task.

Note: Videos are broadcast through youtube.com.  Some browsers may block this content.

Streamline Workflow with Model Builder

September 10, 2008 by  
Filed under ArcGIS, ArcToolbox, GIS Tips

There are many tasks that we preform over and over each day in ArcMap.  We go through the same routine without thought of there actually being an easier way.  These repetitious actions can actually be modeled to make like easier and more productive.  ArcGIS provides a excellent tool called Model Builder.  Model Builder is based out of ArcToolbox.  By following just a few simple steps, you can be on your way to an easier, more productive work flow.

To create a model:

1. Open ArcToolbox by clicking on the red toolbox at the top of ArcMap or ArcCatalog.

Read more