Lecture 5
Spatial Analysis &
Raster Calculations
GIS in Water Resources
Spring 2015
Spatial Analysis Using Grids
Learning Objectives
• The concepts of spatial fields as a way to
represent geographical information
• Raster and vector representations of spatial
fields
• Perform raster calculations using spatial
analyst
• Raster calculation concepts and their use in
hydrology
• Calculate slope on a raster using
– ESRI polynomial surface method
– Eight direction pour point model
– [D method]
1
Readings – at http://help.arcgis.com
• Elements of geographic information starting from “Overview of
geographic information elements”
http://help.arcgis.com/en/arcgisdesktop/10.0/help/00v2/00v200000003
000000.htm to “Example: Representing surfaces”
Readings – at http://help.arcgis.com
• Rasters and images starting from “What is raster data”
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009t00
000002000000.htm to end of “Raster dataset attribute tables”
2
Two fundamental ways of representing
geography are discrete objects and fields.
The discrete object view represents the real world as
objects with well defined boundaries in empty space.
(x1,y1)
Points Lines Polygons
The field view represents the real world as a finite number
of variables, each one defined at each possible position.
f ( y ) f ( x , y ) dx
x
Continuous surface
Raster and Vector Data
Raster data are described by a cell grid, one value per cell
Vector Raster
Point
Line
Zone of cells
Polygon
3
Raster and Vector are two methods
of representing geographic data in
GIS
• Both represent different ways to encode and
generalize geographic phenomena
• Both can be used to code both fields and
discrete objects
• In practice a strong association between
raster and fields and vector and discrete
objects
Numerical representation of a spatial surface (field)
Grid
TIN Contour and flowline
4
Triangulated Irregular Networks, TINs
No point in a set of points P lies
within a circumcircle of any of the
created triangles.
=> Delauney Triangulation
“Flipping”
Algorithm
This is NOT Delauney This one IS Delauney
Relation to Voronoi Tesselation
Mark center of each circumcircle.
Then connect each center with those
surrounding.
If center of CC is inside triangle, then lines
connecting centers are perpendicular to the
common edge of two neighboring triangles.
Does not always work out! Has implications
for numerical models needing orthogonal grid.
5
Six approximate representations of a field used in GIS
Regularly spaced sample points Irregularly spaced sample points Rectangular Cells
Irregularly shaped polygons Triangulated Irregular Network (TIN) Polylines/Contours
from Longley, P. A., M. F. Goodchild, D. J. Maguire and D. W. Rind, (2001), Geographic Information
Systems and Science, Wiley, 454 p.
A grid defines geographic space as a matrix of
identically-sized square cells. Each cell holds a
numeric value that measures a geographic attribute
(like elevation) for that unit of space.
6
The grid data structure
• Grid size is defined by extent, spacing and
no data value information
– Number of rows, number of column
– Cell sizes (X and Y)
– Top, left , bottom and right coordinates
• Grid values
– Real (floating decimal point)
– Integer (may have associated attribute table)
Definition of a Grid
Cell size
Number
of
rows
NODATA cell
(X,Y)
Number of Columns
7
Points as Cells
Line as a Sequence of Cells
8
Polygon as a Zone of Cells
NODATA Cells
9
Cell Networks
Grid Zones
10
Floating Point Grids
Continuous data surfaces using floating point or decimal numbers
Value attribute table for categorical
(integer) grid data
Attributes of grid zones
11
Raster Sampling
from Michael F. Goodchild. (1997) Rasters, NCGIA Core Curriculum in GIScience,
http://www.ncgia.ucsb.edu/giscc/units/u055/u055.html, posted October 23, 1997
Raster Generalization
Largest share rule Central point rule
12
Raster Calculator
Example
5 6 Precipitation
Cell by cell 7 6
evaluation of -
-
mathematical Losses
3 3
functions 2 4 (Evaporation,
Infiltration)
=
2 3
=
5 2 Runoff
Runoff generation processes
Infiltration excess overland flow P
aka Horton overland flow
P f
P qo
f
Partial area infiltration excess P
overland flow
P
P qo
f
Saturation excess overland flow P
P
P qo
qr
qs
13
Runoff generation at a point depends on
• Rainfall intensity or amount
• Antecedent conditions
• Soils and vegetation
• Depth to water table (topography)
• Time scale of interest
These vary spatially which suggests a spatial
geographic approach to runoff estimation
Cell based discharge mapping flow
accumulation of generated runoff
Radar Precipitation grid
Soil and land use grid
Runoff grid from raster
calculator operations
implementing runoff
generation formula’s
Accumulation of runoff
within watersheds
14
Raster calculation – some subtleties
Resampling or interpolation
(and reprojection) of inputs
+ to target extent, cell size,
and projection within
region defined by analysis
mask
=
Analysis mask
Analysis cell size
Analysis extent
Spatial Snowmelt Raster Calculation Example
The grids below depict initial snow depth and average temperature over a day for an area.
100 m 150 m 150 m
100 m
100 m
100 m
150 m
40 50 55
40 50 55
4 6
150 m
4 6
42
42
47
47
43
43
2 2
4 4
42
42 44
44 41
41
(a) Initial snow depth (cm) (b) Temperature (oC)
One way to calculate decrease in snow depth due to melt is to use a temperature index
model that uses the formula
D new D old m T
Here Dold and Dnew give the snow depth at the beginning and end of a time step, T gives
the temperature and m is a melt factor. Assume melt factor m = 0.5 cm/OC/day.
Calculate the snow depth at the end of the day.
15
New depth calculation using Raster
Calculator
“snow100” - 0.5 * “temp150”
Example and Pixel Inspector
16
The Result
• Outputs are
on 150 m grid.
38 52
• How were
values
obtained ?
41 39
Nearest Neighbor Resampling with
Cellsize Maximum of Inputs
100 m
40 50 55
40-0.5*4 = 38
42 47 43
55-0.5*6 = 52
38 52
42 44 41
42-0.5*2 = 41
41-0.5*4 = 39 41 39
150 m
4 6
2 4
17
Scale issues in interpretation of
measurements and modeling results
The scale triplet
a) Extent b) Spacing c) Support
From: Blöschl, G., (1996), Scale and Scaling in Hydrology, Habilitationsschrift, Weiner Mitteilungen Wasser Abwasser Gewasser, Wien, 346 p.
From: Blöschl, G., (1996), Scale and Scaling in Hydrology, Habilitationsschrift, Weiner Mitteilungen Wasser Abwasser Gewasser, Wien, 346 p.
18
Use Environment Settings to control the scale
of the output
Extent
Spacing & Support
Raster Calculator “Evaluation” of “temp150”
4 4 6 6 6
2 4 4
2 4
2 4 4
Nearest neighbor to the E and S
has been resampled to obtain a
100 m temperature grid.
19
Calculation with cell size set to 100 m grid
“snow100” - 0.5 * “temp150”
• Outputs are on
100 m grid as
38 47 52 desired.
• How were
41
41 45 these values
obtained ?
41 42 39
100 m cell size raster calculation
100 m
40-0.5*4 = 38
40 50 55 50-0.5*6 = 47
55-0.5*6 = 52
42 47 43
42-0.5*2 = 41
38 47 52
47-0.5*4 = 45
42 44 41 43-0.5*4 = 41
41 45 41
42-0.5*2 = 41
150 m
4 6 6 44-0.5*4 = 42
41 42 39
4 6 41-0.5*4 = 39
2 4 4
2 4 Nearest neighbor values resampled to
2 4 4 100 m grid used in raster calculation
20
What did we learn?
• Raster calculator automatically uses
nearest neighbor resampling
• The scale (extent and cell size) can be set
under options
• What if we want to use some other form of
interpolation? From Point
Natural Neighbor, IDW, Kriging,
Spline, …
From Raster
Project Raster (Nearest, Bilinear,
Cubic)
Interpolation
Estimate values between known values.
A set of spatial analyst functions that predict values for a
surface from a limited number of sample points creating a
continuous raster.
Apparent improvement in resolution may not
be justified
21
Interpolation
methods
• Nearest neighbor
• Inverse distance 1
z zi
weight ri
• Bilinear
z (a bx )(c dy)
interpolation
• Kriging (best linear z w iz i
unbiased estimator)
• Spline z ci x e i ye i
Nearest Neighbor “Thiessen”
Spline Interpolation
Polygon Interpolation
22
Interpolation Comparison
Grayson, R. and G. Blöschl, ed. (2000)
Further Reading
Grayson, R. and G. Blöschl, ed. (2000),
Spatial Patterns in Catchment Hydrology:
Observations and Modelling, Cambridge
University Press, Cambridge, 432 p.
Chapter 2. Spatial Observations and
Interpolation
Full text online at:
http://www.catchment.crc.org.au/special_publications1.html
23
Spatial Surfaces used in Hydrology
Elevation Surface — the ground surface
elevation at each point
3-D detail of the Tongue river at the WY/Mont border from LIDAR.
Roberto Gutierrez
University of Texas at Austin
24
Topographic Slope
• Defined or represented by one of the following
– Surface derivative z (dz/dx, dz/dy)
– Vector with x and y components (Sx, Sy)
– Vector with magnitude (slope) and direction (aspect) (S, )
ArcGIS “Slope” tool
dz (a 2d g) - (c 2f i)
dx 8 * x_mesh_spacing
a b c
d e f dz (g 2h i) - (a 2b c)
g h i dy 8 * y_mesh_spacing
2 2
rise dz dz rise
deg atan
run dx dy run
25
ArcGIS Aspect – the steepest downslope
direction
dz
dz / dx
dy atan
dz / dy
dz
dx
30 Example
a b c dz (a 2d g) - (c 2f i)
80 74 63 dx 8 * x_mesh_spacing
(80 2 * 69 60) (63 2 * 56 48)
d e f 145.2o
69 67 56 8 * 30
0.229
g h i
60 52 48 dz (g 2h i) - (a 2b c)
dy 8 * y_mesh_spacing
(60 2 * 52 48) (80 2 * 74 63)
Slope 0.229 2 0.329 2 8 * 30
0.401 0.329
atan (0.401) 21.8o
0.229 180o
Aspect atan 34.8
o
0.329 145.2o
26
Hydrologic Slope (Flow Direction Tool)
- Direction of Steepest Descent
30 30
80 74 63 80 74 63
69 67 56 69 67 56
60 52 48 60 52 48
67 48 67 52
Slope: 0.45 0.50
30 2 30
Eight Direction Pour Point Model
32 64 128
16 1
8 4 2
ESRI Direction encoding
27
Limitation due to 8 grid directions.
The D Algorithm
Proportion Steepest direction
flowing to downslope
neighboring Proportion flowing to
grid cell 4 is neighboring grid cell 3
1/(1+2) is 2/(1+2)
3 2
4 2 1
Flow
direction.
5 1
6 8
7
Tarboton, D. G., (1997), "A New Method for the Determination of Flow Directions and
Contributing Areas in Grid Digital Elevation Models," Water Resources Research,
33(2): 309-319.) (http://www.engineering.usu.edu/cee/faculty/dtarb/dinf.pdf)
28
The D Algorithm
Steepest direction
downslope
3 2
4
2
e e
0 1 1 atan 1 2
5 1 e0 e1
2 2
8 e e e e
6
7 S 1 2 0 1
If 1 does not fit within the triangle the angle is chosen along the steepest
edge or diagonal resulting in a slope and direction equivalent to D8
D∞ Example
30
80 74 63 e e
1 atan 7 8
e0 e7
eo
69 67 56 52 48
atan 14.9
o
67 52
e7 e8
60 52 48
2 2
284.9o 52 48 67 52
S
14.9o 30 30
0.517
29
Key Spatial Analysis Concepts
• Contours and Hillshade to visualize topography
Zonal Average of Raster over
Subwatershed
30
Subwatershed Precipitation by
Thiessen Polygons
• Thiessen Polygons
• Feature to Raster (Precip
field)
• Zonal Statistics (Mean)
• Join
• Export to DBF (Excel)
Subwatershed Precipitation by
Interpolation• Kriging (on Precip
field)
• Zonal Statistics
(Mean)
• Join
• Export
31
Runoff Coefficients
• Interpolated precip for each
subwatershed
• Convert to volume, P
• Sum over upstream
subwatersheds
• Runoff volume, Q
• Ratio of Q/P
Watershed HydroID's
Subwatershed Precip from Thiessen Polygons Plum Ck at Lockhart, TX 330
Mean Precip Volume Blanco Rv nr Kyle, TX 331, 332
HydroID Area (m^2) Precip (in) (ft^3) San Marcos Rv at Luling, TX 331,332,333,336
330 2.91E+08 36.37 9.49E+09
331 9.21E+08 37.82 3.12E+10
332 1.49E+08 40.48 5.42E+09
333 1.27E+08 40.48 4.60E+09 Precip
336 9.80E+08 37.59 3.31E+10 Flow volume
Flow Volume Subwater‐ subwater‐ Runoff
Watersheds (cfs) (ft^3) sheds shed sum ratio
Plum Ck at Lockhart, TX 49.00 1.5E+09 330 9.49E+09 0.16303
Blanco Rv nr Kyle, TX 165.00 5.2E+09 331, 332 3.67E+10 0.14203
331, 332,
San Marcos Rv at Luling, TX 408.00 1.3E+10 333, 336 7.43E+10 0.17325
Summary Concepts
• Grid (raster) data structures represent
surfaces as an array of grid cells
• Raster calculation involves algebraic like
operations on grids
• Interpolation and Generalization is an
inherent part of the raster data
representation
32
Summary Concepts (2)
• The elevation surface represented by a grid digital
elevation model is used to derive surfaces
representing other hydrologic variables of interest
such as
– Slope
– Drainage area (more details in later classes)
– Watersheds and channel networks (more details
in later classes)
Summary Concepts (3)
• The eight direction pour point model
approximates the surface flow using eight
discrete grid directions.
• The D vector surface flow model
approximates the surface flow as a flow
vector from each grid cell apportioned
between down slope grid cells.
33