Python and GIS Resources

Caitlin Dempsey


Find resources to web sites about Python scripting to use in GIS. Learn how to use Python to expand your geographic information system. Esri uses Python as its scripting language for ArcGIS and the language can be found in many open source GIS applications.   Also see: Learning Programming for GIS for general Python resources.

Python is a scripting language incorporated into many GIS software applications such as ArcGIS and QGIS and is used to automate geoprocessing tasks.  Python scripts are essentially a command-based script containing data types, statements, and functions that make up the geoprocessing instructions.  Python files are denoted with the .py file extension.

Using Python in ArcGIS

Within ArcGIS, there are two options for working with and running python scripts: directly within ArcMap using the python window, or within an  Integrated Development Environment (IDE) such as PythonWin.

Python can be run directly within ArcGIS by clicking on the Python button found on the standard toolbar.  By clicking the button, ArcMap’s python window opens.  The python window can be docked by dragging it to the toolbar or can be floated on top of ArcMap.  The python window is divide into two sections: the python prompt section and the help and syntax window.  The python prompt is found on the left side of the python window and this is the section where python prompts can be typed into or python scripts run.  The right side of the window provides information with syntax information that show up when a command is typed in on the left side.

To load a prewritten script into the python window, right click and select the “load” option from the menu.  Navigate to the folder where the python file is store and select.  Click the “open” button to add the script to the window.

To run a loaded script, hit the “enter” button on the keyboard twice.  The right side will now print out status updates on the running script.  Running a python script within ArcMap allows the user to see dynamically the results of the outputs as the script processes each geoprocessing step.

Python scripts for ArcMap processes can also be edited and run within an IDE.  IDE stands for Integrated Development Environment.  IDEs for python scripting include IDLE, PythonWin, PyScripter, and Wing.

For further learning materials, Esri has compiled a Python for ArcGIS page which provides a variety of Esri-based and individually created resources for learning python including a beginner’s guide, tutorials, and sample scripts.

Python Scripting for ArcGIS
Learn about this book from Esri Press that teaches experienced users of ArcGIS how to develop their programming skills using Python without the need for prior programming experience.

A Guide to the Python Universe for ESRI Users (PDF File)
Overview and guide for GIS users to Python by Howard Butler from Iowa State University.

Using Python in QGIS

QGIS is an open source GIS which incorporated python as a scripting option starting with release 0.9.  The PyQGIS cookbook provides a good introductory text on how python is used with the QGIS environment.  The QGIS blog also has a list of QGIS tutorials in Python.

QGIS Python Programming CookBook
Learn how to use Python to create dynamic maps in QGIS with this free preview chapter of QGIS Python Programming CookBook.

Open Source GIS and Python

Geoprocessing with Python using Open Source GIS
Structured  course outline by Chris Garrard of Utah State University with links to open source software, course slides, and data.

Geocoding toolbox for Python.  Provides support for six geocoders: Google Maps, Yahoo! Maps, Windows Local Live (Virtual Earth),, GeoNames, MediaWiki pages (with the GIS extension), and Semantic MediaWiki pages.

Python Cartographic Library
The Python Cartography Library, or PCL, is a package of modules for rendering GIS data from a variety of backends into maps. Open source.

Python and GIS 101
From Sean Giles’ blog.

Unofficial Python GIS SIG
Discussion group for GIS developers using Python with a focus on exchanging ideas and peer support.

Legacy GIS: Python for ArcView 3.x

Using Python with ArcView 3.x
Resources for using Python with ArcView 3.x software. Also contains links to Python examples and resources.

Python language support for ArcView 3.x software which allows you to embed Python within ArcView 3.x

Suggest a resource:
Photo of author
About the author
Caitlin Dempsey
Caitlin Dempsey is the editor of Geography Realm and holds a master's degree in Geography from UCLA as well as a Master of Library and Information Science (MLIS) from SJSU.

Free weekly newsletter

Fill out your e-mail address to receive our newsletter!

2 thoughts on “Python and GIS Resources”

  1. Please help me to fix the error. The end quotation.
    thank you

    Error line , quotation

    print “The freeway buffers have been created.”

    #Date Created: 09/14/2010
    # Purpose: Create a feature class of SDMTS trolly stops within 0.25 miles ( 1320 feet) of a freeway
    # Import Arcgis scripting module, create the Geoprocessor object, and specify the workspace and toolbox
    import argisscripting
    gp = arcgisscripting.create()
    gp.workspace = “C:\Temp\nadeem_python\SanDiegoData\SanDiego.gdb”
    gp.toolbox = “analysis”

    # Buffer freeways by 0.25 milrd (1320 feet).
    gp.buffer(“freeways”, “Freeway_Buffers”, 1320)
    print “The freeway buffers have been created.”
    # Intersect trolley stops with freeway buffers to output stops within 0.25 miles ( 1320 feet) of a freeway
    gp.Intersect_analysis(“trolleystop ; Freeway_Buffers” , “StopsNearFreeways”)
    print “The intersect was completed.”

  2. Hi, I wonder if you can help me with something I want to progam. So:
    How can I write a program using python, that calculates some morphometric and drainage indexes using numeric attributes in the attribute table with ArcGIS?

    The data I have in my table are area and perimeter of the basin, and channel order of the watercourses (number and km of each order).

    For example, I need to calculate the Relationship of bifurcation with this formula: RB=Nu/Nu+1 (Nu – considered channel order; Nu+1 – channel order immediately ) above the considered one).

    So, I want to create a program that would be able to get the right value from the attribute table (in ArcGIS) and run with the formula. How can I do that?


Comments are closed.