53
GIS Tools for Analyzing Dynamic Landscapes April 2011 US-IALE 2011 [email protected] Page 1 of 53 GIS Tools for Analyzing Dynamic Landscapes Workshop U.S. Regional Association of the International Association for Landscape Ecology 2011 Symposium Charlene Nielsen

GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 [email protected] Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 1 of 53

GIS Tools for

Analyzing Dynamic Landscapes

Workshop

U.S. Regional Association of the

International Association for

Landscape Ecology

2011 Symposium

Charlene Nielsen

Page 2: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 2 of 53

Abstract

Gain proficiency with existing custom

Geographic Information Systems (GIS) tools –

plus learn to build your own – for analyzing

landscapes spatially and temporally. This is an

applied workshop on GIS as leveraged in

landscape ecology and conservation biology

research by collaborators at the Alberta

Cooperative Conservation Research Unit

(ACCRU), University of Alberta. The topics

covered include landscape characterization

(vegetation indices, satellite image

classification, and change detection),

management unit delineation (watersheds and

home ranges), scenario modelling (creating and

shifting landscape features), temporal and

proximity analyses of habitat (date matching,

cost paths, and network distances), and

calculating the spatial map from regression-

based equations (model calculation). Although

specific applications formed the basis of tool

development they are flexible and easily

modifiable: the open source of the ModelBuilder

framework and the Python language allows

landscape ecologists to adapt the tools to help

answer alternative issues. Note: Course

participants are expected to be familiar with

ESRI ArcGIS Desktop.

Venue Portland State University Science Building 2, Room B1-82

Date Sunday April 3rd, 2011 8:00 a.m. – 4:00 p.m.

Based on Charlene Nielsen‟s development of

research solutions and educational materials on

GIS in ecology at the University of Alberta

http://www.biology.ualberta.ca/facilities/gis and

supported in part by the Alberta Cooperative

Conservation Research Unit (ACCRU)

http://www.biology.ualberta.ca/accru

Page 3: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 3 of 53

Contents

Introduction ................................................... 4

Overview of GIS analysis .............................. 5

Acknowledgements ....................................... 6

Data ................................................................ 6

ACCRU tools .................................................. 7

Sample questions .......................................... 8

1 Question 1 ............................................. 10

1.1 Create random locations ..................... 12

1.2 Cost surface ........................................ 13

1.3 Automatic linear features .................... 14

1.4 Update raster landscape ..................... 14

1.5 Tabulate areas .................................... 15

1.6 Custom tools inspection ...................... 16

2 Question 2 ............................................. 17

2.1 Equal sized watersheds ...................... 18

2.2 Vegetation indices............................... 22

2.3 Zonal change ...................................... 23

3 Question 3 ............................................. 29

3.1 Classification of landcover .................. 31

3.2 Extract landscape rasters with *.fbt ..... 34

Extra credit ................................................... 41

References ................................................... 43

ModelBuilder quick guide ........................... 45

Python scripting quick guide ...................... 49

Page 4: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 4 of 53

Introduction

This is an applied workshop on Geographic Information Systems (GIS) as leveraged in landscape ecology and conservation biology research at the University of Alberta. It involves versatile tools for landscape characterization, management unit delineation, scenario modelling, temporal and proximity analyses of habitat, and the calculation of spatial habitat maps from regression-based models.

Note that no statistical modelling is actually

covered since this is a spatial course on developing the landscape layers (before and after) for use in such endeavours.

Broad-scale North American data are used for the examples, but the tools can be adapted to a wide diversity of research. Keep in mind that alternate tools/methods than what are presented here are available and potentially better suited for similar and additional specialized tasks.

However, the focus of this particular workshop is to expand your command of the built-in tools for ESRI ArcGIS 9.3 along with the freely

transferable methods of working with the ModelBuilder and provided custom script tools from open source Python.

ESRI © 1999-2010, Environmental Systems Research Institute

Python © 1990-2010, Python Software Foundation

Page 5: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 5 of 53

Overview of GIS analysis

The hands-on guided exercises of this workshop are concerned solely with step 4 of the general steps of a GIS-based analysis as outlined below:

1. Identify your objective and determine the methods needed; e.g. how has the landscape changed between time periods? classification algorithm? how to extract characteristics (simple

proportions or landscape metrics)? It is often helpful to fit these methods that visualize the real world to the product needed – i.e. outline a cartographic model to make your workflow more efficient

2. Assemble data needed to prepare the spatial database; e.g. base data, satellite imagery

3. Process existing data to get your „data ducks‟ all lined up in a row; e.g. conversion, mosaicking, projection, extraction

4. Perform the analyses by using built-in tools or developing your own; e.g. ModelBuilder and/or Python scripting

5. Interpret and assess the results and prepare for presentation; e.g. export tables, map layouts, graphs

Get started at the „Sample questions‟ section.

This is where you learn about the various

analytical methods to be covered and set up

your own custom toolbox.

Page 6: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 6 of 53

Acknowledgements

The following people: Scott Nielsen, Erin Kelly,

Seth Cherry, Jodie Pongracz, Vicki Sahanatien,

Brett Scheffers, Rebecca Rooney, Cameron

Aldridge, Kyle Knopff, Evelyn Merrill, Jacqui

Frair, Barry Robinson, Nick Pilford, Lori

Holmstol, Kerri Lappin, Simon Slater, Chris

Carli, Kim Dawe, and hundreds of students,

faculty, and colleagues associated with ACCRU

have provided many interesting challenges and

inspirations for the GIS solutions shared here.

ESRI‟s ModelBuilder and Python-infused

ArcGIS Desktop in conjunction with all the

talented corporate and public folks associated

with the following websites:

http://support.esri.com

http://forums.esri.com

http://forums.arcgis.com

are deemed invaluable for developing the

solutions in analyzing conservation landscapes.

All datasets used in this workshop are publicly

available with no limitations. Refer to the

sections on „Course data‟ and „References‟

below for access to the available data.

Data

All data are provided in the dynaland folder.

The available data for each question number in

the „Sample questions‟ are contained inside a

self-named folder. See the „References‟

section to access the websites for the freely

available spatial data used in this short course.

Question Study Area Year(s)

1 Montana-Alberta 2005

2 Lake Superior 2007-2010

3 Alaska-Yukon 1994-2009

Page 7: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 7 of 53

ACCRU tools

The „Sample questions‟ are modelled after

using and creating custom GIS tools as found in

ACCRU Tools. This toolbox for ArcToolbox

contains custom, ever-evolving tools created to

answer ecological questions posed by

researchers of the Alberta Cooperative

Conservation Research Unit (ACCRU) at the

University of Alberta. Several generic utilities

are also included to help make data processing

and other workflows more efficient.

DOWNLOAD the toolbox and files from here:

www.biology.ualberta.ca/facilities/gis/?Page=3063

INSTALL by unzipping the folder to the local

drive and in ArcToolbox 9.3 right-click to Add

Toolbox, navigate to the local directory, select

the ACCRU Tools.tbx file, and click Open.

It is recommended that the majority of the

analyses be performed by accessing ArcToolbox

via ArcCatalog (this will be faster because there

is no redraw or screen refresh needed as in

ArcMap). Also, for each new question set the

global ArcToolbox environment to the provided

empty WORK folder.

If working within ArcMap, note that some of the

tools do not allow direct input from the layer in

the map – in these cases examine the layer

properties to learn the directory path(s) of the

data required by the tool then navigate to the

location using the browse button (open folder

icon).

View the tool Help side bar for details and tips

on all the tool parameters!

Page 8: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 8 of 53

Sample questions

The following examples are provided as a guide

in choosing and creating the set of tools needed

for analyzing landscapes. It is more useful to

learn by doing (answering questions through

hands-on methods) rather than by lecture

(listening to the theory of how to do so).

Existing built-in ArcGIS geoprocessing tools are

used as needed, but automating and extending

their functionality through ModelBuilder and

Python are based on „ACCRU tools‟.

Question 1: How would simulated development

affect wildlife habitat?

Study Area: Montana-Alberta

Available Data: landcover raster, existing

development, species range

Workflow:

Create random points

Cost surface

Automatic linear features

Update raster landscape

Tabulate areas

Question 2: How do sub watersheds differ in

vegetation characteristics through time?

Study Area: Lake Superior

Available Data: digital elevation model,

multispectral imagery

Workflow:

Equal sized watersheds

Vegetation indices

Zonal change

Question 3: How have wildfires changed the

forested landscape patterns over the years?

Study Area: Alaska-Yukon

Available Data: multispectral imagery, units

Workflow:

Classification of landcover

Extract landscape rasters with *.fbt

Page 9: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 9 of 53

First set up your custom toolbox. This can be

done in a number of ways, but the following is

good practice because (a), all that is needed for

the toolbox is contained in a single folder, and

(b) using ArcCatalog gives you direct control

over where the toolbox is stored.

Set up a custom toolbox in ArcCatalog

1. Click START >>> PROGRAMS >>>

ARCGIS >>> ARCCATALOG

2. In the catalog tree, navigate to

c:\temp\dynaland

3. Right-click the directory name \dynaland

and choose NEW >>> FOLDER

4. Rename the folder: ADL_Tools

5. Right-click the new folder name \ADL_Tools

and choose NEW >>> TOOLBOX

6. Rename the toolbox: ADL Tools.tbx

7. Inside the \ADL_Tools folder, create a

subfolder named Scripts

For full details on setting up a tool share, see:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?TopicName=A_structure_for_sharing_tools

KEY:

All text you

must type

yourself is

bolded

Page 10: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 10 of 53

1 Question 1

How would simulated development affect

wildlife habitat?

A common management strategy for natural

resources long-term planning and decision-

making is scenario planning, where the

objective is to examine several possible future

landscapes and determine which would be

most beneficial (or have the least impact).

Climate change models are perhaps the most

commonly recognized use of scenario planning,

but are rather complex. The simplified example

here stems from increased pressures for

development of renewable energy sources,

specifically wind energy. Other common

examples in landscape ecology that would use

a very similar approach to this question are

projecting impacts from oil and gas

development or forest harvest plans.

The eastern foothills of the Rocky Mountains

have some of the highest wind potential in

North America and although acting as a

potential solution towards moving away from

fossil fuel-based sources of energy, wind

developments do have ecological impacts.

This question will develop two simple wind

development scenarios and compare how these

potentially affect wildlife habitat. Existing and

custom tools are used to make the complex

analytical process more efficient. The ACCRU

tools that are demonstrated here are then

scrutinized to set the stage for getting you

started at building your own tools.

Set up ArcMap and the geoprocessing

environments

1. Click START >>> PROGRAMS >>>

ARCGIS >>> ARCMAP

2. Start using ArcMap with a new empty map

3. Click the ADD DATA button

Page 11: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 11 of 53

4. Navigate to your working directory; i.e. the

\dynaland\question1\shapes folder and

double click to open

5. Hold the CTRL key on the keyboard and

select the following shapefiles:

anu_50_we_dos, boundary, extent, place,

power, road, and wind_class

6. Click ADD

7. ADD DATA from the \question1\rasters

folder: landcover2005.img and srtm.img

8. Take a few moments to symbolize each

data layer and open attribute tables to help

you understand what you have to work with

(see the References section to view

websites for metadata)

9. IMPORT SYMBOLOGY for anu_50_we_dos

using the provided wind_energy.lyr file

10. Click TOOLS >>> EXTENSIONS and make

sure to check on SPATIAL ANALYST

11. If necessary, SHOW ArcToolbox

12. Right-click the name for ArcToolbox and

click ADD TOOLBOX

13. Navigate to your working directory; i.e. the

\dynaland\ACCRU_Tools folder and select

ACCRU Tools.tbx

14. Click OPEN

15. Similarly, right-click ArcToolbox to ADD

TOOLBOX for \ADL_Tools\ADL Tools.tbx

16. Right-click the name for ArcToolbox and

click ENVIRONMENTS

17. Specify the following General Settings:

Current Workspace = \question1\work

Scratch Workspace = \question1\work

Extent = Same as layer extent

Snap Raster = landcover2005.img

18. Specify the following Raster Analysis

Settings:

Cell Size = Same as layer landcover.img

Mask = extent

19. Click OK

20. Click FILE >>> DOCUMENT PROPERTIES

>>> DATA SOURCE OPTIONS

21. Click „Store relative path names…‟

22. Check beside „Make relative paths the

default…‟

23. Click OK twice

Page 12: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 12 of 53

24. Click FILE >>> SAVE as question1.mxd in

your \question1\work folder

1.1 Create random locations

Generate random points for new wind farms.

The wind_class layer was previously

reclassified as: high (H), moderate (M), and low

(L) from the anu_50_we_dos (Canadian Wind

Energy Atlas) and will provide the basis of a

stratified random design.

1. Open DATA MANAGEMENT TOOLS >>>

LAYERS AND TABLE VIEWS >>> SELECT

LAYER BY ATTRIBUTES on the wind_class

layer where “CLASS” <> „L‟ – this will first

create the second scenario that requires 20

total points with 10 each in the high and

medium wind energy classes

2. Open DATA MANAGEMENT TOOLS >>>

FEATURE CLASS >>> CREATE RANDOM

POINTS tool to generate new wind farm

locations with the following parameters:

Output Location: \question1\work

Output Point Feature Class:

windfarms2

Constraining Feature Class: wind_class

Number of Points (Long): 10

Minimum Allowed Distance (Linear unit):

10000

3. Click OK

4. OPEN ATTRIBUTE TABLE for both

windfarms2 and wind_class – notice that the

“CID” field corresponds to the “FID” field

from the wind_class layer; thus, “CID” = 0

matches “CLASS” = „H‟

5. Open ANALYSIS TOOLS >>> EXTRACT

>>> SELECT tool to separate out the high

class points using the following parameters:

Input Features: windfarms2

Output Feature Class:

\question1\work\windfarms1.shp

Expression: “CID” = 0

6. Click OK

7. CLEAR SELECTED FEATURES (there are

at least four ways to do this; which one do

you prefer?) and CLOSE any tables

Page 13: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 13 of 53

1.2 Cost surface

Create a cost surface to represent powerline

construction difficulty. Take a moment to think

about what will make a reasonable cost surface

(i.e. a layer that represents increasing cost of

travelling through each cell) for constructing

new powerlines in the eastern foothills area.

1. Review some handy help files:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?Topic

Name=Understanding_cost_distance_analysis

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?Topic

Name=How Cost functions work

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=65

17&pid=6505&topicname=Slope

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=64

98&pid=6491&topicname=Reclassify

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=64

63&pid=6460&topicname=Weighted_Sum

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?Topic

Name=Spatial_Analyst_Tutorial

2. Create a SLOPE surface in degrees from

the digital elevation model srtm.img; name it

slope_srtm and save it to the \work folder

3. RECLASSIFY values to a standardized

scale of 1 to 10 using a classification

scheme that makes sense (i.e. higher

slopes have values closer or equal to 10);

name it slope10 and save it to the \work

folder

4. RECLASSIFY landcover2005.img to create

a standardized land surface by assigning

water/snow/ice classes = 10 (hopefully,

impeded), all forest classes = 5 (due to

higher construction costs), urban = 3

(remember „nimby‟), and everything else = 1

(relatively cheap to construct a powerline

through); name it land10

5. Perform an OVERLAY >>> WEIGHTED

SUM to combine (using equal or unequal

weightings depending on which input you

decide is more important) the two

standardized rasters into the cost surface;

name it cost and save it to the \work folder

Page 14: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 14 of 53

1.3 Automatic linear features

Create linear features for simulating new

transmission lines.

1. Use ACCRU TOOLS >>> 6.1.2 Automatic

Linear Features tool for each scenario to

map out the best routes for new

transmission lines that connect the

proposed wind farms to existing power lines

2. Click the SHOW HELP button and read the

side panel information after clicking each

parameter – this will offer clues on how to

use the tool and what data and values are

needed to run this handy tool that

automates all the cost distance and least

cost path functions

3. The following provides the required

parameters (remember to repeat for each

scenario):

Source Data: power

Destination Data: windfarms1

[windfarms2]

Destination Unique ID Field: FID

Cost raster: cost

Output Workspace: \question1\work

Output Features Name: newlines1.shp

for first scenario [newlines2.shp for

second scenario]

4. Click OK (and repeat for each scenario)

5. ADD DATA to visualize both newlines1 and

newlines2

6. Once both scenarios have new power lines

generated for them, take a moment to view

the tool – it is a ModelBuilder tool. Right-

click and EDIT to view the individual cost

tools and settings used.

1.4 Update raster landscape

Convert features to raster and overlay on

landcover.

1. Use ACCRU TOOLS >>> 6.2.1 Update

Raster Landscape tool for existing power

lines plus the two scenarios to map out the

baseline and impacts (scenario1 and

scenario2) on the landscape – assume that

Page 15: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 15 of 53

a 250 m cell size isn‟t over exaggerating the

buffer effect of the new power lines – there

will be a total of three updated landscapes

2. The following provides the required

parameters (repeat for each scenario):

Input Features: power [newlines1,

newlines2]

Raster Value: -999 [20, 20] – same

value from baseline for scenario

conversion, which should be 20!

Input Base Raster: landcover2005.img

[baseline, baseline] – update existing!

Output Workspace: \work

Output Name for Updated Raster:

baseline [scenario1, scenario2]

3. Click OK (yes, you must navigate to the

\work and \rasters directories to select the

required input files – the tool does not work

with layers in the map document)

4. ADD DATA to view baseline, scenario1, and

scenario2 (you may also need to reset the

data source for the newlines*, if a red

exclamation mark appears beside it in the

table of contents – a quirk with the tool)

5. You may want to turn off all other layers,

open the attribute table for each updated

raster and interactively select the last class

row to highlight for better visualization

1.5 Tabulate areas

Tabulate landcover/habitat areas by bat range.

1. ADD DATA: from \question1\shapes folder

select all myotis_* layers and click ADD

2. Use SPATIAL ANALYST TOOLS >>>

ZONAL >>> TABULATE AREA for the

myotis_* layers on each of the 3 updated

raster landscapes, for 9 total output tables

3. Use this output table naming convention:

Prefix: pattern specgenu; e.g. myotcili

Suffix: „_b‟ (baseline) or „_1‟ or „_2‟

(scenario) – NO extension needed

4. Take advantage of Batch processing:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?id=752&pid=749&topicname=Using_the_batch_gri

d_control

Page 16: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 16 of 53

5. Open ACCRU Tools >>> 1.2.1 MERGE

WITH FILENAME and specify the following:

Input Workspace: \question1\work

Geometry Type: INFO

New Field Name: Source

Output File Name:

\question1\work\merge_tabareas.dbf

6. Click OK

7. Open ACCRU Tools >>> 1.3.1 EXPORT TO

CSV and specify the following parameters:

Input Data: merge_tabareas.dbf AND

the landcover2005.img (this attribute

table will help you reference the

VALUE_X heading of merge_tabareas)

Output Folder: \question1\work\tables

(create a new folder and highlight it)

8. Click OK

NOTE: There have been a lot of assumptions

and oversimplification with these scenarios, but

you now have the general idea and skills

needed to apply scenario planning to your own

projects and other future work.

But for now, let‟s take a closer look at the

custom tools used to automate and make all the

scenario analyses quick and possible.

1.6 Custom tools inspection

1. In ArcToolbox ACCRU Tools, right-click on

each tool and click EDIT to view the

ModelBuilder diagram or the Python code:

6.1.2 Automatic Linear Features

6.2.1 Update Raster Landscape

1.2.1 Merge With Filename

1.3.1 Export to CSV

2. CLOSE all when done

Next, go to the „ModelBuilder quick guide‟

and then the „Python scripting quick guide‟ to

get acquainted (or refreshed) with creating tools

via ModelBuilder and Python programming,

before working through the next landscape

research questions where you will build the

custom tools yourself!

Page 17: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 17 of 53

2 Question 2

How do sub watersheds differ in vegetation

characteristics through time?

The sub watershed is a convenient

management unit for many analyses in natural

resources and ecosystem-based studies.

Vegetation indices are standard practice

measures for tracking phenology and

landcover/landuse changes. Built-in GIS tools

are extended to automate each of these tasks

and combine them to help analyze dynamic

landscapes at the sub watershed level, making

them applicable to any study area.

This question will develop methods for

addressing vegetation characteristics

surrounding Lake Superior – a watershed that

is commonly studied for a variety of reasons.

Set up ArcMap and the geoprocessing

environments

1. Click START >>> PROGRAMS >>>

ARCGIS >>> ARCMAP

2. Start using ArcMap with a new empty map

3. Click the ADD DATA button

4. Navigate to your working directory; i.e. the

\dynaland\question2\shapes folder and

double click to open

5. Hold the CTRL key on the keyboard and

select the following shapefiles: boundary,

lake and watershed

6. Click ADD

7. ADD DATA from the \question2\rasters

folder: srtm250.img

8. Take a few moments to symbolize each

data layer and open attribute tables to help

you understand what you have to work with

(see the References section to view

websites for metadata)

9. Click TOOLS >>> EXTENSIONS and make

sure to check on SPATIAL ANALYST

10. If necessary, SHOW ArcToolbox

Page 18: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 18 of 53

11. Right-click the name for ArcToolbox and

click ADD TOOLBOX

12. Navigate to your working directory; i.e. the

\dynaland\ACCRU_Tools folder and select

ACCRU Tools.tbx

13. Click OPEN

14. Similarly, right-click ArcToolbox to ADD

TOOLBOX for \ADL_Tools\ADL Tools.tbx

15. Right-click the name for ArcToolbox and

click ENVIRONMENTS

16. Specify the following General Settings:

Current Workspace = \question2\work

Scratch Workspace = \question2\work

17. Click OK

18. Click FILE >>> DOCUMENT PROPERTIES

>>> DATA SOURCE OPTIONS

19. Click „Store relative path names…‟

20. Check beside „Make relative paths the

default…‟

21. Click OK twice

22. Click FILE >>> SAVE as question2.mxd in

your \question2\work folder

2.1 Equal sized watersheds

The hydrology toolset that comes with Spatial

Analyst contains all the building blocks needed

to delineate drainage areas or watersheds

based on topography (i.e. a digital elevation

model). The standard watershed tool requires

pour point data, but the following approach

allows the landscape to be divided up in to

approximately equal-sized sub watersheds,

using a threshold value, within the extent of the

input elevation layer.

First, you must perform the preliminary steps of

filling the elevation raster and calculating flow

direction and flow accumulation.

1. In ArcToolbox, click ACCRU TOOLS >>>

3.1.3 WATERSHED INPUTS

2. The following provides the required

parameters:

Input DEM: srtm.img

Output Workspace: \question2\work

3. Click OK

Page 19: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 19 of 53

4. While the custom tool runs, view the same

tool in EDIT mode in ArcCatalog to examine

how it was constructed. Right-click the tool

name and click EDIT: the Fill, Flow

Direction, and Flow Accumulation tools

have been connected in ModelBuilder with

the necessary parameters exposed.

5. Read the information on hydrology tools,

such as Fill, Flow Direction, Flow

Accumulation, and Watershed in the help:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?TopicName=Hydrologic_analysis_sample_applicati

ons

6. Especially note the ArcGIS documentation

indicating “A threshold can be specified on

the raster derived from the Flow

Accumulation tool; the initial stage is

defining the stream network system. This

task can be accomplished with the Con tool

or using Map Algebra. An example of Con is

newraster = con(accum > 100, 1). All cells

with more than 100 cells flowing into them

will be part of the stream network.”

7. CLOSE the model and return your focus to

ArcMap

8. In ArcToolbox, locate the ADL Tools toolbox

9. Right-click the name for ADL Tools and click

NEW >>> MODEL

10. Move the Model window so you can see

both it and ArcToolbox

11. Expand ArcToolbox >>> SPATIAL

ANALYST TOOLS >>> CONDITIONAL

12. Expand ArcToolbox >>> SPATIAL

ANALYST TOOLS >>> HYDROLOGY

13. Drag and drop CON on to the model

diagram

14. Double click the Con tool element to open it

15. Examine the parameters (required and

optional) and decide which ones you want

for your custom tool – you will need the flow

accumulation raster and a threshold value

for the expression

16. CLOSE the tool

17. In the model diagram, right-click Con and

click MAKE VARIABLE >>> FROM

Page 20: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 20 of 53

PARAMETER >>> INPUT CONDITIONAL

RASTER

18. Right-click „Input conditional raster‟ and click

RENAME

19. Change the name to Input flow

accumulation raster and click OK

20. Right-click anywhere it is empty in the

model and click CREATE VARIABLE

21. Select LONG from the list and click OK

22. Right-click „Long‟ and RENAME to

Threshold

23. Double click to open the Con tool element

again

24. Specify the following parameters:

Expression: Value >= %Threshold%

Input true raster: Input flow

accumulation raster

Output raster:

%scratchWorkspace%\t%Threshold%

25. Click OK

26. Expose the „Input flow accumulation raster‟

and „Threshold‟ variables as parameters by

right-clicking each and selecting MODEL

PARAMETER – a „P‟ will appear next to

each of the three variables

27. Drag and drop STREAM LINK on to the

Model diagram

28. Double click the Stream Link tool element to

open it

29. Specify the following parameters:

Input stream raster: t%Threshold%

Output raster:

%scratchWorkspace%\sl%Threshold%

30. Click OK

31. TIP: See the help file on in-line variable

substitution to learn more about dynamically

naming files (e.g. %Threshold%) and setting

environments (e.g. %scratchWorkspace%):

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?TopicName=In-line_variable_substitution

32. In the model diagram, right-click Stream

Link and click MAKE VARIABLE >>> FROM

PARAMETER >>> INPUT FLOW

DIRECTION RASTER

Page 21: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 21 of 53

33. Right-click „Input flow direction raster‟ and

click MODEL PARAMETER

34. Drag and drop WATERSHED on to the

Model diagram

35. Double click the Watershed tool element to

open it

36. Specify the following parameters:

Input flow direction raster: Input flow

direction raster

Input raster or feature pour point data:

sl%Threshold%

37. Click OK

38. Expose the „Output raster‟ variable as a

model parameter (P)

39. Drag and drop RASTER TO POLYGON

(located in the CONVERSION >>> FROM

RASTER toolset) on to the Model diagram

40. Double click the Raster to Polygon tool

element to open it

41. Specify the following parameters:

Input raster: Output raster

42. Click OK

43. Expose the „Output polygon features‟

variable as a model parameter (P)

44. Click the AUTO LAYOUT and FULL

EXTENT buttons to view the fully completed

model tool

45. Click MODEL >>> MODEL PROPERTIES

46. In the GENERAL tab, specify:

Name: equalwatersheds

Label: Equal Sized Watersheds

Description: Creates approximately

similar-sized sub watersheds (raster

and features) using a threshold value

47. Check to „Store relative path names...‟

48. In the PARAMETERS tab, change the order

as needed to match below:

Input flow accumulation raster

Threshold

Input flow direction raster

Output raster

Output polygon features

49. Click OK

50. Click MODEL >>> SAVE

51. Close the ModelBuilder window

Page 22: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 22 of 53

52. In ArcToolbox, double click ADL TOOLS

>>> EQUAL SIZED WATERSHEDS to open

the tool and specify:

Input flow accumulation raster:

\question2\work\flowacc

Threshold: 100000

Input flow direction raster:

\question2\work\flowdir

Output raster: \question2\work\w100000

Output polygon features:

\question2\work\w100000.shp

53. Ensure that all outputs are saving to your

working directory: \question2\work

54. Click OK

55. Modify the drawing order so that the lake

layer draws on top of the new w100000

layer.

56. If you are not satisfied with the sizing of the

output watersheds, then repeat running the

new custom tool using a different threshold

value, such as 500000. A number smaller

than 100000 will yield more watersheds and

a number larger will yield fewer watersheds.

Again, use the value in the output names to

help you identify how they were created.

57. TIP: In ArcToolbox, click the RESULTS tab,

expand the Current Session and double-

click to open the equalwatersheds tool. The

former process is shown with all

input/output parameters. Change the

Threshold, Output raster and Output

polygon features appropriately and click OK.

58. TIP: If you wish to remove the actual lake

from the sub watershed polygons, then use

the built-in ANALYSIS TOOLS >>>

OVERLAY toolset. Erase (ArcInfo) will work

the same way as Union and Select

(ArcView and ArcEditor)

59. SAVE your map document

2.2 Vegetation indices

Examine the ACCRU Tools >>> 2.1 Vegetation

Indices toolset.

1. Right-click 2.1.1 NDVI and click EDIT

Page 23: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 23 of 53

2. This is a model tool that will quickly

calculate the Normalized Difference

Vegetation Index (NDVI) using the map

algebra equation:

float(Near Infrared Band - Red Band) /

float(Near Infrared Band + Red Band)

3. CLOSE the model and then double click to

OPEN it

4. Calculate NDVI on question2\modis\

modis20100626.img raster (NIR = Layer_2

and Red = Layer_1), save the output as

\question2\work\ndvi

5. ADD DATA: all the \modis\evi* rasters

6. Take a moment to view the new rasters

7. SAVE your map document

2.3 Zonal change

Now you will extract the multiple vegetation

values. When using point features, Extract

Values to Points and Sample are the Spatial

Analyst tools to use. With polygon features, the

rasters must be summarized statistically within

the areas – Zonal Statistics as Table will do the

trick!

1. Right-click the name for ADL Tools and click

NEW >>> MODEL

2. Move the Model window so you can see

both it and ArcToolbox

3. Drag and drop ZONAL STATISTICS AS

TABLE (Spatial Analyst >>> Zonal) on to

the Model diagram

4. Double click the Zonal Statistics as Table

(ZST) tool element to open it

5. Examine the parameters and decide which

ones you want for your custom tool

6. CLOSE the tool

7. In the model diagram, right-click ZST and

click MAKE VARIABLE >>> FROM

PARAMETER >>> INPUT RASTER OR

FEATURE ZONE DATA

8. Repeat to make a parameter variable for the

ZONE FIELD

9. Repeat to make a parameter variable for the

INPUT VALUE RASTER

10. Expose all four variables (including the

Output table) as parameters with a „P‟

Page 24: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 24 of 53

11. Click MODEL >>> MODEL PROPERTIES

12. Click the AUTO LAYOUT and FULL

EXTENT buttons to view the fully completed

model tool

13. Click MODEL >>> MODEL PROPERTIES

14. In the GENERAL tab, specify:

Name: zonalmodel

Label: Zonal Model

Description: This is the prototype for

creating the 'Zonal Change' tool

Check to „Store relative path names...‟

15. In the PARAMETERS tab, change the order

if needed to match below:

Input raster or feature mask data

Zone field

Input raster

Output table

16. Click OK

17. Click MODEL >>> SAVE

18. Close the ModelBuilder window

19. In ArcToolbox, double click ADL TOOLS

>>> ZONAL MODEL to open the tool

20. Specify the parameters to match below:

Input raster or feature mask data:

w100000

Zone field: GRIDCODE

Input raster: evi20070626

Output table:

\question2\work\ZonalStats_2007

21. Click OK

While this runs, you may note that you just

created a model tool that merely mimics the

original tool:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?id=6527&pid=6520&topicname=Zonal_Statistics_a

s_Table

It isn‟t anything spectacular but it provides the

skeleton for the Python coding that will extend

its functionality to loop through all raster years.

22. In ArcToolbox, right-click ADL TOOLS >>>

ZONAL MODEL to EDIT the tool

23. Click MODEL >>> EXPORT >>> TO

SCRIPT >>> PYTHON

Page 25: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 25 of 53

24. SAVE in the \dynaland\ADL_Tools\Scripts\

folder as zonalchange.py

25. SAVE and CLOSE the ArcMap document

26. In Windows Explorer, navigate to

\dynaland\ADL_Tools\Scripts to right-click

zonalchange.py and Open With IDLE

27. If the file association isn‟t set properly on

your own computer, then click START >>>

PROGRAMS >>> PYTHON 2.5 >>> IDLE

(PYTHON GUI) and when the Python Shell

interactive window opens, click FILE >>>

OPEN and find zonalchange.py

28. Take a moment to see how the script

program is constructed

29. DELETE the „# Load required toolboxes...‟

line and the one directly below it (these are

not necessary and cause problems between

32-bit and 64-bit computers)

The following will be done to improve and

extend the code:

30. After the line „gp = arcgisscripting.create()‟

type gp.overwriteoutput = 1 # this allows

us to reuse filenames during the code

testing phase

31. Hard-code the input arguments as follows

(type continuous new lines): Input_raster_or_feature_zone_data = "C:\\Temp\\dynaland\\question2\\work\\w100000.shp" Zone_field = "GRIDCODE"

Input_value_raster = [ “C:\\Temp\\dynaland\\question2\\modis\\evi20070626", "C:\\Temp\\dynaland\\question2\\modis\\evi20080626",

"C:\\Temp\\dynaland\\question2\\modis\\evi20090626", "C:\\Temp\\dynaland\\question2\\modis\\evi20100626"]

32. Hard-code the output argument as a

directory only: Output_folder = "C:\\Temp\\dynaland\\question2\\work"

33. Set up a „for loop‟ on the Input_value_raster

list: for raster in Input_value_raster:

print raster

34. Highlight the original arguments (the ones

with „sys.argv‟ in them)

35. Click FORMAT >>> COMMENT OUT

REGION

Page 26: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 26 of 53

36. Highlight the „# Process: Zonal Statistics as

Table...‟ and the line directly below it and

COMMENT OUT REGION

37. Click RUN >>> RUN MODULE (or press the

shortcut F5 key on the keyboard)

38. Click OK to save the script

39. After the run is completed, go back to the

file window to add some more code (if you

get an error, check your „for loop‟ for the

colon and correct whitespace and

indentation)

40. When replacing the text below, ignore the

single quotes

41. Replace „print raster‟ with print raster[-11:]

# this slices off the last 10 characters

42. Calculate the output table as a variable

concatenated with the output directory

43. Directly below the „for raster...‟ loop, type

the following: out_name = raster[-11:]

44. Type Output_table = Output_folder +

os.path.sep + out_name + “.dbf” #

os.path.sep = “\\” in Windows

45. Type print Output_table

46. SAVE and RUN the module

47. Once you get output in the interactive shell

window that lists the concatenated file

names, you are ready to set the

geoprocessing

48. Back in the file window, copy and paste the

following line to directly below the „print

Output_table‟ line: gp.ZonalStatisticsAsTable_sa(Input_raster_or_feature

_zone_data, Zone_field, raster, Output_table, "DATA")

49. NOTE: This page width wraps the line, but

your line in IDLE should be continuous

50. SAVE and RUN the module

51. You now have output tables for each raster

in the hard-coded list – not so flexible when

you want to run it with new and bigger lists

of data. The next steps turn the script in to a

generic tool for ArcToolbox.

52. Highlight all the sys.argv lines below the

„#Script arguments...‟ and click FORMAT

>>> UNCOMMENT REGION

53. Replace „Input_value_raster = sys.argv[3]‟

with Raster_list = sys.argv[3]

Page 27: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 27 of 53

54. Replace „Output_table = sys.argv[4]‟ with

Output_folder = sys.argv[4]

55. Two blank lines below the arguments, type:

Input_value_raster = Raster_list.split(";")

# ArcGIS sends to Python a string of

filenames separated by semi-colons

56. Highlight all the hard-coded arguments and

click FORMAT >>> COMMENT OUT

REGION

57. IMPORTANT: Insert commenting at the top

of the file and throughout the code to

explain what the various parts are doing

58. It is critical to take the time to do this so that

next time you or someone else needs to

tweak the code, it should be more

understandable. It‟s a good idea to do this

as you go along. Remember to include your

contact info, date, etc.

59. SAVE the file

60. OPEN the question2.mxd in ArcMap

61. In ArcToolbox, right-click ADL Tools and

click ADD >>> SCRIPT

62. Type the following:

Name: multizonalstats

Label: Multi Zonal Stats

Description: Calculates summary

statistics in to tables for multiple

rasters representing different time

periods (or any set of rasters) by

zones

Check to „Store relative path names...‟

63. Click NEXT

64. Click the open folder icon to BROWSE to

\dynaland\ADL_Tools\Scripts\

zonalchange.py

65. Click NEXT

66. Set up the following parameters/arguments:

Display Name Data Type

Input zones Feature Class

Zone field Field

Raster list Raster Dataset

Output folder Folder

67. In the Parameter Properties for „Zone field‟

set OBTAINED FROM to Input_zones

68. In the Parameter Properties for „Raster list‟

set MULTIVALUE to YES

69. Click FINISH

Page 28: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 28 of 53

70. In ArcToolbox, click ADL Tools >>> MULTI

ZONAL STATS

71. Specify the following parameters:

Input zones: w100000

Zones field: GRIDCODE

Raster list: all \modis\evi*

Output folder: \work\tables

72. You must create the new \tables folder

73. Click OK

74. Open ACCRU TOOLS >>> 1.2.1 MERGE

WITH FILENAME and specify the following:

Input Workspace: \work\tables

Geometry Type: DBASE

New Field Name: Source

Output File Name:

\question2\work\merge_zstats.dbf

75. Click OK

76. SAVE your map document

You have developed two new tools: one is a

ModelBuilder tool that calculates equal-sized

watersheds based on a user-specified threshold

value for a stream link; the second is a Python

script that summarizes statistical values for

each raster by watershed zone.

To most efficiently analyze the merged table,

run it through the PIVOT TABLE tool (ArcInfo):

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?id=1968&pid=1961&topicname=Pivot_Table_(Data

_Management)

Alternatively, MS Excel can pivot your data to

help track the change of values across time

periods for any of the zonal statistics!

Page 29: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 29 of 53

3 Question 3

How have wildfires changed the forested

landscape patterns over the years?

Patterns on the landscape are a main focus of

landscape ecology and the dynamics of how

wildfires affect landscape vegetation patterns

are the subject of much research. The forested

wilderness, in the far northern state of Alaska

and province of Yukon, is not close enough for

typical human consumption, and so is a natural

laboratory for helping us to understand how

these landscapes respond and succeed in

wildfire disturbance.

This question will develop methods for

classifying the landscape through time and then

“clipping” and exporting the data to be used in

the very handy FragStats software package.

Brushing up on remote sensing knowledge

(there are several textbooks and online

tutorials) will help you understand what is

needed when classifying satellite imagery using

the built-in tools of ArcGIS Spatial Analyst‟s

Multivariate toolset. Instruction on FragStats is

also not included in the workshop, but

documentation is found here: www.umass.edu/landeco/research/fragstats/fragstats.html

Set up ArcMap and the geoprocessing

environments

1. Click START >>> PROGRAMS >>>

ARCGIS >>> ARCMAP

2. Start using ArcMap with a new empty map

3. Click TOOLS >>> EXTENSIONS and make

sure to check on SPATIAL ANALYST

4. If necessary, SHOW ArcToolbox

5. Right-click the name for ArcToolbox and

click ADD TOOLBOX

6. Navigate to your working directory; i.e. the

\dynaland\ACCRU_Tools folder and select

ACCRU Tools.tbx

7. Click OPEN

Page 30: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 30 of 53

8. Similarly, right-click ArcToolbox to ADD

TOOLBOX for \ADL_Tools\ADL Tools.tbx

9. Right-click the name for ArcToolbox and

click ENVIRONMENTS

10. Specify the following General Settings:

Current Workspace = \question3\work

Scratch Workspace = \question3\work

11. Click OK

12. Click the ADD DATA button

13. Navigate to your working directory; i.e. the

\dynaland\question3\rasters folder and

double click to open

14. Hold the CTRL key on the keyboard and

select all the *.img files

15. Click ADD

16. Take a few moments to symbolize each

data layer and open attribute tables to help

you understand what you have to work with

(see the References section to view

websites for metadata)

17. A good RGB composite for highlighting

burned areas in the forested study area is

using Layer_6, Layer_4, Layer_3 (the data

are from Landsat 5 TM and correspond to

original bands 7,4,3)

18. TIP: Once you have the first layer

symbolized as 6,4,3, simply click the

IMPORT button on the Symbology tab for

the other image layers

19. Change the drawing order if you wish to

have the layers draw in descending or

ascending years

20. Turn the layers on and off (click the check

boxes) to view the landscape change

through time and help you identify when

each of the wildfire burn areas first appear

in the imagery

21. Click FILE >>> DOCUMENT PROPERTIES

>>> DATA SOURCE OPTIONS

22. Click „Store relative path names…‟

23. Check beside „Make relative paths the

default…‟

24. Click OK twice

25. Click FILE >>> SAVE as question3.mxd in

your \question3\work folder

Page 31: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 31 of 53

3.1 Classification of landcover

For simplicity (and to fit more tool-building in to

this workshop), the unsupervised approach is

used to demonstrate the workflow of classifying

four different years of Landsat 5 TM satellite

imagery: 1995, 1999, 2004, and 2009.

1. In ArcToolbox, click ACCRU TOOLS >>>

2.2.2 UNSUPERVISED CLASSIFICATION

2. The following provides the required

parameters (remember to repeat for each

satellite image):

Input raster bands: L5_19950916.img

Number of classes: 10

Output signature file:

IsoClus_L5_1995.GSG

Output classified raster: MLClass_1995

3. Leave all else at the defaults and click OK

4. Repeat the 2.2.2 UNSUPERVISED

CLASSIFICATION for L5_19990911.img

5. TIP: In ArcToolbox, click the RESULTS tab,

expand the Current Session and double-

click to open the UnsupervisedClassification

tool. The former process is shown with all

input/output parameters. Highlight the Input

raster bands L5_19950916.img and click

the delete button (X). Select a new input:

L5_19990911.img. Change the Output

signature file and Output classified raster

names to reflect the year 1999. Click OK.

6. While the custom tool runs, view the same

tool in EDIT mode in ArcCatalog to examine

how it was constructed. Right-click the tool

name and click EDIT: the IsoCluster and

Maximum Likelihood Classification tools

have been connected in ModelBuilder with

the necessary parameters exposed.

7. More information on multivariate tools, such

as IsoCluster and Maximum Likelihood

Classification, can be found in the help:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?id=2199&pid=2198&topicname=An_overview_of_th

e_Multivariate_toolset

8. CLOSE the model and return your focus to

ArcMap

Page 32: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 32 of 53

9. In ArcToolbox, click the FAVORITES tab

and expand ArcToolbox >>> SPATIAL

ANALYST TOOLS >>> MULTIVARIATE

10. Locate the ADL Tools toolbox

11. Right-click the name for ADL Tools and click

NEW >>> MODEL

12. Move the Model window so you can see

both it and ArcToolbox

13. Drag and drop ISOCLUSTER on to the

Model diagram

14. Double click the IsoCluster tool element to

open it

15. Examine the parameters (required and

optional) and decide which ones you want

for your custom tool

16. CLOSE the tool

17. In the model diagram, right-click IsoCluster

and click MAKE VARIABLE >>> FROM

PARAMETER >>> INPUT RASTER BANDS

18. Repeat to make a parameter variable for the

NUMBER OF CLASSES

19. Expose all input and output variables as

parameters by right-clicking each and

selecting MODEL PARAMETER – a „P‟ will

appear next to each of the three variables

20. Drag and drop MAXIMUM LIKELIHOOD

CLASSIFICATION on to the Model diagram

21. Double click the Maximum Likelihood

Classification (MLC) tool element to open it

and decide which parameters you want to

set, then CLOSE the tool

22. Click the ADD CONNECTION tool and

click/drag/drop a connection from the Input

raster bands variable already set with the

IsoCluster tool element to the MLC tool

element

23. Repeat the ADD CONNECTION from

Output signature file to MLC – the type of

data is detected and automatically

connected to the appropriate parameter

24. Right-click „Output classified raster‟ and

click MODEL PARAMETER

25. Click the AUTO LAYOUT and FULL

EXTENT buttons to view the fully completed

model tool

26. Click MODEL >>> MODEL PROPERTIES

Page 33: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 33 of 53

27. In the GENERAL tab, specify:

Name: unsupclass

Label: Unsupervised Classification

Description: Creates a signature file

using the isodata clustering

algorithm and applies it to classify

the input bands in to the specified

number of classes

Check to „Store relative path names...‟

28. In the PARAMETERS tab, change the order

if needed to match below:

Input raster bands

Number of classes

Output signature file

Output classified raster

29. Click OK

30. Click MODEL >>> SAVE

31. Close the ModelBuilder window

32. In ArcToolbox, double click ADL TOOLS

>>> UNSUPERVISED CLASSIFICATION to

open the tool

33. Specify the parameters:

Input raster bands:

L5_20040908.img

Number of classes: 10

Output signature file:

IsoClus_L5_2004.GSG

Output classified raster:

MLClass_2004

34. Ensure that all outputs are saving to your

working directory: \question3\work

35. Click OK

36. Repeat your custom UNSUPERVISED

CLASSIFICATION for L5_20090906.img

layer (output IsoClus_L5_2009.GSG and

MLClass_2009 – same naming

conventions, so you know what year the

files go with)

37. Once all four classifications have

completed, turn off all layers by holding the

SHIFT key on the keyboard and clicking on

any checked box in the table of contents

38. For each of the years, turn on only the

paired set of L5_*.img and MLC_Class*

layers to visualize how well the classification

did in mapping out the wildfire burn areas

Page 34: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 34 of 53

39. TIP: Use the EFFECTS toolbar to set the

MLClass_* as the target layer and use the

SWIPE LAYER tool to reveal lower layer

40. IMPORTANT NOTE: The classification work

is not even close to being finished, because

this is the time you would then assign actual

landcover categories to each class number.

This may also involve iteratively

reclassifying and regrouping to yield the

final product. Since this is not a remote

sensing workshop, we will use the results as

they are for the next task.

41. SAVE your map document

3.2 Extract landscape rasters with

*.fbt

To make the classifications ready for input in to

FragStats, they will be extracted to the desired

analytical units (e.g. home ranges, buffers, or in

this case, protected and unprotected status).

The example here requires that each unit is its

own feature class or shapefile (see ACCRU

Tool 1.2.3 for a way to do this with your own

data). The additional step of exporting to an

alternate format, such as ERDAS *.img or

ASCII, makes this process more versatile for

ArcGIS 10 users or sending the files to ArcGrid

disabled FragStats users. No other automated

tool exists for this, so this one must be created

from scratch!

1. Click the ADD DATA button

2. Navigate to \dynaland\question3\shapes

folder and double click to open

3. Hold the CTRL key on the keyboard and

select pa0, pa1, and pa2

4. Click ADD

5. Take a few moments to symbolize each

data layer and open attribute tables to help

you understand what you have to work with

6. Right-click the name for ADL Tools and click

NEW >>> MODEL

7. Move the Model window so you can see

both it and ArcToolbox

Page 35: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 35 of 53

8. Drag and drop SPATIAL ANALYST >>>

EXTRACTION >>> EXTRACT BY MASK on

to the Model diagram

9. Double click the Extract by Mask (EBM) tool

element to open it

10. Examine the parameters and decide which

ones you want for your custom tool

11. CLOSE the tool

12. In the model diagram, right-click EBM and

click MAKE VARIABLE >>> FROM

PARAMETER >>> INPUT RASTER

13. Repeat to make a parameter variable for the

INPUT RASTER OR FEATURE MASK

DATA

14. Right-click on „Input raster or feature mask

data‟ and click PROPERTIES

15. In the GENERAL tab, click „This variable

contains:‟ A LIST OF VALUES

16. Click OK

17. Expose all variables as parameters (P)

18. Click MODEL >>> MODEL PROPERTIES

19. Click the AUTO LAYOUT and FULL

EXTENT buttons to help view the model

20. Click MODEL >>> MODEL PROPERTIES

21. In the GENERAL tab, specify:

Name: extractmodel

Label: Extract Model

Description: This is the prototype for

creating the 'Extract Raster

Landscape with *.fbt' tool

Check to „Store relative path names...‟

22. In the PARAMETERS tab, change the order

if needed to match below:

Input raster

Input raster or feature mask data

Output raster

23. Click OK

24. Click MODEL >>> SAVE

25. Close the ModelBuilder window

26. In ArcToolbox, double click ADL TOOLS

>>> EXTRACT MODEL to open the tool

27. Specify the parameters to match the table

below:

Page 36: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 36 of 53

28. Ensure that all outputs are saved to your

working directory: \question3\work

29. Click OK

While this runs, it will be good to know that

although you just created a model tool that

merely mimics the batch grid control:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?id=752&pid=749&topicname=Using_the_batch_gri

d_control

it is also the foundation for the Python coding

that is needed to extend its functionality to loop

through all years and automatically write the

FragStats batch file (very useful when there are

dozens of input landscapes to be analyzed).

30. In ArcToolbox, right-click ADL TOOLS >>>

EXTRACT MODEL to EDIT the tool

31. Click MODEL >>> EXPORT >>> TO

SCRIPT >>> PYTHON

32. SAVE in the \dynaland\ADL_Tools\Scripts\

folder as extractlandscapes.py

33. SAVE and CLOSE the ArcMap document

34. Navigate to \dynaland\ADL_Tools\Scripts to

right-click extractlandscapes.py and Open

With IDLE

35. If the file association isn‟t set properly on

your own computer, then click START >>>

PROGRAMS >>> PYTHON 2.5 >>> IDLE

(PYTHON GUI) and when the Python Shell

interactive window opens, click FILE >>

OPEN and find extractlandscapes.py

36. Take a moment to see how the script

program is constructed

37. DELETE the „# Load required toolboxes...‟

line and the one directly below it (these are

not necessary and cause problems between

32-bit and 64-bit computers)

The following will be done to improve and

extend the code:

38. After the line „gp = arcgisscripting.create()‟

type gp.overwriteoutput = 1 # this allows

us to reuse filenames during the code

testing phase

Page 37: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 37 of 53

39. Replace (ignore the single quotes)

„Input_raster_or_feature_mask_data‟ with

Input_mask

40. Hard-code the input arguments with lists of

full directory path datasets: Input_raster = [ "C:\\Temp\\dynaland\\question3\\work\\MLClass_1995",

"C:\\Temp\\dynaland\\question3\\work\\MLClass_1999", "C:\\Temp\\dynaland\\question3\\work\\MLClass_2004", "C:\\Temp\\dynaland\\question3\\work\\MLClass_2009"]

Input_mask = [ "C:\\Temp\\dynaland\\question3\\shapes\\pa0.shp",

"C:\\Temp\\dynaland\\question3\\shapes\\pa1.shp", "C:\\Temp\\dynaland\\question3\\shapes\\pa2.shp"]

41. Hard-code the output argument as a

directory only: Output_folder = "C:\\Temp\\dynaland\\question3\\work"

77. Set up a „for loop‟ on the Input_raster list:

for raster in Input_raster:

print raster

78. Set up an „inner for loop‟ on the Input_mask

list:

for mask in Input_mask:

print mask

42. Highlight the original arguments (the ones

with „sys.argv‟ in them)

43. Click FORMAT >>> COMMENT OUT

REGION

44. Highlight the „# Process: Extract by Mask...‟

and the line directly below it and

COMMENT OUT REGION

45. Click RUN >>> RUN MODULE (or press the

shortcut F5 key on the keyboard)

46. Click OK to save the script

47. After the run is completed, go back to the

file window to add some more code (if you

get an error, check your for loop for the

colons and correct whitespace and

indentation)

48. When replacing the text below, ignore the

single quotes

49. Replace „print raster‟ with print raster[-4:]

50. Replace „print mask‟ with mask_name =

os.path.split(mask)[1] # this separates the

name of the file from the directory path

Page 38: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 38 of 53

51. Add a line directly below with print

mask_name.replace(".shp","") # this is

one way to remove the file extension

52. SAVE and RUN the module

53. Calculate the output raster as a variable

concatenated with the output directory

54. Directly below the „for raster...‟ loop, type

the following: year = raster[-4:]

55. Directly below the „for mask...‟ loop, type the

following: mask_name =

os.path.split(mask)[1].replace(".shp","")

# variable assignment of the name of the file

minus the extension

56. Type on its own line:

out_name = mask_name + "_" + year

57. Type on its own line: Output_raster = Output_folder + os.path.sep + out_name

+ ".img"

58. Type on its own line:

print Output_raster

59. SAVE and RUN the module

60. Once you get output in the interactive shell

window that lists the concatenated file

names, you are ready to set up the

geoprocessing line

61. Back in the file window, type the following

line to directly below the „print

Output_raster‟ line: gp.ExtractByMask_sa(raster, mask, Output_raster)

62. SAVE and RUN the module

Provided the program ran to completion (if not,

handle the error before continuing), it‟s time to

set up the code to write the required information

to an output file for FragStats batching. This is

simply a text file with a *.fbt extension. Full

details are available in the FragStats

documentation:

http://www.umass.edu/landeco/research/fragstats/do

cuments/User%20guidelines/Running%20via%20G

UI/Step%204.htm

63. Add the following lines of code directly after

the „Output_folder = “...”‟ (include the blank

line below to improve code readability):

Page 39: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 39 of 53

FBT_name = "wildfire9509"

out_file = Output_folder + os.path.sep + FBT_name + ".fbt"

new_file = open(out_file, 'w')

64. Add the following lines of code directly after

the „gp.ExtractByMask_sa(...)‟: fbt_line = Output_raster + ", x, 999, x, x, IDF_ERDAS\n"

new_file.write(fbt_line)

65. At the very end of the program, type with

NO indentation:

new_file.close()

66. COMMENT OUT the

„gp.ExtractByMask_sa(...)‟ line (you know

that this part works, so no need to wait for it

to run through again)

67. SAVE and RUN the module

68. Examine the wildfire9509.fbt in the

\question3\work folder (right-click and open

with Notepad or other text editor)

You now have your classified landscapes,

extracted to separate analytical units, and an

input file for running FragStats on these multiple

landscapes without having to parameterize and

run each separately. But this current version of

the Python program is hard-coded, and not

flexible for new data. The next steps turn the

script in to a tool for ArcToolbox.

69. UNCOMMENT ##gp.ExtractByMask_sa(...)

70. Replace all the sys.argv lines below the

„#Script arguments...‟ with:

Raster_list = sys.argv[1]

Mask_list = sys.argv[2]

Output_folder = sys.argv[3]

FBT_name = sys.argv[4]

71. One blank line below the arguments, type:

# Separate semi-colon delimited string of filenames

Input_raster = Raster_list.split(";")

Input_mask = Mask_list.split(";")

72. COMMENT OUT the following lines:

Input_raster = [...]

Input_mask = [...]

Output_folder = "C:\\Temp\\..."

FBT_name = "wildfire9509"

Page 40: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 40 of 53

73. IMPORTANT: Insert commenting at the top

of the file and throughout the code to

explain what the various parts are doing.

74. It is critical to take the time to do this so that

next time you or someone else needs to

tweak the code, it should be more

understandable. It‟s a good idea to do this

as you go along. Remember to include your

contact info, date, etc.

75. SAVE the file

76. OPEN the question3.mxd in ArcMap

77. REMOVE all of the results from the Extract

Model tool; e.g. pa0_1999.img, etc.

78. In ArcToolbox, right-click ADL Tools and

click ADD >>> SCRIPT

79. Type the following:

Name: extractlandscapes

Label: Extract Raster Landscapes

with *.fbt

Description: Extract multiple rasters

by multiple masks (analytical units)

to *img files, and automatically write

the FragStats batch file

Check to „Store relative path names...‟

80. Click NEXT

81. Click the open folder icon to BROWSE to

\dynaland\ADL_Tools\Scripts\

extractlandscapes.py

82. Click NEXT

83. Set up the following parameters for the input

arguments:

Display Name Data Type

Input raster(s) Raster Dataset

Input mask(s) Feature Class

Output folder Folder

FragStats Batch Name String

84. In the Parameter Properties for both Inputs

set MULTIVALUE to YES

85. Click FINISH

86. In ArcToolbox, double click ADL Tools >>>

EXTRACT RASTER LANDSCAPES WITH

*.FBT

87. Specify the following parameters:

Input rasters: all \work\mlclass_*

Input masks: all \shapes\pa*

Output folder: \work\extract

FragStats Batch Name: wildfire

Page 41: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 41 of 53

88. You must create the new \extract folder

89. Click OK

90. In ArcMap INSERT >>> DATA FRAME

91. ADD DATA: all the *.img files from the

\work\extract folder

92. Turn them off and on to view

93. SAVE your map document

You have developed two new tools: one is a

ModelBuilder tool that performs all the steps for

an unsupervised classification on multispectral

satellite imagery; the second is a Python script

that extracts (clips) each raster landscape by

several features, exporting as ERDAS *img

layers, along with an automatically written

FragStats batch file.

NOTE: In both questions 2 and 3, you first set

up a model to export as a script. You may

forego this step and type the code directly in

IDLE using the script samples of the ArcGIS

Help documentation as a guide.

Extra credit

This is where you put in to practice what you

have learned (because there are no step-by-

step instructions). Three+ tool ideas are

outlined below, and solutions may be

developed using ModelBuilder and/or Python

for each. Pick one, pick all, and if you don‟t

have enough time during the workshop to get

guidance from Charlene, do them as homework

and feel free to email for help.

Multi Tabulate Areas – develop a tool to

automate this, instead of relying on the batch

grid control, which can become tedious when

there are dozens to hundreds of processes

(question 1)

Page 42: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 42 of 53

Update Raster Landscape – develop a

simplified ModelBuilder tool by following the

ACCRU Tool example (question 1)

EVI – develop a tool that calculates Enhanced

Vegetation Index (question 2):

The coefficients adopted for the MODIS-EVI

algorithm >>> L=1, C1 = 6, C2 = 7.5, and G

(gain factor) = 2.5 are specified here:

http://tbrs.arizona.edu/cdrom/VI_Intro/VI_MOD_VI.html.

In ArcGIS, the equation will look more like this:

EVI = G * (NIR - Red) / (NIR + C1 * Red - C2 * blue + L)

To help you with development and testing, it will

be good to know the band ordering for

\question2\modis\modis20100626.img:

Layer_1: subdataset 3 = red

Layer_2: subdataset 4 = NIR

Layer_3: subdataset 5 = blue

Other – based on your knowledge or gleaned

from the web, create additional vegetation index

tools for Landsat 5 TM data (question 2)

You will need the band ordering information for

\question2\rasters\L5bwcaw20090626.img:

Layer_1: TM1 blue

Layer_2: TM2 green

Layer_3: TM3 red

Layer_4: TM4 NIR

Layer_5: TM5 mid-IR

Layer_6: TM7 mid-IR

Page 43: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 43 of 53

References Commission for Environmental Cooperation.

(2004-2005): North American Environmental Atlas: Boundary, Ecoregions, Landcover, Roads [digital data]. Available at: http://www.cec.org/Page.asp?PageID=924&ContentID=2336

Environment Canada. (2008): Canadian Wind

Energy Atlas [digital data]. Government of Canada, WEST System of Environment Canada. Available at: http://www.windatlas.ca/en/maps.php

Environmental Systems Research Institute.

(2008): ArcGIS: Release 9.3 [software]. Redlands, California: Environmental Systems Research Institute, 1999-2008. http://www.esri.com

IUCN. (2010): IUCN Red List of Threatened

Species – Mammals [digital data]. Version 2010.4. Available at: http://www.iucnredlist.org/technical-documents/spatial-data

Jarvis A., H.I. Reuter, A. Nelson, E. Guevara,

(2008): Hole-filled seamless SRTM data V4 [digital data]. International Centre for Tropical Agriculture (CIAT). Available at: http://srtm.csi.cgiar.org

National Renewable Energy Laboratory. (1993):

Transmission Lines [digital data]. As provided to Federal Emergency Management Agency. Available at: http://www.mapcruzin.com/renewable-energy-us-electric-transmission-shapefiles.htm

Natural Resources Canada. (2009):

Transmission Lines, CanVec version 1.1 [digital data]. Government of Canada, Natural Resources Canada, Earth Sciences Sector, Centre for Topographic Information. Available at: http://geogratis.cgdi.gc.ca/geogratis/en/collection/metadata.do?id=5460AA9D-54CD-8349-C95E-1A4D03172FDF

Page 44: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 44 of 53

Neteler, Markus. (2009): MODIS Sinusoidal

Grid Shapefile [digital data]. Fondazione Edmund Mach (FEM), IASMA Research and Innovation Centre, Italy. Available at: http://gis.fem-environment.eu/modis-sinusoidal-gis-files

Nielsen, Charlene. (2010): ACCRU Tools:

extension for ArcGIS, release 9.3.1 [software]. University of Alberta, Edmonton, Alberta, Canada. Available at: http://www.biology.ualberta.ca/facilities/gis/?Page=3063#tools

Python Software Foundation (PSF). (2010):

Python programming language: Release 2.5 [software]. Python Software Foundation, Wolfeboro Falls, NH, 1990-2010, http://www.python.org

Tucker, Corey. (2005): Writing Geoprocessing

Scripts. Environmental Systems Research Institute, Inc. Redlands, CA.

U.S. Geological Survey. (2007-2010): MODIS

Terra Vegetation Indices 16-Day L3 Global 250m, product MOD13Q1 [digital data]. U.S. Department of the Interior, U.S. Geological Survey, Land Processes Distributed Active Archive Center (LP DAAC), Available at: https://lpdaac.usgs.gov/lpdaac/products/modis_products_table/vegetation_indices/16_day_l3_global_250m/mod13q1

U.S. Geological Survey. (1994-2009): Landsat

5 satellite imagery [digital data]. U.S. Department of the Interior, U.S. Geological Survey, EROS Data Center, Available at: http://edcsns17.cr.usgs.gov/NewEarthExplorer

Van Rossum, Guido. (2010): Python tutorial.

Python Software Foundation. http://docs.python.org/tutorial/

Page 45: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 45 of 53

Some more GIS tools…

Marine Geospatial Ecology Tools

http://code.env.duke.edu/projects/mget

Geospatial Modelling Environment

http://www.spatialecology.com/gme

Home Range Tools

http://www.blueskytelemetry.com/downloads.asp

Topography Tools for ArcGIS

http://arcscripts.esri.com/details.asp?dbid=15996

ModelBuilder quick guide

An applied GIS workshop cannot possibly cover

every nuance, tip and trick when working with

ModelBuilder, so the following is offered as a quick

guide to cover what you need to know for the

sample questions tool building, along with resources

on where to learn more.

Online help topics (ESRI ArcGIS 9.3)

http://resources.arcgis.com/content/geoprocessi

ng/9.3/about

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?TopicName=An_overview_of_model_concepts_an

d_terms

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?TopicName=An_overview_of_ModelBuilder

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?TopicName=Creating_a_simple_model

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?topicname=faq_for_modelbuilder

Page 46: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 46 of 53

Free training

The following are online web seminars from

ESRI.com and ESRICanada.com:

Geoprocessing Using ModelBuilder

Getting Started with ModelBuilder

Advanced ModelBuilder

Effective Analysis and Data Management with

Geoprocessing

Parameterize a generic model tool

The following shows how to build the tool –

Add/Calculate Geometry Field – while exploring

the basic building blocks of ModelBuilder. The

testing assumes ArcMap is open with the layer

\general\protected_mb.shp already added.

1. Add/Create a custom toolbox

a. Right-click ArcToolbox and click ADD

TOOLBOX

b. Navigate to where you created the ADL

Tools.tbx (from the „Sample questions‟

section above), select it and click OPEN

2. Open up the ModelBuilder interactive window

a. Right-click ADL TOOLS and click NEW

>>> MODEL

b. Click MODEL >>> MODEL

PROPERTIES

c. Specify a Name (no spaces) =

addcalcarea; Label = Add Calculate

Area, and Description = Calculate area

for polygon features

d. Check to „Store relative path names‟

e. Briefly, examine the ModelBuilder

window

f. Click OK and then click the SAVE button

g. Choose HELP >>> ARCGIS DESKTOP

HELP

h. Read through „An overview of

ModelBuilder‟ and explore some of the

links

i. Minimize the help file when finished –

you will want to refer to it as you work

Page 47: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 47 of 53

3. Drag and drop tools to the diagram

a. Use the Search or Index tabs to

highlight and click LOCATE or expand

the Favorites tab of ArcToolbox to help

you find the tools you need

b. Drag and drop the ADD FIELD tool to

the model diagram

c. Drag and drop the CALCULATE FIELD

tool to the diagram

d. Double click each tool element to open

and examine which parameters are

available for the tool and then close

4. Connect processes and workflows

a. Click the CONNECT tool and drag and

drop a connection between the output of

ADD FIELD and the tool element of

CALCULATE FIELD

b. Alternatively, by setting parameters

inside each tool, connections will be

made between variables

c. Click the AUTO LAYOUT and FULL

EXTENT tools to help with the layout

5. Set up variables, parameters, etc.

a. Right-click ADD FIELD and click MAKE

VARIABLE >>> FROM PARAMETER

>>> INPUT TABLE

b. Make parameter variable for FIELD

NAME

c. Right-click „Input Table‟ and click

MODEL PARAMETER

d. Repeat exposing as a parameter for

„Field Name‟

e. Double click ADD FIELD to open, set

FIELD TYPE = DOUBLE, and then

close

f. Double click the FIELD NAME variable

element and type AREA

g. Double click CALCULATE FIELD to

open, set FIELD NAME = Field Name,

EXPRESSION = float(!shape.area!),

EXPRESSION TYPE = PYTHON, and

then close

6. Save, close, edit

a. Click FILE >>> SAVE

b. CLOSE ModelBuilder

c. If you wish to access the diagram again

to make modifications/additions then

right-click the model name and click

EDIT

7. Test, edit, and test again

Page 48: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 48 of 53

a. OPEN the tool and input protected_mb

as the input table

b. Double click CALCULATE FIELD to

open, set FIELD NAME = %Field

Name%

c. Test again with protected_mb (but you‟ll

have to use a different field name)

d. TIP: The „Field Name‟ and „Expression‟

parameters could easily be changed to

calculate LENGTH or other geometry

properties:

http://webhelp.esri.com/arcgisdesktop/9.

3/index.cfm?id=962&pid=951&topicnam

e=The_geometry_object

8. Share with documentation

a. When in the model diagram, click

MODEL >>> MODEL PROPERTIES or

right-click the model and click

PROPERTIES to modify the label,

description, order of parameters,

environments, etc.

b. TIP: You may wish to filter the type of

input data that is accepted by the tool;

do this in the PROPERTIES >>>

PARAMETERS tab

c. Right-click the model tool and click EDIT

DOCUMENTATION to open the

documentation page editor

9. Extra credit

a. Copy the model tool

b. Rename and re-label as addcalclength

c. EDIT the model and change the Field

name to LENGTH

d. Change the expression to

float(!shape.length!)

e. SAVE and CLOSE

f. Run the tool on protected_mb.shp

Page 49: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 49 of 53

Python scripting quick guide

A one-day workshop is not enough time to become

proficient in the Python language, so the following

acts as a quick guide to cover what you need to

know for the sample questions tool building, along

with resources on where to learn more.

Online help topics (ESRI ArcGIS 9.3)

http://resources.arcgis.com/content/geoprocessi

ng/9.3/about

http://webhelp.esri.com/arcgisdesktop/9.3/pdf/Geopr

ocessor_93.pdf

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?TopicName=An_overview_of_writing_geoprocessin

g_scripts

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?TopicName=An_overview_of_creating_script_tools

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm

?topicname=faq_for_scripting

Free training

The following are online web seminars from

ESRI.com and ESRICanada.com:

Getting Started with Scripting in ArcGIS 9

Using Python in ArcGIS Desktop 10

Effective Analysis and Data Management with

Geoprocessing

ESRI Canada has three web seminars coming soon:

http://www.esricanada.com/en_events/615.asp

The official and „instant‟ Python tutorials:

http://docs.python.org/tutorial/

http://hetland.org/writing/instant-python.html

http://learnpythonthehardway.org

Page 50: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 50 of 53

Add a generic script tool

The following shows how to build the tool –

Add/Calculate Geometry Field – while getting to

know Python programming and IDLE.

1. Open up the integrated development

environment (i.e. IDLE)

a. Click START >>> PROGRAMS >>>

PYTHON 2.5 >>> IDLE (PYTHON GUI)

b. Examine the various menu items

c. Click HELP >>> IDLE HELP

d. Close when finished reading

e. Click OPTIONS >>> CONFIGURE IDLE

f. Examine each tab and modify as

needed; e.g. change font (Fonts/Tabs

tab); add custom web/file help link/path

(General tab and click Add button)

g. Close when finished

2. OPTIONAL: Play around with some of the

Python language (supplemental material in the

\ppp folder)

a. assign statement

variables (numerics, strings, lists)

operators (concatenate, math)

b. print statement

c. compound statement (colons,

indentation with spaces, whitespace)

test condition: if, elif, else

loop and iterate: while or for

3. Create a new file

a. Click FILE >>> NEW WINDOW

b. Examine the various menu items

c. Click FILE >>> SAVE to the

\dynaland\ADL_Tools\Scripts folder as

addcalcarea.py

4. Use comments/docstrings to indicate details

about what the script requires and does

a. # Tells Python to ignore the line, but you

may type notes on a single line to

indicate what the code below does

b. “““ Encloses any amount of text between

triple quotes, which Python also ignores

”””

c. Indicate at the top of the file, information

such as script name, date, your contact,

program description/usage, etc.

Page 51: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 51 of 53

5. Import required module(s)

a. Extra „tools‟ are available as

libraries/packages/modules – use the

„import‟ statement to bring them in to

your program

b. import arcgisscripting – required for

working with ArcGIS geoprocessing

framework

c. import os, string, sys – gives you

access to working with the operating

system, string functions, and system

variables

6. Type out the basic structure of your coding

a. Create the geoprocessing object so you

can access all the ArcGIS tools and

functionality for working with spatial

data: gp = arcgisscripting.create()

b. OPTIONAL: Check out any necessary

licenses (this is an example only and is

not needed for this script):

gp.CheckOutExtension("spatial")

c. Use comments and placeholders to set

up arguments, variables, and

processes; re-visit each to complete:

# Arguments

input_table = ""

field_name = ""

# Variables

field_type = "DOUBLE"

expression = "float(!shape.area!)"

# Process: Add field – type all on one line

gp.AddField_management(

input_table, field_name, field_type)

# Process: Calculate field – type all on one line

gp.CalculateField_management(

input_table, field_name, expression,

"PYTHON", "")

d. FUTURE: Use try/except and other code

to handle errors (not covered in this

workshop)

7. Test with hard-coded arguments

a. Fill in the placeholders:

input_table =

"c:\\temp\\dynaland\\general\\protected_p.shp"

field_name = "AREA"

Take

advantage

of the

sample

scripts in

ArcGIS

Help files!

Page 52: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 52 of 53

b. Highlight the lines starting with „gp.‟ And

click FORMAT >>> COMMENT OUT

REGION

c. Directly below each of those

commented out lines type a print

statement with one of the variables

required for that process

print “Adding field to ” + input_table

print “Calculating “ + expression

d. Click RUN >>> RUN MODULE (click OK

to save, if prompted)

e. Edit and fix any errors as needed

8. Set up system variables

a. Two ways to make your code in to a

program that accepts inputs (i.e.

arguments/parameters):

gp.GetParameterAsText(0)

sys.argv[1]

b. Replace arguments with the following:

# Arguments

input_table = sys.argv[1]

field_name = sys.argv[2]

a. Highlight the lines starting with „gp.‟ And

click FORMAT >>> UNCOMMENT

REGION

b. SAVE the file

9. Add/Create a custom toolbox

a. In an ArcMap document, right-click

ArcToolbox and click ADD TOOLBOX

b. Navigate to where you created the ADL

Tools.tbx (from the „Sample questions‟

section above), select it and click OPEN

10. Add a script tool

a. Right-click ADL TOOLS and click ADD

>>> SCRIPT

b. Specify a Name (no spaces) =

addcalcarea; Label = Add Calculate

Area, and Description = Calculate area

for polygon features

c. Check to „Store relative path names...‟

d. Click NEXT

e. Click the open folder icon to BROWSE

to \ADL_Tools\Scripts\addcalcarea.py

f. Click NEXT

11. Set up parameters/arguments

a. Type the name for display and select the

type of data it will accept

Page 53: GIS Tools - University of Albertaccn/teaching/USIALE2011_GISDynaLand.pdfUS-IALE 2011 ccn@ualberta.ca Page 2 of 53 Abstract Gain proficiency with existing custom Geographic Information

GIS Tools for Analyzing Dynamic Landscapes April 2011

US-IALE 2011 [email protected] Page 53 of 53

Display Name Data Type

Input table Feature Layer

Field name String

b. Click FINISH

12. Test, edit, and test again

a. ADD DATA protected_p

b. Right-click protected_p and OPEN

ATTRIBUTE TABLE and CLOSE when

finished viewing

c. In ArcToolbox, click ADL Tools >>>

ADD CALCULATE AREA

d. Specify the following parameters:

e. Input table: protected_p

f. Field name: AREA

g. Click OK

h. Right-click protected_p and OPEN

ATTRIBUTE TABLE and CLOSE when

finished viewing

13. Share with documentation

a. In ArcToolbox, right-click ADD

CALCULATE AREA and click

PROPERTIES to modify the label,

description, source, parameter

properties, etc.

b. TIP: You may wish to filter the type of

input data that is accepted by the tool;

do this in the PROPERTIES >>>

PARAMETERS tab

c. Right-click the model tool and click EDIT

DOCUMENTATION to open the

documentation page editor

14. Extra credit

a. In IDLE, save the script as

addcalcname.py and modify the code

b. In IDLE, replace the following variables:

field_type = "TEXT"

expression = os.path.split(input_table)[1]

c. In ArcToolbox, modify the Name (no

spaces) = addcalcname; Label = Add

Calculate Name, and Description =

Calculate file name in to attribute

table

d. Change the Source to addcalcname.py

e. Click OK

f. Run the tool on protected_p.shp with the

Field name NAME

g. In IDLE, fix the code with:

expression = '"' + os.path.split(input_table)[1] + '"'

h. SAVE and run the tool again