Spatial Analysis Using Grids GIS in Water Resources Fall 2014 by Ayse Kilic with materials from...

Post on 25-Dec-2015

214 views 1 download

Tags:

Transcript of Spatial Analysis Using Grids GIS in Water Resources Fall 2014 by Ayse Kilic with materials from...

Spatial Analysis Using GridsGIS in Water Resources

Fall 2014

by Ayse Kilic with materials fromDavid G. Tarboton, Utah State University and from ESRI

software

Spatial Analysis Using Grids

• Continuous surfaces or spatial fields representation of geographical information

• Grid data structure for representing numerical and categorical data

• Map algebra raster calculations • Interpolation • Calculate slope on a raster using

– ArcGIS method based in finite differences– D8 steepest single flow direction– D steepest outward slope on grid centered triangular facets

Learning Objectives

• http://resources.arcgis.com/en/help/main/10.2/#/Raster_dataset_zones_and_regions/009t00000008000000/ Raster and Images, starting from "Introduction/What is raster data" to end of " Fundamentals of raster data/Rasters with functions"

Readings – at http://resources.arcgis.com/en/help/

Readings – at http://resources.arcgis.com/ • What is the ArcGIS Spatial Analyst extension and Essential ArcGIS Spatial

Analyst extension vocabulary http://resources.arcgis.com/en/help/main/10.2/index.html#/What_is_the_ArcGIS_Spatial_Analyst_extension/005900000001000000/

x

dx)y,x(f)y(f

x

y

f(x,y)

Two fundamental ways of representing geography are discrete (separated) objects and fields.

The discrete object view represents the real world as objects with well defined boundaries in empty space.

The field view represents the real world as a finite number of variables, each one defined at each possible position.

(x1,y1)

Points Lines Polygons

Continuous surface

Numerical representation of a spatial surface (field)

Grid or

Raster

TIN Contour and flowline

Fields can represent any number of two or three dimensional surfaces (any kind of gridded data)

Discrete (vector) and continuous (raster) data

Images from http://resources.arcgis.com/en/help/main/10.1/index.html#/Discrete_and_continuous_data/009t00000007000000/

Discrete is also called thematic, categorical, or discontinuous data

Discrete

Continuous

Continuous

Raster and Vector Data

Point

Line

Polygon

Vector Raster

Raster data are described by a cell grid, one value per cell

Zone of cells

Line as a Sequence of Cells

How do we define a line (stream) using grid cells?

Polygon as Zone of Grid Cells

http://resources.arcgis.com/en/help/main/10.2/index.html#/How_features_are_represented_in_a_raster/009t00000006000000/

When we use grid cells, we have to break down polygon shapes like lakes into individual grid cellsWe start on the left with a accurate picture of well-defined boundaries and we end up with a pixelated view on the right

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

A grid defines geographic space as a mesh of identically-sized square cells. Each cell holds a numeric value that measures a

geographic attribute (like elevation) for that unit of space.

549 542 538 534 528 522 518 512548 541 536 530 524 518 515 511558 551 542 532 525 519 515 512571 559 551 544 537 530 524 514585 583 576 563 549 534 519 505606 593 578 563 546 530 513 497612 600 584 568 550 533 516 497611 600 586 568 551 533 515 498601 592 580 565 545 528 516 508594 585 577 570 560 547 534 521614 605 597 588 575 560 544 527622 611 603 595 578 563 545 527620 610 600 592 582 570 554 537627 616 604 593 584 574 564 551631 618 605 594 582 572 566 557628 616 603 591 577 566 558 552627 614 602 593 582 572 561 549617 610 600 590 582 573 562 549613 603 594 582 575 567 558 548610 601 590 579 568 559 553 546605 597 586 578 569 560 551 542

Elevation (meter) for part of Upper Klamath Basin, OR

The grid values

There are two types of grids: integer and floating pointUse integer grids to represent discrete data (land use classes)Use floating-point grids to represent continuous data (elevation) Grids may have associated attribute table

Attribute tables describe overall characteristics for the entire grid

The grid• Grid is defined by

extent, spacing, and perhaps a no data value

• Extent is – the Number of rows,

Number of columns– Top-left and bottom-

right coordinates

• Spacing is the Cell size (X and Y)

• NODATA is outside the extent or is undefined

Numberof

rows

Number of Columns

(X,Y) Cell sizeNODATA cell

NODATA Cells

Networks Using Cells

The same number identifies cells that are in the same reach

Grids Using Floating Point (Decimal Numbers)

Continuous data surfaces using floating point or decimal numbersExamples are ET (evapotranspiration), elevation, precipitation

Integer valued grids to represent zones

Examples are Landuse classes, soil types, political units

Value Attribute Table (VAT) to summarize categorical (integer) grid data

Attributes of grid zones

How are values for Rasters determined?

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

There are three ways that a “Value” for a grid cell is determined

Cell size of raster data

The cell must be small enough to capture the required detail but large enough so computer storage and analysis can be performed efficiently.

Discrete data

The level of detail (of features/phenomena) represented by a raster is dependent on the cell size. (Cell size matters!!!) Estimates of area

Integer Raster Generalization How do we determine the value for the cell?

Central point ruleLargest share rule

Whatever is happening at the centerWinner takes it all!

Map Algebra/Raster Calculation

Precipitation-

Losses (Evaporation + Infiltration)

=Runoff5 2

2 3

2 43 3

7 65 6

-

=

Cell by cell evaluation of mathematical functions

Example

5-3= 2

Runoff generation processes

Infiltration excess overland flowaka Horton overland flow

Partial area infiltration excess overland flow

Saturation excess overland flow

PP

P

qrqs

qo

PP

P

qo

f

PP

P

qo

f

f

Runoff generation at a point depends on

• Rainfall intensity or amount• Antecedent moisture conditions• Soils and vegetation type• Depth to water table (topography)• Time scale of interest

These factors vary spatially. That suggests using a spatial approach (GIS) to runoff estimation

Cell based generation of runoff and routing discharge

Radar Precipitation grid

Soil and land use grid

Runoff grid from raster-based calculations implementing runoff generation formulas

We use a DEM to show accumulation and routing of runoff within watersheds

Raster calculation – some complications

+

Sometimes different layers have different:

• Cell size

• Extent

• Projection

We need to tell Arc how to combine these data layers. We may need to reproject, and resample to a common cell size.

Raster calculation – some complications

Analysis extent

+

=

Analysis cell size

Analysis mask (Domain)

An Analysis Mask is used to tell Arc how to resample or interpolate (and reproject) inputs to the target extent, cell size, and projection

Spatial Snowmelt Raster Calculation Example

The grids below depict initial snow depth and average temperature over a day for an area.

40 50 55

42 47 43

42 44 41

100 m

100

m

(a) Initial snow depth (cm)

4 6

2 4

150 m

150

m

(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

TmDD oldnew

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.

40 50 55

4347

414442

42

100 m

100

m

4

2 4

6

150 m

150

m

Lets Experiment with this in ArcGIS

temp.asc

ncols 2nrows 2xllcorner 0yllcorner 0cellsize 150NODATA_value -99994 62 4

snow.asc

ncols 3nrows 3xllcorner 0yllcorner 0cellsize 100NODATA_value -999940 50 5542 47 4342 44 41

New depth calculation using Raster Calculator

“snow100” - 0.5 * “temp150”

Environment SettingsTell Arc how to resample or interpolate (and reproject) inputs to the target extent, cell size

Example and Pixel Inspector

38 52

41 39

The Result for Snow Depth on Day 2

• Outputs are on 150 m grid.

• How were values obtained ?

When input layers have different cell sizes

40 50 55

4347

414442

42

100

m

4

2 4

6150

m

38 52

41 39

When we have two different input cell sizes, we have to specify one of them for the output cell size. If you specify using the layer having the maximum cell size, then the input layers having the smaller cell size will be resampled. The default resampling in Arc uses Nearest Neighbor

The NN resampling grabs the input cell that is closest to the center of the output cell

150

m

See next slide

Output raster

Nearest Neighbor (NN) Resampling using Cell size based on “Maximum of Inputs”

40 50 55

4347

414442

42

100

m

40 55

42 41

The NN resampling grabs the input cell that is closest to the center of the output cell

There are Nine 100 m cells . Only 4 of them will be selected for the calculations (because we use NN). Note that some spatial information is lost during resampling.

Red symbols are centers of the 150 m cells

Resampling the 100 meter input to 150 meters using NN

40 55

42 41

Nearest Neighbor (NN) Resampling using Cell size based on “Maximum of Inputs”

4

2 4

6150

m

40-0.5*4 = 38

55-0.5*6 = 5238 52

41 39

42-0.5*2 = 41

41-0.5*4 = 39

However, only 4 of original snow depths were utilized because we use NN.

Now we can make calculations with all the inputs and outputs at 150 meter

Nearest Neighbor (NN) Resampling using Cell size based on “Maximum of Inputs”

40 50 55

4347

414442

42

100

m

4

2 4

6150

m

40-0.5*4 = 38

55-0.5*6 = 5238 52

41 39

42-0.5*2 = 41

41-0.5*4 = 39

We could have combined the resampling and calculations into one step as shown here (this is what Arc Does)

There are Nine 100 m cells Only 4 of them will be selected for the calculations (because we use NN)

Red symbols are centers of the 150 m cells

From: Blöschl, G., (1996), Scale and Scaling in Hydrology, Habilitationsschrift, Weiner Mitteilungen Wasser Abwasser Gewasser, Wien, 346 p.

Cell size and sampling frequency need to agree with the behavior of our data

We need to sample more frequently to capture high frequency changes

We need to sample a longer series to capture the full data extent

We need to use a smaller cell size to capture the full range of values

Interpolation and Resampling• 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

Interpolation methods

• Nearest neighbor• Inverse distance

weight• Bilinear

interpolation• Kriging (best linear

unbiased estimator)• Spline• Cubic convolution

ii

zr

1z

)dyc)(bxa(z

iizwz

ii eei yxcz

Known data points are large red circles

(For resampling only)

Resampling Methods in Arc

4 6

2 4

5

3

3

54

4 6

2 4

Spacing & Support

Lets redo the calculations at 100 m resolution

Resample 150 m to 100 m to get consistent cell size

Black values are originalThe white values are resampled

Calculation with consistent 100 m cell size grid“snow100” - 0.5 * “temp100”

38 52

41 39

47.5

40.5

42.5

40.545

Cell by cell snowmelt calculations using 100 m cell size

40 50 55

4347

414442

42

100

m15

0 m

40-0.5*4 = 38

42-0.5*3 = 40.538 52

41 39

43-0.5*5 = 40.5

41-0.5*4 = 39

47.5

40.5 45 40.5

42.5

50-0.5*5 = 47.5

55-0.5*6 = 52

47-0.5*4 = 45

42-0.5*2 = 41

44-0.5*3 = 42.54

6

2 4

5

3

3

54

4

6

2 4 Two inputs on the left have the same 100 m resolution

Illustration of different Interpolation techniques

When you have to create a grid from a limited set of data points

Nearest Neighbor “Thiessen” Polygon Interpolation Spline Interpolation

Point to Raster Interpolation

Grayson, R. and G. Blöschl, ed. (2000)

Interpolation Comparison

ThiessenThin plate spline

Inverse Distance Squared Kriging (zero nugget, large range)

Sixth order polynomial Kriging (different nugget and range paramters)

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

http://www.catchment.crc.org.au/special_publications1.html

Full text online at:

Spatial Surfaces used in Hydrology

Elevation Surface — the ground surface elevation at each point

Slope Handout

Determine the length, slope and azimuth of the line AB.

http://snr.unl.edu/kilic/giswr/2014/Slope.pdf

3-D detail of the Tongue river at the WY/Montana border from LIDAR.

Roberto GutierrezUniversity of Texas at Austin

Topographic Slope

• Used to determine how water flows downhill and concentrates into streams

• Topographic slope can be determined from a DEM

Topographic Slope

• There are three alternative sets of inputs (choose one)– Surface derivative z (dz/dx, dz/dy)– Vector with x and y components (Sx, Sy). Slope in x and y direction.– Vector with magnitude (slope) and direction (aspect) (S, )

• Calculates the maximum rate of change in value from that cell to its neighbors

• Calculated for each cell• Represents the rate of change of elevation for

each digital elevation model (DEM) cell. It's the first derivative of a DEM

• The lower the slope value, the flatter the terrain; the higher the slope value, the steeper the terrain.

ArcGIS “Slope” tool

Definition of X, Y, and Z in 3D space

Z axis is the direction that elevation changes (up or down)

Y axis is the direction that Y has a changing value (North-South in ArcGIS)X axis is the direction that X

has a changing value (East-West in ArcGIS)

Origin is the location of the point of interest (pixel or grid cell)

X, and Y are horizontal distancesZ is the vertical distance

The X, Y, Z axes are at right angles to one another

Definition of Slope

Run is the horizontal distance calculated using X and YRise is the vertical distance calculated using Z (elevation)Slope ranges (-900, +900) or (-infinity %, +infinity %)

(0)

* 100 (%)

𝑇𝑎𝑛(𝛳 )=𝑅𝑖𝑠𝑒𝑅𝑢𝑛

How Slope works

Run is the horizontal distance calculated using X and YRise is the vertical distance calculated using Z (elevation)

(0)

* 100 (%)

When the angle () is 45 degrees, the rise is equal to the run, and the percent rise is 100 percent

When the slope angle ) approaches vertical (90 degrees), the percent rise (slope) begins to approach infinity.

Pythagorean theoremUsed to calculate Run where a =ΔY and b = ΔX

Definition of Aspect

Δ𝑥

Δ 𝑦 𝛼 = aspect, angle defined as degrees clockwise from North

𝑥

𝑦

If I pour water on the ground, which direction does it flow?Identifies the direction where slope is maximum (slope is the steepest)Aspect identifies the downslope direction of the maximum rate of change in value from each cell to its neighbors

Y axis is the direction that Y has a changing value (North-South in ArcGIS)

X axis is the direction that X has a changing value (East-West in ArcGIS)

This is my grid cell location

𝑇𝑎𝑛(𝛼)=∆ 𝑋∆𝑌

𝛼=𝐴𝑟𝑐𝑇𝑎𝑛∆𝑋∆𝑌

= Aspect  

Invert that top equation and solve for α by Inverting the Tangent Function (ArcTan)

The other way to write ArcTan is Tan-1

Definition of Aspect

Aspect = Convert from radians to degrees (180/π)

Δ𝑥

Δ 𝑦 𝛼 = aspect, angle defined as degrees clockwise from North

𝑥

𝑦

The rate of change in the y direction for cell e is calculated with the following algorithm

ArcGIS “Slope” tool

a b c

d e f

g h ix

y

gd

ah

eb

if

c∆

2∆ xy

The rate of change in the x direction for cell e is calculated with the following algorithm

Calculates slope for each cell. In this illustration, it is for Cell “e”For each cell, the Slope tool calculates the maximum of the rate of change in value from that cell to each of its eight neighbors

dzd y

=(g+2h+i )− (a+2b+c )

8 ∆

ArcGIS “Slope” tool

gd

ah

eb

if

c∆

𝑎−𝑐2∆ 𝑑− 𝑓

2∆𝑔−𝑖2∆

2∆ xy

𝑎−𝑐2 ∆

+𝑑− 𝑓2∆

2+

𝑑− 𝑓2∆

+𝑔−𝑖2∆

22

The two equations for dz/dx and dz/dy are simplified from this first equation.The basis for that equation is illustrated in the Figure and represents an average of central finite differences over each of the three rows of cells, with the middle row counting twice as it appears in averages on each side.

=

ArcGIS Aspect – the steepest downslope direction

dx

dz

dy

dz

dy/dz

dx/dzatan

In Arc, with grid cells it is easiest to calculate Aspect using the ratio of dz/dx to dz/dy.We use Arc tangent function to determine the aspect angle.

𝛼

Example for topographic slope

30

80 74 63

69 67 56

60 52 48

a b c

d e f

g h i

m/m 229.030*8

)4856*263()6069*280(

acing x_mesh_sp* 8

i) 2f (c - g) 2d (a

dx

dz

m/m329.030*8

)6374*280()4852*260(

cingy_mesh_spa * 8

c) 2b (a-i) 2h (g

dy

dz

o8.21)401.0(atan

145.2o

m/m401.0

329.0229.0)/()/( 2222

dydzdxdzSlope

Mesh spacing=30 mSlope/Aspect at cell e?

Slope in degrees

Example for Aspect30

80 74 63

69 67 56

60 52 48

a b c

d e f

g h i

m/m 229.030*8

)4856*263()6069*280(

acing x_mesh_sp* 8

i) 2f (c - g) 2d (a

dx

dz

m/m329.030*8

)6374*280()4852*260(

cingy_mesh_spa * 8

c) 2b (a-i) 2h (g

dy

dz

o

dydz

dxdzAspect 8.34

329.0

229.0atan

/

/atan

oo 2.145180

145.2o

Mesh spacing=30 mSlope/Aspect at cell e?

The Atan function is multivalued on the full circle and only unique in a range of 180 degrees. To unambiguously determine the direction from two components you really need the atan2 function that keeps the sign on y and x components separately.

Specifically, let y = y component of a vectorx = x component of a vectoratan(x/y) gives the direction of the vector as an angle (with the ratio x/y since angle here is measured from north). But x/y is the same value if y is positive and x negative, or x positive and y negative. So once you take the ratio x/y, if you get a negative number you do not know which (y or x) was negative.

A way to resolve this isangle = atan(x/y)if(0 < angle < 180 and x < 0) then aspect = angle + 180 # flip the direction because x is negative if angle is in positive x directionelse aspect = angleendif

32

16

8

64

4

128

1

2

D8 steepest single flow direction(Eight Direction Pour Point Model)

ESRI Direction encoding (ArcGIS)

In a gridded system, water can only flow to one of eight adjacent cells

The direction of flow is determined by the direction of steepest descent:

Maximum_drop = change_in_z-value / distance * 100

80 74 63

69 67 56

60 52 48

30

45.0230

4867

50.0

30

5267

Slope:

Hydrologic Slope (Flow Direction Tool) Find Direction of Steepest Descent (ArcGIS)

80 74 63

69 67 56

60 52 48

30

For diagonal direction, the denominator for slope includes square root of 2

Slope:

?

Limitation due to 8 grid directions.

The true flow direction follows the red arrow. However, we can only choose one of the blue arrows because we have to use one of eight adjacent cells.

Flowdirection.

Steepest directiondownslope

1

2

1

234

5

67

8

Proportion flowing toneighboring grid cell 3is 2/(1+

2)

Proportionflowing toneighboringgrid cell 4 is

1/(1+2)

The D Algorithm

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)

Steepest direction downslope

1

2

1

2 3

4

5

6 7

8

0

The D Algorithm

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

10

211 ee

eeatan

210

221 eeee

S

D∞ Example30

eo

e7 e8

o

70

871

9.145267

4852atan

ee

eeatan

14.9o284.9o

517.0

30

5267

30

4852S

22

80 74 63

69 67 56

60 52 48

The tool is available at http://hydrology.usu.edu/taudem/taudem5/documentation.html

210

221 eeee

S

ArcGIS.Com ready to use maps including elevation services

http://www.arcgis.com/features/maps/earth.html

Land Cover

Soils

Elevation

Elevation Services

http://elevation.arcgis.com/arcgis/services

CyberGIS Apps

http://sandbox.cigi.illinois.edu/home/

Big Spatial Data

77

A YouTube Videohttp://www.youtube.com/watch?v=hrJ_cZkG-Xs

Viewshed

From http://www.innovativegis.com/basis/mapanalysis/Topic15/Topic15.htm

The locations that are visible from a viewer location. Line of sight analysis. Useful for cell coverage and visual exposure analyses

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

Summary Concepts (2) • The elevation surface represented by a grid digital

elevation model is used to derive slope important for surface flow

• 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.