Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

05 Ras3.AnalysisProperties

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Ras.3.

Analysis Environment Properties


Before we start using spatial analysis methods on grids, it’s important that we
understand what happens during the process, and how we can control how the analysis
proceeds. This is especially important for raster-mode spatial analysis because of the
significance of the grid cells: their position, size, and spatial correspondence among
input data layers.

If you’re starting ArcMap up again, remember to add the Spatial Analyst Extension.

Spatial analysis is pretty easy with grid-based GIS, but we must clearly understand the
issues that relate to using this kind of data. Resolution and cell size, registration, and a
variety of analysis properties must be considered carefully or we can end up with poorly-
formed results. We’ll start by seeing what is involved in creating rasters, and how we can
use the Raster Calculator to do this. The Raster Calculator will be somewhat familiar to
those who have used map algebra-based systems like Map Analysis Package or GRID.

Environment Settings
When you use Spatial Analyst or other tools to create rasters, typically from other
datasets, environment settings are used. These settings remain in the background and are
applied when you perform an operation that creates an output. They include: (1) the
working directory; (2) the extent – a rectangular study area; (3) the cell size – the width
of the square cells; and (4) a mask – a definition of an irregular study area within the
extent, with nodata (null) cells representing areas outside the study area.
¾ Bring up the Analysis Properties window from the Spatial Analyst toolbar with
Spatial Analyst>Options…
¾ In the General tab, enter the working
directory that corresponds to where
you’re working: e.g.
“D:\workspace\raster\HMBarea” if
you’re working on the local hard drive.

™ You should pay attention to what you get


and where things get stored as you do this
exercise. When you get a result in
ArcMap, right-click the layer and go to
the Source tab. The raster information
area has lots of important stuff, like
whether a raster’s status is temporary or
permanent. Note: temporary grids are
deleted when you leave ArcMap.

5-1
Creating a grid from a feature layer
We’ll use a feature-to-raster conversion to look at the effects of
cell and extent settings.

¾ Add arcs from the streams coverage in hmbarea to a new


dataframe.

¾ Spatial Analyst>Convert> Features to


Raster… to create the grid; Set the Conversion
Field to ST-CODE [code to be assigned, which
will make it the main Value field in the resultant
grid]; erase everything in the output raster field
and give it the name streams_g ; default
everything else.
? What name is given to the output raster, is it
permanent, and where is it stored (right-click the
layer and look at its data source under the source
tab)?

Cell size and resolution


An important aspect of raster GIS is cell size, and the related concepts of resolution and
minimum mapping unit. Any raster data layer has a cell size and that size limits the
ability to “resolve” features and patterns in the map. Cell size is often determined by
limits in the data sources for the GIS, especially where information comes from aerial
photography or scanned imagery. The concept of “minimum mapping unit” is basically
the minimum size that cells can be set, based on the pixel size of the imagery being used.
For instance, a Landsat Thematic Mapper image pixel is typically 25 m on a side, thus the
minimum mapping unit is 25 m; nothing smaller can be seen.
¾ Let’s start by exploring raster (grid and image) data that exists in the hmbarea
directory. Fill out the following table by creating a new dataframe and adding each of
the grid layers into it. Determine the values by right-clicking each grid and selecting
Properties…– for multispectral images, just add one band and look at its
Properties...

Name Cellsize rows cols left right bottom top type


Original:
Elev
geology
landuse
tmcomp
New:
Streams_g
? Do you see a pattern – describe what you see.

5-2
? Can you foresee any problems in using these datasets
together?

Spatial Analyst does not require that grid cell structures be


the same for multi-raster analyses, but it’s best to make
them the same as much as possible. You can ensure that
the result of a raster calculation derives from a simple cell-
by-cell computation, thus producing more consistent and
accurate results.

¾ Create some new rasters from the streams and roads arc
coverages, but use an existing raster you want to match as
a reference. Start by inserting a new dataframe and adding
the elev raster and the two arc coverages roads and
streams as feature layers. Convert each vector
feature to rasters (with Spatial
Analyst>Convert>Features to Raster) using road-
code and st-code fields, but first specify “Same As
Elev” for both the Output Raster Extent and
Output Raster Cell Size in the Analysis Options.
Give them the names Roads60 and Streams60.

¾ Now make two 30-m-cell rasters for these two


feature layers, using “Same As Elev” for the
Output Raster Extent, but specifying the cell size
as 30. Name them Streams30 and Roads30.
¾ Go ahead and display the rasters.
¾ Before we continue, make sure the dataframe has a coordinate system set, and the
units are in meters. Right-click on the dataframe and select Properties… to bring up
the Dataframe Properties window and make sure Map Units are set to meters.
¾ Rearrange the legend to where the streams feature layer is at the top, followed by
Streams30 and Streams60, and turn all other legend entries off. Zoom in to some
area where tributary streams converge, with the scale showing around 1:10,000.

¾ Note the effect of the two raster resolutions on the nature of the
stream representation by alternately turning on and off these two
rasters.

What was the effect?

5-3
Joining Data

The rasters we’ve just created are


derived from feature datasets, and we
picked a logical code to use for our
value field, but there are other
attributes we are interested in. Since
the feature datasets had a record for
every feature, and many of the features
have the same value, much of the data
are stored in separate data tables, one
record per value – the same as raster
data tables. So why not join the
separate data into the new raster
attribute table? That’s what we’ll do.
™ Note for streams that there are two
values for Value, derived from the
conversion field St-code from the
stream coverage’s arc attribute
table. Since St-code doesn’t mean
anything to most of us we’ll pull a
descriptive attribute from another
table.
¾ Add an info table, streams.exp,
from hmbarea. This table
contains descriptive information
related to the stream codes. To
join this table to stream30, right-
click stream30 in the table of
contents and select Joins and
Relates>Joins...
¾ A Join Data Dialog will pop up. Set the windows to the graphic below, e.g. 1)
Value, 2) streams.exp 3) ST-CODE, and click OK.

¾ As you can probably see, the result of this is we can see two types of streams.
However, the differences between these are only important for drawing political
boundaries that also happen to coincide with the streams. Later on, we’ll simplify
this grid, since we really don’t care about these differences for grid analyses.
¾ Do the same for the other streams grid streams60 roads; and then the two roads grids,
joining the info table roads.exp.
? What are the road codes, and what are their text descriptions?

5-4
Making a mask raster
A mask raster is used to limit analysis to a specific area – no areas outside the mask are
used. Say you’d like to analyze land-use patterns on granitic rocks. There are various
ways to do this, but one way is to create a raster of granitic rock areas, then use it as a
mask raster in a query.

¾ Create a new dataframe, and add geology and landuse from


hmbarea.
¾ Open the attribute table for the geology raster, and select the
record for “granite”, then close the table.
¾ Use Spatial Analyst>Raster Calculator to create a raster from
this selection or query result (Make sure you set the Analysis
Options – Extent and Cell Size – to Same as layer “geology”
before you create the raster). Enter the assignment statement
granitics = [geology]
into the Raster Calculator window and Evaluate.
? What is the status (temporary or permanent) of the raster dataset
that is created? __________________

? In this granitics raster, what value is stored in the non-granitic areas?


_____________

Using the mask in an analysis

¾ In the Analysis Properties window, set the


analysis mask to granitics.
? Considering the previous question (make sure
you know its correct answer), what makes
granitics work as a mask?

¾ Open the attribute table for the landuse raster, and select the record for “Evergreen
Forest”, then close the table. Create a raster with the following expression in Raster
Calculator: [landuse]
¾ Rename the result “Evergreen on Granitics”
¾ Set the Analysis Mask to “<None>” and do this same map query, renaming the result
“Evergreen Forest”. Examine the result, and note the effect.
? What is the effect of the mask?

¾ Try some other analyses, with and without masks. In a later exercise, we'll learn
other methods of selecting values and creating masks. Before continuing, clear all of

5-5
the selections in the attribute tables (find the Clear Selection operation in the Options
button on the attribute table display), and save your map document as ras3.mxd.

Overlay effects of cell and extent settings


In this part, we'll see how environment settings of windows and cell sizes are used when
creating rasters from a variety of processes, including overlay of multiple source rasters.
We will also explore a bit of using Grid, part of Workstation ArcInfo (sometimes called
“classic ArcInfo”). The Map Algebra statements we have been using, and will be
exploring a lot more in the coming sections, can be used either one at a time in the
ArcMap’s Raster Calculator, or run as a multi-step script in Grid.
In this section, we’ll use a script to create a series of simple rasters for demonstrating
analysis properties of cell size and extent. The simple rasters we’ll use have no purpose
other than demonstrating the effects of various combinatorial raster operations and the
effect of Analysis Property settings. These rasters do represent real maps, but have areal
extents and cell sizes, as do real maps. By studying these simple rasters, which have a
coarse array of cells, of contrasting cell sizes and extents, we can better understand the
effects of these analysis properties on real maps.

Setup
To create these rasters and work with them we need to (1) create a workspace folder to
work in; (2) write the script; and (3) run the script. Since the rasters we’re creating don’t
relate to any existing datasets we have – it’s like we’re creating a simulated study area –
we shouldn’t use any existing workspaces.

¾ You should find an Makegrids.aml


Arc Macro cw testrasters
Language (AML) w testrasters
script called grid
makegrids.aml in setwindow 4.25 6.25 14.25 12.25
the raster folder you setcell 0.5
copied. If not, you one = ($$ROWMAP MOD 2) * ($$COLMAP MOD 2)
can use a text editor setwindow 6.125 4.125 12.125 13.875
to type the script in setcell 0.75
(just type it two = ($$ROWMAP MOD 2) * ($$COLMAP MOD 2) * 2
carefully and end it setwindow 12.5 2.5 16.25 8.125
with a blank line). setcell 0.625
The script starts by four = ($$ROWMAP MOD 2) * ($$COLMAP MOD 2) * 4
creating a quit
workspace folder,
starts the grid
program, then creates three rasters with a pattern of cells with values of 0 and either
1, 2, or 4 – named one, two, and four – and for each manipulates the analysis extent
and cell size. Grid has its own way of setting the analysis extent and cell size, using
the Setwindow and Setcell commands. It’s not critical that you understand this, but

5-6
$$ROWMAP is a grid of row numbers and $$COLMAP is a grid of column numbers,
for a raster created using the current analysis properties. These values create rasters
that help to visualize the cell sizes.
¾ If you typed the script, save it in your raster
workspace folder as makegrids.aml, using the
“All files” file type option.
¾ Run this script from the Arc window, first setting the workspace. Quit when it's
done. The following three commands does this: (1) sets the current workspace (w) to
your raster folder (similar to opening a folder in Windows); (2) runs the AML script;
then (3) quits the arc command window. Type what’s in bold, not “Arc:” – that is the
prompt you should see in the black Arc command-line window – it means that you
are sending commands to the Arc
command processor. You're probably not using a folder called "workspace"
Arc: w d:/workspace/raster so you may have it in "f:/geog621/raster" or some
Arc: &run makegrids other place. Use windows to see what the path name
Arc: q is. Backslashes (\) or forward slashes (/) can be used,
¾ Now display the rasters in a new it doesn't matter. But maybe you'll be typing
Arcmap document you create and
name testras3.mxd. Ignore the w f:/geog621/raster
message about the layers missing
spatial reference information – they I can't give you the specific path, because it depends
are not projected areas of the earth but on where you put it.
are in a simulated area. Use the
Effects toolbar to set the transparency If you do this command wrong, you'll see the message
for overlapping rasters to about the Unable to change workspace.
Effects toolbar to set the transparency If you do it right, you'll see the message
for overlapping rasters to about 30% WARNING: New location is not a workspace.
or so. In the table of contents, set the
color for cells with values greater than I know that sounds ominous, but it just means that it
zero to distinct colors: 1 (red), 2, found the folder, but is just warning you that the folder
(green), 4 (yellow). hasn't been configured as an ArcInfo workspace. The
AML will run just fine, since I've included all the code
it needs to create a valid workspace.

When you run the makegrids aml in the next


command, you should see a series of messages like
"Running...100%" appearing from time to time. It'll
either happen slowly or fast, but it eventually will
return an "Arc:" prompt. Wait until you see this
before you try to quit and use ArcMap to see your
l

5-7
Cell Width Settings
The cell width setting in the Spatial Analyst Options has several options:

Basically, you can either (1) set it to the largest size from the input rasters (Maximum of
Inputs); (2) set it to the smallest size of the input rasters (Minimum of Inputs); (3) set it
directly (As Specified Below) by typing in a value into the Cell Size box; or (4) reference
a raster for a cell size (e.g. “Same As Layer “one”).
Experiment with each of these options to see how they work. For each experiment, use
the Raster Calculator to derive temporary rasters that are the sum of one and two, using
the following expression (make sure to include spaces around the + sign):
[one] + [two]

Answer these questions:


? What is the status of the above Raster Calculator result?

? When you used Minimum of Inputs, which of the rasters (one or two) is used to
determine the cell size?

? What about if you use Maximum of Inputs?

? Try setting the cell size to a large value like 5. What does this show?

5-8
Setting the Analysis Extent
The extent settings include the options to use:
a. (Same As Display) the extent of what is currently
displayed. For example, to create a raster covering a
small area you've zoomed into, this is the setting to
use. Note that if you change the display after you
make this setting, the new display change will have
no effect, unless you bring up Analysis Properties
again and use the setting "same as display"
b. (Intersection of Inputs) only those cells common to
all input rasters
c. (Union of Inputs) all of the areas covered by the input rasters
d. (As Specified Below) values specified in the boxes
e. (Same As ….) values representing the extent of an existing raster or other layer.
¾ As we did with cell sizes, experiment with the various settings while adding one and
two together to create temporary rasters for display. Try adding four into the mix as
well – raster calculations are not limited to two rasters. Again, use the cell tools to
explore the result. Note: to see the effect of setting the extent, you should set
Symbology to display nodata as something other than transparent. To make the
results consistent, set the Analysis Cell Size to "Maximum of Inputs".
? What is the effect of the Union setting? (Note: you need to display the nodata cells as
black, not transparent, to see the effect.)

? What happened to the areas not common to both rasters?

? When would this be useful?

? How about the Intersection setting?

? Try setting the extent to Same As Layer “Four”, and adding one and two as before.
Remember to display nodata as a color. What is the effect?

5-9
? When would this be useful, or other “Same as (raster)” operations be useful?

Specifying values for both cell width and extent

You can of course control both cell width and extent. You may have already been
experimenting with this. If not, here’s a simple demonstration:

Create a raster with values of 5 everywhere, and setting the cell width and extent. Use
“As Specified Below” for both, using Left = 0, Right = 50, Bottom = 0, Top = 50 as the
four settings for extent, and 1 as the cell width. The Raster Calculator should use 5 as the
expression. If you get an error, it’s probably because the environment setting is wrong.

? Can you think of a use for data like this?

¾ Try the following expression in the raster calculator: int(rand() * 10)


? What did this create, and can you think of a use for it?

Snapping to a raster
Sometimes you want your cells to align exactly with a particular raster (like an elevation
model) yet your spatial extent needs to derive from another raster (like a study area).
Let’s say that raster one represents your study area, and raster two represents the raster
you want cells to be aligned with.

¾ Set the cell size to be the same as layer two, the extent to be the same as layer one,
then set the extent to be As specified – this will leave it the same as the most recent
setting (don’t change it), then set the Snap Raster to layer two. Now use the raster
calculator to, again, add one and two. Make sure to display nodata in the result.
? What was the effect?

Review Questions:
? In general, what process creates a temporary raster vs. a permanent one?

? What makes a raster work as a mask?

End of Exercise – save your map document.

5-10

You might also like