Basic Concepts:
GIS Data Models
(Raster)
ENVR
Raster
• Raster Data Model
• Raster Data Model (Examples)
• Raster Data Structure
• Raster Analysis and Tools
• Raster Storage (Compression)
• Raster Data Sources
Raster Data Model
• Derive from formulation that real
world - it has spatial elements
and objects fills those elements
•Used to represent geographic
space
•Spatial locations are implicit
•Relationships between
entities/objects are explicit
Raster Data Model
Raster Data
•Points associated with single grid cell
•Lines are a connected sequence of cells
•Areas are a sequence of interconnected cells
•An object is represented by a group of cells
Raster Data -> Spatial Data
• Rows and columns containing the attribute value
associated with each data layer
Raster Data -> Spatial Data
• The row/column location of the data value
represents the spatial position
Spatial Data
• Exact geographic position is typically established
with “header information” before the rows and
columns of data
ESRI Grid Data File
(Example from ESRI Grid Data File)
Spatial Data
• Also need knowledge of what the values represent
(e.g., elevation in meters); typically part of the
metadata
The Raster structure illustrates points, lines, and areas utilizing the
confines of cells for representing geographic areas.
Each cell has a value
Raster Data Model (Examples)
1. Digital Elevation Model (DEM)
2. Satellite Images
3. Digital Orthophotos
4. Scanned Maps
5. Graphics Files (scanned graphics)
DEM
Digital Orthophoto
Satellite Image
Raster Data Structures
• grid often has its origin in the upper left but note:
• State Plane and UTM, lower left
• lat/long & Cartesian, center
Raster Data Structures
• single values associated with each cell
• typically 8 bits assigned to values therefore 256 possible
values (0-255)
• rules needed to assign value to cell if object does
not cover entire cell
• majority of the area (for continuous coverage feature)
• value at cell center
• ‘touches’ cell (for linear feature such as road)
• weighting to ensure rare features represented
Rules needed to assign value to cell if
object does not cover entire cell
Raster Data Structures
• choose raster cell size
• smallest feature to map (smallest feature called minimum
mapping unit or resel--resolution element)
Raster Data Structures:
• raster orientation: angle between true north
and direction defined by raster columns
• class: set of cells with same value (e.g.
type=sandy soil)
• zone: set of contiguous cells with same value
• neighborhood: set of cells adjacent to a target
cell in some systematic manner
Representing Data using Raster Model
• area is covered by grid with (usually) equal-
sized cells
• location of each cell calculated from origin of
grid:
• “two down, three over”
• cells often called pixels (picture elements);
raster data often called image data
• attributes are recorded by assigning each cell a
single value based on the majority feature
(attribute) in the cell, such as land use type.
Representing Data using Raster Model
• easy to do overlays/analyses, just by
‘combining’ corresponding cell values:
“yield= rainfall + fertilizer”
• simple data structure:
• directly store each layer as a single table
(basically, each is similar to a “spreadsheet”)
• computer data base management system not required
(although many raster GIS systems incorporate them)
Raster Analysis and Tools
Surface Analysis
Surface Analysis
tools derive
useful geospatial
information from
elevation
surfaces such as
•Slope
•Aspect
•Hillshade
•Viewshed
Raster Analysis and Tools
Prepare data for analysis
• organize your workspaces
• determine the tools you need
• identify data required for your analysis
• convert vector to raster
• reclassify data
Raster Analysis and Tools
Converting data
Raster Analysis and Tools
Reclassify raster data
Reclassification is the process of reassigning a value, arrange of values, or
a list of values in a raster to new output values.
Why reclassify:
One reason is to set specific values to NoData to exclude them from
analysis. Other reasons are to change values in response to new
information or classification schemes, or to replace one set of values
with an associated set (for example, to replace values representing soil
types with pH values). Still another reason is to assign values of
preference, priority, sensitivity, or similar criteria to a raster.
Reclassification of categorical data
involves replacing individual values with
new values. For example, land use
values can be reclassified into
preference values of low (1), medium
(2), and high (3). Land use values not
desired in the analysis are given values
of NoData.
Raster Analysis and Tools
Visualising surface data
How do you visualize three-dimensional surface data in a
two-dimensional environment?
Answer:
By using hillshades and contours.
Hillshade
• Hillshading illuminates surface features based on the
position of an imaginary light source, casting shadows
that make surface features recognizable.
• Hillshaded relief maps are perhaps the most realistic
looking way of representing a three-dimensional world
in a two-dimensional environment.
Hillshading
Hillshading computes surface illumination as values from 0 to 255
based on a given compass direction to the sun (azimuth) and a
certain altitude above the horizon (altitude).
Contours
Contour lines can be used to represent surfaces. A contour line is a
line following an equal value.
Contours can represent many types of data. Lines connecting surface or
sample points of equal value are known as isolines. The following are all
examples of different types of isolines:
•Isobar: Equal barometric pressure
•Isochron: Connecting lines of equal time
•Isohel: Equal duration of sunshine
•Isohyet: Equal rainfall
•Isoseismal: Earthquake shock intensity
•Isotherm: Equal temperature
•Isogonic: Equal magnetism
Raster Analysis and Tools
Driving data from surfaces
? Rise = 150
Run=300
? SLOPE (Degrees & %)
Slope is a measure of the steepness of
a surface and may be expressed in
either degrees or percent of slope. In
this example, the red cells show steep
areas and the green cells show flat
areas.
Raster Analysis and Tools
Slope Tool
Used to analyze the
angular component
of a terrain –
Can answer
questions like
where to build a
structure based on
the degree of slope
and Solar Panel tilt
angle
Raster Analysis and Tools
Aspect Tool
Aspect tools
helps identify
slope direction
or the compass
direction a hill
faces.
Raster Analysis and Tools
Hillshade Tool
Hillshade is used
to determine the
Hypothetical
illumination of a
surface.
For e.g. hillshade
can be used to
determine the
length of time and
intensity of the
sun in a given
location
Raster Analysis and Tools
Viewshed Tool
Viewshed
identifies the
cells in an
input raster
that can be
seen from one
or more
observation
points or lines
Raster Analysis and Tools
Surface Creation
Use the following interpolation tools
to create a surface from sample
data measurements
•Spline
•Inverse Distance Weighting
•Kriging (Ordinary, Universal)
Interpolation
The purpose: to produce a continuously varying smooth surface
over a region using point values at particular locations as
inputs.
Surface interpolation is carried out in hydrology for constructing
maps of variables, such as water table elevation, annual or
storm precipitation, air temperature, and evaporation.
Interpolation
The unknown value of the cell is
based on the values of the
sample points as well as the
cell's relative distance from
those sample points.
In this example, a straight line
passes through two points of
known value. You can estimate
the point of unknown value
because it appears to be
midway between the other two
points. The interpolated value of
the middle point could be 9.5.
Interpolation
methods
• Nearest neighbor
• Inverse distance weight
• Bilinear interpolation
• Kriging (best linear
unbiased estimator)
• Spline
Raster Analysis and Tools
IDW
Inverse Distance Weighting (IDW) is a method of interpolation that assumes
each sample point has a local influence that diminishes with distance. In
estimating the value for a given cell, this method gives greater weight to points
closer to the cell than to those farther away.
The term "inverse distance" arises from the
assumption that the weight is inversely
proportional to the distance between the
centre of the cell to the measured point to the
power r. Usually r = 2, which produces inverse
distance squared weighting, but occasionally
other values of r are chosen.
Raster Analysis and Tools
Inverse Distance Weighted
The weight (influence) of a sampled
data value is inversely proportional to
its distance from the estimated value
Raster Analysis and Tools
In physics, an inverse-square law is any physical law stating that
a specified physical quantity or intensity is inversely proportional to
the square of the distance from the source of that physical quantity.
The fundamental cause for this can be understood as geometric
dilution corresponding to point-source radiation into three-
dimensional space (see diagram). Mathematically formulated:
It can also be mathematically
expressed as:
Inverse Distance Weighted
(Example)
n z
i
p
i 1
d
z ( x, y ) i
or z ( x , y ) z 1
with
1
i i i
n
d
p
i 1
i
100
IDW:
4 Closest 3
3 160 neighbors
2
200
Inverse Distance Weighted
(Example)
Weights
A 1 / (42) = .0625
B 1 / (32) = .1111
C 1 / (22) = .2500
A = 100
4
B = 160
3
2
C = 200
Inverse Distance Weighted
(Example)
Weights Weights * Value
A 1 / (42) = .0625 .0625 * 100 =
B 1 / (32) = .1111 6.25 .1111 * 160 =
C 1 / (22) = .2500 17.76 .2500 * 200 =
50.00
Total = .4236 A = 100
6.25 +17.76 + 50.00 = 74.01 4
B = 160
3
74.01 / .4236 = 175
2
C = 200
Spatial interpolation and IDW
(Further Example)
• Noise is louder closer to a siren than further away.
• When it’s raining, it’s more likely to rain 1 meter away compared to
500 meters away.
Spatial interpolation and IDW
• In the example below, the red points have known elevation values. The
other points will be interpolated. If you wanted to measure the purple
point, you can set up your interpolation so that it takes a fixed or variable
number of points. In this example, it uses a fixed number of points of 3
and uses the three closest points.
Spatial interpolation and IDW
• We use the 3 closest points in this example:
Spatial interpolation and IDW
• For a power of 1, that cell value is equal to:
((12/350) + (10/750) + (10/850)) / ((1/350) + (1/750) + (1/850)) = 11.1
Spatial interpolation and IDW
• For a power of 2, that cell value is equal to:
= ((12/3502) + (10/7502) + (10/8502)) / ((1/3502) + (1/7502) + (1/8502)) = 11.4
Spatial interpolation and IDW
IDW
[Link]
Raster Analysis and Tools
Spline
Unlike IDW, which interpolates values from sample
points near the processing cell, Spline models surface
by forming a mathematical function over the domain.
Spline is intended to fit a minimum-curvature
surface to the sample points. The surface passes
exactly through the sample points.
Before there were computers to make it easy to
estimate surface values, draftsmen used flexible
rulers to manually fit a surface over the sample points.
These rulers were called splines.
Because it generates smooth surfaces, the Spline
method is best suited to sample data that varies
smoothly, for instance, groundwater elevation.
It's not appropriate if there are large changes in value
within a short horizontal distance.
Linear Spline - Linear Interpolation
Given x0 , y0 , x1 , y1 ,......, x n1 , y n1 x n , y n , fit linear splines to the data. This simply involves
forming the consecutive data through straight lines. So if the above data is given in an ascending
order, the linear splines are given by yi f ( xi )
Figure : Linear splines
[Link]
Quadratic Interpolation
Given x0 , y0 , x1 , y1 ,......, x n1 , y n 1 , x n , y n , fit quadratic splines through the data. The splines
are given by
f ( x ) a1 x 2 b1 x c1 , x 0 x x1
a 2 x 2 b2 x c2 , x1 x x 2
.
.
.
a n x 2 bn x cn , x n 1 x x n
Find a i , bi , ci , i 1, 2, …, n
[Link]
Quadratic Interpolation (contd)
Each quadratic spline goes through two consecutive data points
a1 x 0 b1 x 0 c1 f ( x0 )
2
a1 x12 b1 x1 c1 f ( x1 ) .
.
.
a i xi 1 bi xi 1 ci f ( xi 1 )
2
a i xi bi xi c i f ( xi )
2
.
.
.
a n x n 1 bn x n 1 c n f ( xn 1 )
2
a n x n bn xn cn f ( x n )
2
This condition gives 2n equations
[Link]
Quadratic Splines (contd)
The first derivatives of two quadratic splines are continuous at the interior points.
For example, the derivative of the first spline
a1 x 2 b1 x c1 is 2 a1 x b1
The derivative of the second spline
a 2 x 2 b2 x c 2 is 2 a2 x b2
and the two are equal at x x1 giving
2 a1 x1 b1 2a 2 x1 b2
2 a1x1 b1 2a 2 x1 b2 0
[Link]
Quadratic Splines (contd)
Similarly at the other interior points,
2a 2 x 2 b2 2a3 x 2 b3 0
.
.
.
2ai xi bi 2ai 1 xi bi 1 0
.
.
.
2a n 1 x n 1 bn 1 2a n x n1 bn 0
We have (n-1) such equations. The total number of equations is (2n) (n 1) (3n 1) .
We can assume that the first spline is linear, that is a1 0
57 [Link]
Quadratic Splines (contd)
This gives us ‘3n’ equations and ‘3n’ unknowns. Once we find the ‘3n’ constants,
we can find the function at any value of ‘x’ using the splines,
f ( x) a1 x 2 b1 x c1 , x0 x x1
a 2 x 2 b2 x c 2 , x1 x x 2
.
.
.
a n x 2 bn x cn , x n 1 x x n
[Link]
Kriging
Raster Analysis and Tools
Surface Creation - Kriging
Kriging is based on statistical models that include
autocorrelation.
Weights are based on:
• The distance between the measured points
and the predicted location and
• The overall spatial arrangement among the
points.
Raster Analysis and Tools
Surface Creation - Kriging
Ordinary Kriging
Ordinary kriging is the simplest form of
kriging.
Derives a surface using the values from the
measured locations to predict values for
each other location in the domain
Relies on both statistical and mathematical
methods
Access the uncertainty of the predictions
Based upon random processes with
dependence
Steps
• Calculate the empirical semivariogram
• Fit a model
• Create the matries
• Make prediction
Ordinary Kriging
In our case Z, at point S0, Z (S0) to be calculated
using a weighted average of the known values or
control points:
This estimated value will most likely differ from the actual value at
point S0, and this difference is called the estimation error:
Ordinary Kriging
If no drift exists and the weights used in
the estimation sum to one, then the
estimated value is said to be unbiased. The
scatter of the estimates about the true
value is termed the error or estimation
variance.
Ordinary Kriging
Kriging tries to choose the optimal weights that produce the
minimum estimation error .
Optimal weights, those that produce unbiased estimates and
have a minimum estimation variance, are obtained by
solving a set of simultaneous equations
.
Kriging Example
For example: Z(1,4) is the prediction location
Z(1,5) = 100
Z(si) = µ + ε (si)
µ : mean (no trend)
ε(si): random error
Z(si) is the measured value at the ith location;
Z(1,5) = 100
λi is an unknown weight for the measured value at the ith
location
S0 is the prediction location; e.g. (1,4) in this example
N=5; five measured known values
Minimize the statistical expectation of the following formula:
Kriging equations:
The solution is to minimize the standard errors subject to the
constrained by unbiasedness estimation.
Creating the empirical semivariogram based upon the Euclidean distance:
The empirical semivariance is 0.5 times the difference
squared of the Euclidean distance.
i.e.
0.5 x average[(value at location i – value at location j)2]
• With more measured samples, the number of pairs of locations will
increase rapidly.
• Group the pairs of locations (binning)
• Use lag distance which is calculated using the distance between the two
locations.
(1, 2]
Fitting a model using regression:
Fit to the least-squares regression line; force to positive slope and
pass through zero.
Semivariance = Slope x Distance
Semivariance = Slope x Distance
Semivariance = 13.5 x h
e.g.
The Semivariance for the location (1,5) and (3,4) is:
Semivariance = 13.5 x 2.236 = 30.19
The matrix formula for ordinary kriging is:
Γxλ=g
λ=Γ -1 xg
Γ -1 is the inverse matrix of Γ
g is the vector which indicated the unmeasured location wish to
Predict.
For example: (1,4)
The g vector records the distance among all measured points.
Making Prediction:
λ=Γ -1 xg
Add the products together and you can find the final prediction for
The location (1,4).
102.6218
The weights decrease with distance but are more refined than a
Straight distance weighting since they account for the spatial
arrangement od the data.
Kriging Variance
It is possible to calculate a statistical measure of uncertainty for the
prediction.
Kriging variance:
Multiply each entry in the λ vector times each entry in the g vector and
add them together.
If we assume the kriging standard errors are normally distributed. 95%
prediction intervals can be obtained in the following way:
Kriging Predictor ± 1.96 x sqrt (kriging variance)
The 1.96 comes from the standard normal distribution where 95% of the
probability is contained from -1.96 to 1.96.
Interpretation:
If predictions are made again and again from the same model, in the
long run 95% of the time the prediction interval will contain the value at
the prediction location.
The prediction interval in our example:
Prediction interval ranges from 95.49 to 109.75
(102.62 ± 1.96 x 3.64)
INVERSE DISTANCE WEIGHTED
VS
SPLINE INTERPOLATIONS
VS
KRIGING
[Link]
IDW
The Inverse Distance Weighting interpolator assumes that each input point has a
local influence that diminishes with distance. It weights the points closer to the
processing cell greater than those further away.
ADVANTAGES
•Quick and simple
•Fast
DISADVANTAGES
•Cannot estimate prediction errors
•Produce “bulls eyes” around data locations
Note: The optimal power (p) value is determined
by minimizing the root mean square prediction
error (RMSPE).
Spline
Spline estimates values using a mathematical function that minimizes overall surface
curvature, resulting in a smooth surface that passes exactly through the input points.
ADVANTAGES
• Creates a smooth surface effect.
DISADVANTAGES
• When the sample points are close together and have extreme differences in
value, Spline interpolation doesn’t work as well. This is because Spline uses slope calculations
(change over distance) to figure out the shape of the flexible rubber sheet.
Kriging
Kriging is similar to IDW in that it weights the surrounding measured values to derive a
prediction for an unmeasured location.
ADVANTAGES
•Directional influences can be accounted for: Soil Erosion, Siltation Flow, Lava
Flow and Winds.
•Flexible; allows assessment of spatial autocorrelation
•Can obtain prediction standard errors
•Many parameter decisions
DISADVANTAGES
•Sensitivity to sample design
•Need to make many decisions on transformations, trends, models,
parameters and neighborhoods
Raster Analysis and Tools
Which Interpolation Method to Use?
• Bilinear/ Nearest neighbour - rarely goes through your original
points
• Spline - best for surfaces that are already smooth
• Elevations, water table heights, etc.
• IDW - assumes variable decreases in influence w/distance from
sampled location
• Interpolating a surface of consumer purchasing power for a retail store
• Kriging - if you already know correlated distances or directional
bias in data
• Geology, soil science
Which interpolation model should we use?
Cross-validation
• Cross-validation is a technique used to evaluate the performance of an interpolation model. The goal
of cross-validation is to estimate how well the model will perform on new data by testing it on a set
of data that were not used to train the model.
• Here are the general steps to perform cross-validation on an interpolation model:
• Split the data: Divide the available data into two sets: a training set and a validation set (choose
10% of the data). The training set is used to train the interpolation model, while the validation
set is used to evaluate the model's performance.
• Train the model: Use the training set to train the interpolation model. This involves estimating
the parameters of the model based on the available data.
• Validate the model: Use the validation set to evaluate the performance of the interpolation
model. This involves applying the model to the validation data and comparing the predicted
values to the actual values.
• Repeat the process: Repeat steps multiple times, using different subsets of the data for the
training and validation sets each time. This helps to ensure that the results are not biased by the
specific choice of training and validation data.
• Evaluate the performance: Calculate a measure of the model's performance based on the results
of the cross-validation process. Common measures include the root mean squared error, and
coefficient of determination (R-squared).
• By performing cross-validation, we can get a more accurate estimate of the performance of the
interpolation model and identify any potential issues with overfitting or underfitting. This can help to
improve the accuracy and reliability of the model's predictions.
Slope and Aspect Ratio
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, )
Standard Slope Function
The rate of change in the x direction for cell e is calculated
with the following algorithm:
[dz/dx] = ((c + 2f + i) - (a + 2d + g)) / (8* Mesh size)
a b c
The rate of change in the y direction for cell e is calculated
d e f with the following algorithm:
[dz/dy] = ((g + 2h + i) - (a + 2b + c)) / (8* Mesh size)
g h i
slope
Aspect Ratio
• Aspect identifies the downslope direction of the maximum
rate of change in value from each cell to its neighbors.
• It can be thought of as the slope direction. The values of
each cell in the output raster indicate the compass direction
that the surface faces at that location.
• It is measured clockwise in degrees from 0 (due north) to
360 (again due north), coming full circle. Flat areas having no
downslope direction are given a value of -1.
• The value of each cell in an aspect dataset indicates the direction the
cell's slope faces.
Aspect directions
The Aspect algorithm
• A moving 3 x 3 window visits each cell in the input raster, and for each cell in
the center of the window, an aspect value is calculated using an algorithm
that incorporates the values of the cell's eight neighbors. The cells are
identified as letters a to i, with e representing the cell for which the aspect
is being calculated.
The rate of change in the x direction for cell e is calculated with the
following algorithm:
[dz/dx] = ((c + 2f + i) - (a + 2d + g)) / (8* Mesh size)
The rate of change in the y direction for cell e is calculated with the
following algorithm:
[dz/dy] = ((g + 2h + i) - (a + 2b + c)) / (8* Mesh size)
Taking the rate of change in both the x and y direction for cell e,
aspect is calculated using:
aspect = 57.29578 * atan2 ([dz/dy], -[dz/dx])
The aspect value is then converted to compass direction values (0-
360 degrees), according to the following rule:
if aspect < 0
cell = 90.0 - aspect
else if aspect > 90.0
cell = 360.0 - aspect + 90.0
else
cell = 90.0 - aspect
An Aspect calculation example
• As an example, the aspect value of the center cell of the moving window
will be calculated.
The rate of change in the x direction for the center cell e is:
[dz/dx] = ((c + 2f + i) - (a + 2d + g)) / 8
= ((85 + 170 + 84)) - (101 + 202 + 101)) / 8
= -8.125
The rate of change in the y direction for cell e is:
[dz/dy] = ((g + 2h + i) - (a + 2b + c)) / 8
= ((101 + 182 + 84) - (101 + 184 + 85)) / 8
= -0.375
The aspect is calculated as:
aspect = 57.29578 * atan2 ([dz/dy], -[dz/dx])
= 57.29578 * atan2 (-0.375, 8.125)
= -2.64
Since the calculated value is less than zero, the final rule will be
applied as:
cell = 90.0 - aspect
= 90 - (-2.64)
= 90 + 2.64
= 92.64
arctan2
Aspect example output
• The value of 92.64 for the center cell e indicates that its aspect is in
the easterly direction.
Hydrologic Slope
- Direction of Steepest Descent
30 30
80 74 63 80 74 63
69 67 56 69 67 56
60 52 48 60 52 48
Slope:
Curvature
Curvature is the rate of change of slope and
aspect.
Curvature
Rate of change of aspect:
Convex: aspect lines diverge downslope
Concave: aspect lines converge downslope
Planar: Aspect constant
Rate of change of gradient:
Convex: increase in slope gradient
Concave: decrease in gradient downslope
Planar: constant gradient
Raster Analysis and Tools
Raster Calculation
Raster Calculation takes any number of data
sets and combine them with certain
parameters. It is a tool for:
•Map algebra
•Statistics
•Queries
Raster Analysis and Tools
Raster Calculation: Map Algebra
Map algebra is used to perform spatial analysis using raster
data. Map algebra uses expressions that normally return
numeric values to an output grid.
Map Algebra supports
three types of
expressions:
•Arithmetic operators
(+, -)
•Boolean operators
(AND, OR)
•Relational operators
(>, <)
Raster Analysis and Tools
Raster Calculation: Statistics
Cell statistics (Local): only use data in a single cell to
calculate an output value
•Used to analyse a certain phenomenon over time –
land use over a period of time
•Two main types of local operation:
•reclassification and
•overlay
Raster Analysis and Tools
Raster Calculation: Query
Single layer numeric example:
precipitation >200mm
Raster Analysis and Tools
Raster Calculation: Distance analysis
Straight Line Distance
functions (Euclidean)
Cost Weighted Distance
functions
Shortest/least cost
distance between 2
points.