You are on page 1of 19

# Foundation Maths for Remote Sensing and Spatial Ecology

## The Purpose of These Notes:

Remote sensing and spatial ecology are scientific disciplines and as such a reasonable
knowledge of mathematics is essential.

However, these days a wide variety of different university disciplines use spatial
techniques; including several departments that probably dont rate mathematics very
high as a prerequisite for undergraduates.

## These notes therefore aim to provide the student with a refresher/introduction to

several crucial mathematical concepts.

The information contained in these notes is not examinable but the student is
recommended to look at them, try the exercises, and ask questions!

When reading these notes, please try to remember that mathematics is a tool, much
like a drill.

Its very difficult to do home improvement without using a drill, so you use it; but you
might not necessarily know what makes it work.

## The same is true for mathematics.

In remote sensing and spatial ecology, we use the mathematics as a tool, we learn the
tricks and rules to use it correctly, but in many cases we dont need to know how it
works; only that it does.

These notes aim to describe the rules, tricks, and the tools of mathematics and we are
going to do a home mathematical improvement of a general research project.

## Dr. Alistair Smith

Department of Forest Resources
Email: alistair@uidaho.edu

1
Contents

Introduction..3
Planning a Scientific Project..4
Project Safety.....5

Materials...6
Numbers.....7
Functions....7
Vectors...9
Matrices..11

## Tools and Skills...13

Differentiation..14
Integration....17

2
Introduction

## Planning a Scientific Project...4

Project Safety....5

y = 2 Z + 4 PQ 2
n =1

C = A B
a =b4

5x
y= x + 2x 2
3

y = mx + c

3
Planning a Scientific Project
Spatial projects can be satisfying, especially when your hard work pays off, but to
fully understand the processes you require more than the ability to display the
occasional image. As with all projects, whether we talk about science or home
improvement, expertise on specific tools is not as important when compared to
attention to details and learning quick and easy methods to do complicated tasks.

Now, what do you do at the start of a new scientific project? Well, begin any project
by writing your ideas down. Next, check both the available literature and the Internet
to determine whether your idea is novel or has been done before. Finally, try and
explain your idea to your colleagues. If they can follow and understand what you
mean; then you also understand what you are trying to achieve.

Now, that you are ready to begin, ask yourself the following questions:

What Types of Materials Would Work Best for My Project? In spatial projects
people frequently either use vector or raster (pixel) based data what will you need?
Does you analysis require integers (i.e. 1, 45, -10, 100) or real numbers (i.e. 2.23.
1.90, 100.8)? Do you need to use functions or Boolean algebra? Will you be using
satellite images (i.e. Matrices/Arrays) or point (e.g. Lidar) data?

Which Tools do I Need? Most spatial analysis packages allow the use of Boolean
operators will you need them? Do you need to integrate or differentiate anything?
If you are doing image processing, do you need to use Fourier Transforms or Matrix
Algebra? Will your analysis require the use of probability and statistics?

Do I have time to Learn or Use the Mathematics? If you are a graduate student,
you are probably very busy on research and course work. If you think you will need to
use a mathematical tool once, just learn the trick. Only try and understand the
processes involved if you need to use the mathematics again and again.

Have any Previous Studies Found a Shortcut? It is quite possible that a similar
study has written a program, or produced easy ways to do what you propose. Make
sure you have extensively checked the past resources and in particular google.

Can You Get By Using a Software Program? Many software packages (i.e. R,
SPSS, S-PLUS, MATLab, etc) are very powerful and can be used to help you in your
mathematical task. The most important thing that you must remember is to never use
Excel for statistics.

## Calculators and Computers

Pencils and Pens
Paper
Rulers, protractors, and set squares

4
Project Safety
You might ask yourself, Safety in Mathematics? However, this is not a joke.

When conducting scientific projects you will use mathematics for a large variety of
tasks, some of which might involve human impacts. For instance, you might be
estimating the fuel required to make a boat trip to a remote field site. Making an error
in your calculation could prove dangerous.

However, it is more likely that by making errors you will just waste time. This is
something you cant afford to do in remote sensing as some processes can easily take
you a day to run. If you make a mathematical mistake, you will feel terrible the next
day, when you have to repeat the process. You might also feel uncertain that even this
process is correct. Such uncertainties are best avoided in graduate studies.

Now, you will make some mistakes, but the best you can do is to minimize the
number of times they occur. This can be done by always following these steps:

## Are you using the correct technique?

Are your original data entered correctly? Incorrect data is one of the greatest
cause of error in scientific research DO NOT assume that it is ok, check it!

## Take your time: do not rush it.

Is your answer is reasonable? If not, repeat the calculation and compare your
answers. If they differ, do it again until you answer agrees.
Are your results to similar studies? Do your results make sense?
Write down the all the steps of the method that works.

## Mathematical First Aid

Original Backup The most important from of mathematical first aid that you can
have is to save your original unprocessed data backed up as a separate file that you
NEVER change.

Before doing any analysis, create an exact copy of this data, then work with the copy.

In the situation of complete meltdown in your analysis, a computer crash, etc, you can
always refer back to your original data.

Textbooks and Notes Always have your textbooks or notes handy. Quickly referring
to your notes, can not only save time later, but also will also give you more
confidence in your analysis and make the task less daunting.

Keep your Tools Handy Know where your calculator and software tools hide.

5
Materials

Numbers....7
Functions...7
Vectors...9
Matrices...11

y = 2 Z + 4 PQ 2
n =1

C = A B
a =b4

5x
y= x + 2x 2
3

y = mx + c

6
Numbers
The simplest material in mathematics is the Number. This is to mathematics like
wood is to carpentry and stone is to masonry.

However, numbers can come in many different shapes and forms. This section will
explain the differences of those that you will come across in remote sensing:

Integers These are numbers that have no decimal point and are sometimes called
Whole numbers. Integers can be negative, zero, or positive: -12, 45, 0, 22, -100

Natural These are like integers, except they do not include the negative numbers: 0,
34, 97, 1

Real Numbers or Floats These are numbers that are like integers but do have
decimal points: -32.4, 0.0, 19.78, 100.2

Rational Numbers of Fractions These are numbers that can be written as p/q, where
q 0: , , Numbers that cannot be written as p/q are called irrational numbers:
2 and are two such examples.

Functions

A function is a rule, which if you give it a specific input it will produce a specific
output.

For instance, lets assume that you are prefect at drilling a screw into a piece of wood.
In this example the function would look something like:

## Screw & Drill & Wood = Screw in Wood

A function that you will probably see a lot in science is the function for a straight line.
It says that if you know:

1. The value of X,
2. How steep the slope of
the line is, and
3. Where the line intercepts
the Y-axis

value of y.

## For instance in this graph, you

can produce any y value at each
x position by using the equation
y = 3x.

7
The Language of Functions

## In mathematics, the previous function is typically written in the form:

f(x) = 3x

Now, if you saw the following line in the literature: f(x=3) or f(3) this means that the
person who wrote the line wants you to consider the case when x=3 and to work out
the answer for x =3. In our example, this would be 9. i.e f(3) = 9.

Examples:

## If you are given the function: y = 4x + 2 calculate:

(a) f(5)
(b) f(0)
(c) f(-2)
(d) f(b)
(e) f(t+1)

Note from (d) and (e) that it is the RULE that is important and not the letter used. i.e.
to drill in a screw, you could use several different types of screw heads and bit types,
but the rule and result is still the same.

## (a) For y = 4x + 2; f(5) = (4 x 5) + 2 = (20) + 2 = 22

(b) For y = 4x + 2; f(0) = (4 x 0) + 2 = (0) + 2 = 2
(c) For y = 4x + 2; f(-2) = (4 x 2) + 2 = (-8) + 2 = -6
(d) For y = 4x + 2; f(b) = (4 x b) + 2 = 4b + 2
(e) For y = 4x + 2; f(t+1) = (4 *(t+1)) + 2 = (4t + 4) + 2 = 4t + 6

(a) y(4)
(b) y(x)

## (a) For y = (1+ x)2; y(4) = (1 + 4)2 = 52 = 25

(b) For y = (1+ x)2; y(x) = (1 + x)2 = (1 + x) x (1 + x) = 1+x+x+x2 = 1 + 2x + x2

## The RULE for (b) is:

(A + B) x (C + D) = (A x C) + (B x C) + (B x D) + (D x A)

8
Vectors
In all fields of science, including ecological applications, you will frequently make
use of measures that are simply described by a single number. Examples include:

## - The mass of an animal or boulder

- The respective speed of African and European Swallows
- The population of a community

## These are examples of scalar quantities or more simply scalars.

In contrast, there exist several measurements that rely on the knowledge of the
direction that the object is pointing, moving, or has come from. These measures are
called vector quantities or more simply vectors.

## - Weight, which is the effect of gravity (usually downwards) on a mass

- Velocity, which is the speed and direction of an object

When dealing with spatial ecology or GIS problems, you might be more used to
seeing vectors as line segments that stretch between two points:

## In mathematics we would describe this vector by the notation AB

Adding Two Vectors Together:

Let us use the simplest example of wanting to add two line segments together:

a+b
a + =
b a b

The simplest approach is to draw a triangle, where the end of one vector touches the
start of the other.

9
As we are essentially dealing with triangles, several RULES when using vectors can
be stated:

The Commutative RULE: (It doesnt matter which one you add to the other)

a+b

b a =
a b

a+b
a+b=b+a

The Associative RULE: (You can repeat the commutative law with as many vectors
as you want)

a + (b + c) = (a + b) + c

## The Subtraction RULE: (Subtracting is like adding a vector whose direction is

going the wrong way)

(-a)

b
(-a) + = b-a
a = b
-
b

The Multiplying by a Scalar RULES: (Just like regular mathematics: p and q are
scalars and a and b are vectors)

## (p+q).a = p.a + q.a

q.(p.a) = (q.p).a

10
Matrices

## A matrix is a rectangular array or block of numbers. In remote sensing and spatial

ecology we use matrices all the time.

The most common matrices in remote sensing are IMAGES and SPECTRA.

## Some of examples of small matrices are:

1 2 2 2 5

1 1 1 2 3 4 2 6
2
A = 1 8 1 B = (1 2 2 1) X = P = 1 2 2 2 1
1
1 1 1 1 2 2 2 2

5
4 2 2 3

## Each number within a matrix is called an element.

There exist several useful RULES when working with matrices. The complete
collection of rules is sometimes called Matrix Algebra. The RULES of matrix
algebra are classic examples of things you should know, but not care how they
work.

Addition and subtraction If two matrices have the same shape and size then the
elements in each matrix can be added or subtracted:

A B A Z Z X A+ Z B+Z A+ X

B A A + X X Y = B+ X A+ X A+Y
B C C Y Z B + Y C +Y C Z
Y

Subtraction RULE:

(A B C D ) (W X Y Z ) = (A W B X C Y DZ)

Multiplication There are two types of matrix multiplication: One is easy and the
other is bizarre.

## Easy RULE (Multiply a matrix by a constant):

A * (X Y Z ) = (A * X A *Y A* Z )

11
Bizarre RULE (Multiply two matrices together):

## p1q1 p1q2 . p1q r1 s1 s1 r2 . s1 r

p2 q1 . . . r2 s1 . . .
. . . . . . . .

pq . . pq sr . . sr
1 1
Then the Bizarre Multiplication RULE says we can only multiple these two matrices
if the q = r; i.e. if the number of columns in A are equal to the number of rows in B.

## The Bizarre RULE:

a11 a12 b11 b12 a11b11 + a12 b21 a11b12 + a12 b22
* =
a21 a22 b21 b22 a21b11 + a22 b21 a 21b12 + a 22 b22

Examples:

(a) 1 1 4 5 1 + 4 1+ 5 5 6
+ = =
2 2 2 3 2 + ( 2) 2 + 3 0 5

(b) 1 1 4 5 1 4 1 5 3 4
= =
2 2 2 3 2 ( 2) 2 3 4 1

1 1 4 5 (1 * 4) + (1 * 2) (1 * 5) + (1 * 3) 2 8
(c) * = =
2 2 2 3 ( 2 * 4) + ( 2 * 2) ( 2 * 5) + ( 2 * 3) 4 16

1
1 2 3 (1 * 1) + ( 2 * 2) + (3 * 4) 17
(d) * 2 = =
4 5 6 4 (1 * 4 ) + ( 2 * 5) + ( 4 * 6 ) 36

2 2 1
(e)
3 3 * 2 = CANT BE DONE
1 1 3

The last example is not possible, as the q r. i.e. the number of columns in the first
matrix (2) does not equal the number of rows in the second matrix (3).

12
Tools and Skills

Differentiation....14
Integration.17

y = 2 Z + 4 PQ 2
n =1

C = A B
a =b4

5x
y= x + 2x 2
3

y = mx + c

13
Differentiation
Differentiation is a mathematical technique that is used to assess how functions
change. i.e. this is the change sensor (be that movement, rain, temperature, etc) of
mathematics.

In particular, differentiation assess how rapidly that the function is changing at any
specific point. i.e. if we are looking at a function changing with time, differentiation
assesses the RATE that the function changes.

In remote sensing and spatial ecology we typically use differentiation in two ways:
either in image processing to detect edges or in spectral processing to detect features.

## Consider the step function:

Y = 2 for x>0
Y = 1 for x<0 X=0
The step function is an edge
in 1 dimension.

## If we consider the gradient

of a very small section of the
red line (see above) for the
flat line the gradient is zero. X=0

## Now move the small piece of

line a little to the right.

## You move the piece so far it X=0

is now at the edge. Here the
gradient is going to be very
high.

## Moving the piece even more

to the right will again
produce a gradient of zero, as
the function is flat again. X=0

## Therefore, if you draw how

the gradient changed over
this function you would get a
big spike at the edge.
X=0

14
This process of measuring the gradients of very small pieces of line is differentiation.

## Using Differentiation on Spectra or on Arrays with Two Columns:

To calculate the gradient (or derivative) of a small piece of line you use the following
equation:

y 2 y1 small change in y dy
Gradient = = =
x2 x1 small change in x dx

The value of the gradient can vary from 0 (which is a flat line) to infinity (for a
vertical line). A line with an angle of 45 has a gradient of 1.

## The RULES of differentiation for several common functions are:

dy
For y = cons; =0
dx
dy
For y = xn; = nx n 1
dx
dy 1
For y = ln x; =
dx x
dy
For y = e ax ; = ae ax
dx
dy
For y = sin( ax + b); = a cos( ax + b)
dx
dy
For y = cos( ax + b); = a sin( ax + b)
dx

15
Examples:

(a) y = x

In this example, if x changes by 1 then y should also change by 1; i.e. the rate
of change with 1 unit of y is 1. We would then expect that the derivative
should also equal 1:

dy
Answer: For y = x; = (n = 1) * x ( n= 0) = 1
dx

(b) y = x5 + 2x + 4

## Using the second function RULE:

dy
For y = x 5 ; = ( n = 5) * x ( n = 4 ) = 5 x 4
dx
dy
For y = 2x; = ( n = 1) * 2 x ( n = 0 ) = 2
dx

dy
For y = 4; =0
dx

## Now add all these solution together to get the answer:

dy
For y = x 5 + 2 x + 4; = 5x 4 + 2
dx

16
Integration
The process of integration allows us to calculate the area underneath a curve. Such an
area can have several interpretations. For example:

The area under a graph showing the power of a drill with time will tell us the total
energy used by the drill (as Energy = Power x Time).

Example #1

## i.e. we have the function y=x:

1
Now the area underneath this line
0.9
can be calculated by either
integration or using simple 0.8

trigonometry. 0.7
Power (Watts)

0.6
Trig: The area of a triangle = x
Base x Height = x 1 x 1 = . 0.5

0.4

0.3
Integration: 0.2

## Now the RULE of integration is 0.1

as follows: 0
0 0.2 0.4 0.6 0.8 1

## xn = (1/n+1) xn+1 + C Time (seconds)

You increase the power by one and then divide the answer by this new number,
finally you add a constant C.

Often the integral is between two values (e.g. in this case we are trying to add up the
area under the curve between 0 and 1). When this happens you dont need to worry

In these cases, first calculate the values you would get by putting those end x values
(i.e. 0 and 1) into the answer. Second, subtract the smaller x values answer (i.e using
x=0) from the larger x values answer (using x=1):

1 1 1 1 1
Area = xdx = ( x = 1) 2 ( x = 0) 2 = 0 =
0 2 2 2 2

This is integration. Note that the answer is identical to the trig method.

17
Integration is all about following a rule, like the one explained about and then
subtracting the smaller x answer from the larger x answer.

## Other rules for more complex expressions include:

Expressions Integral

1/x = ln |x| + C

eax = (eax/a) + C

## cos (ax+b) = (sin(ax+b)/a) + C

There are many more, but only these are of interest in this course.

Example
Imagine that our drill is now working twice as hard in the same time interval (i.e. 0 to
1) such that now y=2x. Calculate the energy by each method.

## Trig: This is again a triangle: Area = base x height = x 1 x 2 = 1

Integration:
1 1 1
Area = 2 xdx = 2 ( x = 1) ( x = 0) 2 = 1 0 = 1
2
0 2

## Again, the answer is the same.

The second RULE of integration is that when the integral sign has numbers at the top
and bottom you:

## 2. Integrate the function

3. Work out the value of the result using the TOP number
4. Work out the value of the result using the BOTTOM number
5. Subtract the BOTTOM answer from the TOP answer.

3
3 1 1 1 9 1

1
xdx = x 2 = ( x = 3) 2 ( x = 1) 2 = = 4
2 1 2 2 2 2

18
For a more complicated example, the following graph shows a sine function:

1.5
Y=sin(x)
1

0.5

0
-3 -2 -1 0 1 2 3
-0.5 Units of Pi ()

-1

-1.5

In this example, we want to calculate the area under the curve between 1 and +1.

This should be Zero, as each curve above and below the line is the same size.

However, lets work this out using the sin(ax+b) rule mentioned in the previous page.

Therefore:
1 1
Area = sin xdx = 1 cos( x = ) 1 cos( x = ) = 1 1 = 0

The integration of sines and cosines are very important for the theory behind remote
sensing and image processing.

## If you want to have more example or problems to refresh yourself in integration,

please feel free to come and ask.

19