19
1 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. For more information contact: Dr. Alistair Smith Department of Forest Resources Email: [email protected]

Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

  • Upload
    vokiet

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

1

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 don�t 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. It�s 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 don�t 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. For more information contact: Dr. Alistair Smith Department of Forest Resources Email: [email protected]

Page 2: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

2

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

Page 3: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

3

Introduction

Planning a Scientific Project…..…………….4Project Safety…………...…………………….5

BAC ∩=

4±= ba

cmxy +=

∑∞

=

+=1

242n

PQZy

−+= 2

3 52xxxxy

Page 4: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

4

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. A last comment: Don’t forget physical tools:

• Calculators and Computers • Pencils and Pens • Paper • Rulers, protractors, and set squares

Page 5: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

5

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 can�t 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! Remember the saying: ‘Assumption is the Mother of all Screw-ups’

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

Page 6: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

6

Materials

BAC ∩=

4±= ba

cmxy +=

∑∞

=

+=1

242n

PQZy

−+= 2

3 52xxxxy

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

Page 7: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

7

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 Then you can always produce a value of y. For instance in this graph, you can produce any y value at each x position by using the equation y = 3x.

Page 8: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

8

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. Answers:

(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

Given the function y = (1+ x)2 calcualte:

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

Answers:

(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)

Page 9: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

9

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’. Examples of vectors include:

- 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:

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

A

B

a + b

a b

a

b

+ =

Page 10: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

10

As we are essentially dealing with triangles, several RULES when using vectors can be stated: The Commutative RULE: (It doesn�t matter which one you add to the other)

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)

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

q.(a + b ) = q.a + q.b

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

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

a + b

a b =

a + b

b a

= b a -

b(-a) + = b-a

(-a)

b

Page 11: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

11

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:

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: Addition RULE:

Subtraction RULE:

Multiplication There are two types of matrix multiplication: One is easy and the other is bizarre. Easy RULE (Multiply a matrix by a constant):

( )

=

==

−−−−−−−−

=

3224522221122216243252221

12

1221111181111

PXBA

−++++++++

=

+

ZCYCYBYAXAXBXAZBZA

ZYYYXXXZZ

CCBAABABA

( ) ( ) ( )ZDYCXBWAZYXWDCBA −−−−=−

( ) ( )ZAYAXAZYXA **** =

Page 12: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

12

Bizarre RULE (Multiply two matrices together): Lets say that we have two matrices A and B. If A has �p rows� and �q columns�: And B has �r rows� and �s columns�:

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: Examples: (a) (b) (c) (d) (e) 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).

pqpq

qpqpqpqp

.........

.

1

12

12111

srsr

srrsrssr

.........

.

1

12

12111

++++

=

2222122121221121

2212121121121111

2221

1211

2221

1211 *babababababababa

bbbb

aaaa

=

+−+++

=

+

5065

32)2(25141

3254

2211

−−−

=

−−−−−

=

1443

32)2(25141

3254

2211

=

+−++−+

=

16482

)3*2()5*2()2*2()4*2()3*1()5*1()2*1()4*1(

3254

*2211

=

++++

=

3617

)6*4()5*2()4*1()4*3()2*2()1*1(

421

*654321

DONEBECANT=

321

*113322

Page 13: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

13

Tools and Skills

BAC ∩=

4±= ba

cmxy +=

∑∞

=

+=1

242n

PQZy

−+= 2

3 52xxxxy

Differentiation……………………………....14Integration………………………………….17

Page 14: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

14

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. Edge Detection Example: Consider the step function: Y = 2 for x>0 Y = 1 for 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. Now move the small piece of line a little to the right. The gradient is still zero. You move the piece so far it 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. Therefore, if you draw how the gradient changed over this function you would get a big spike at the edge.

X = 0

X = 0

X = 0

X = 0

X = 0

Page 15: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

15

This process of measuring the gradients of very small pieces of line is differentiation. The result of doing differentiation is called the derivative. 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: 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. Using Differentiation on Spectra or on Functions: The RULES of differentiation for several common functions are:

dxdy

xinchangesmallyinchangesmall

xx==

−−

=12

12 yy Gradient

)sin();cos(

)cos();sin(

;

1;ln

;

0;

1

baxadxdybaxyFor

baxadxdybaxyFor

aedxdyeyFor

xdxdyxyFor

nxdxdyxyFor

dxdyconsyFor

axax

nn

+−=+=

+=+=

==

==

==

==

Page 16: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

16

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:

Answer: 1*)1(dxdy x;y For )0( ==== =nxn

(b) y = x5 + 2x + 4 Using the second function RULE:

Using the first function RULE:

Now add all these solution together to get the answer:

4)4(5 5*)5(dxdy; xy For xxn n ==== =

22*)1(dxdy2x; y For )0( ==== =nxn

0dxdy4; y For ==

25dxdy;42 45 +=++= xxxyFor

Page 17: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

17

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 Imagine we have a drill that linearly increases in power with time: i.e. we have the function y=x: Now the area underneath this line can be calculated by either integration or using simple trigonometry. Trig: The area of a triangle = ½ x Base x Height = ½ x 1 x 1 = ½. Integration: Now the RULE of integration is as follows: ∫xn = (1/n+1) xn+1 + C 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 don�t need to worry about C 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):

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

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 0.2 0.4 0.6 0.8 1

Time (seconds)

Pow

er (W

atts

)

210

21)0(

21)1(

21 221

0=−==−=== ∫ xxxdxArea

Page 18: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

18

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 sin (ax+b) = (-cos(ax+b)/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:

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.

101)0(21)1(

212 221

0=−==−=== ∫ xxxdxArea

421

29)1(

21)3(

21

21 22

3

1

3

1

2 =

=

=−

==

=∫ xxxxdx

Page 19: Foundation Maths for Remote Sensing and Spatial Ecology Introv201.pdf · Foundation Maths for Remote Sensing and Spatial Ecology ... just learn the trick. ... Keep your Tools Handy

19

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

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:

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.

-1.5

-1

-0.5

0

0.5

1

1.5

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

Y=sin(x)

011)cos(11)cos(

11sin =−=−=−=−== ∫− ππ

π

πxxxdxArea