Assess Vegetation Health in QGIS using Satellite Imagery
0 views
May 21, 2025
Use QGIS to assess vegetation health from satellite imagery using the Normalized Difference Moisture Index (NDMI). This tutorial demonstrates how to assess changes in vegetation moisture over time using Sentinel-2 satellite imagery. More Sentinel-2 tutorials: https://www.youtube.com/playlist?list=PLoaxBPcx2tRDNJlI8KXkVMl0PO-JCbEqM Check out my website for MORE: https://opensourceoptions.com
View Video Transcript
0:01
Welcome to open source options where we
0:04
teach geospatial analysis and
0:05
programming with free open-source
0:08
software that's powerful. Today we are
0:11
going to discuss vegetation analysis
0:14
using Sentinel 2 data. Uh we've covered
0:18
a lot of Sentinel 2 data recently. I
0:20
have videos on how to download it, how
0:23
to visualize it, and how to calculate
0:26
remote sensing indices, specifically
0:28
NDVI, which you see a visualization of
0:31
here. What we're going to do today is
0:33
we're going to use uh three different
0:36
images from three different times um to
0:39
just kind of analyze the vegetation in a
0:42
region uh using the normalized
0:47
difference moisture index which tells us
0:51
how stressed plants are uh based on
0:54
moisture. So let's go ahead and get into
0:57
that. I'm going to get rid of this
0:59
image. Um, this is just up here to have
1:01
a pretty visual while I talk and we're
1:03
going to pull in the data we want to
1:05
use. So, let's go uh into the browser
1:08
once this gets going and let me show you
1:12
the Sentinel data I have. So, let me
1:15
close this one out. We'll refresh the
1:18
[Music]
1:19
browser. Okay, here we go. So, I have
1:23
three Sentinel images here. These are
1:25
for the same area.
1:28
Um,
1:30
and we can see the dates. So, we have
1:32
2024, June 23rd, 2023, June 24th, and
1:39
2024, September 6th. We're going to use
1:42
all three of these images to calculate
1:44
uh the normalized difference moisture
1:46
index and see uh how we can detect plant
1:51
stress from year to year or across the
1:53
season. So, let's start out. We're going
1:55
to bring in the data we need for this.
1:57
Um, in the granle folder, we need bands
2:00
11 and 8. So, we need to go find where
2:04
we have band 8 and 11 both in 20 m. So,
2:08
we're going to pull those two in uh for
2:11
our first image here. And then I'm going
2:14
to close down this image and we'll go
2:15
get it for the next two images. So,
2:18
we're in the granle uh the subdirectory
2:21
image data. We're going to go to 20 m
2:23
and we're going to pull in 8A and 11.
2:27
Have some clouds there, but that'll be
2:29
okay. And let's go grab it from the last
2:32
image. Uh let's go to granle
2:37
here image
2:39
data 20
2:41
banda and band 11. Now you notice I'm
2:44
doing a lot of repeated tasks. I just
2:46
kind of do that three times to pull
2:47
these into QGIS. And this is where it
2:50
can be very important to learn how to
2:53
write code because you can automate that
2:55
process. And with running your script
2:57
once, you could take care of all those
2:58
things at once. Um, and we have courses
3:02
or going to have courses that will teach
3:03
you that. So check out the open source
3:05
options website for more information.
3:08
Okay. Now we have all of our images
3:12
loaded here. What I want to do next is I
3:15
want to calculate the normalized
3:16
difference water index and normalized
3:19
difference moisture index
3:22
NDMI for each of these dates. To do
3:26
that, I'm going to use the raster
3:28
calculator. So, we'll go to raster
3:30
raster calculator here. I'm going to set
3:34
up my normalized difference equation
3:37
here, which looks like this. And I just
3:40
need to put the bands in on either side
3:43
of it. So what we're doing here is we're
3:46
doing 8
3:48
a minus 11. We make sure we do this for
3:51
the same date. Okay. And not for
3:54
different date. So you can see here this
3:55
is
3:57
24th
4:00
2003. And here it doesn't matter which
4:02
order for the addition. The subtraction
4:04
does matter. should make sure I have
4:05
bands
4:07
111 8A 8A minus plus. Okay. So now we're
4:11
going to save this output layer and
4:15
we'll call this
4:17
NDMI and this is going to be let me just
4:20
double check the date behind there. Uh
4:22
this is going to be
4:24
[Music]
4:26
2023
4:28
0624. Okay. So let's save
4:30
that and let's click okay.
4:34
And this is going to run. I'll pause
4:36
while this
4:37
runs. Okay, our first one is done. Let's
4:40
go and calculate the second one. Raster
4:43
raster
4:44
[Music]
4:45
calculator. And now we're going to do it
4:48
for 2024
4:51
623. You know, I
4:53
wish that with Q with the raster
4:56
calculator, you could pull up your
4:58
previous processing efforts. I haven't
5:00
been able to do that. So, if you know a
5:02
way to reuse your raster calculator, um,
5:04
let me know. I guess I can copy the
5:06
expression. Um, so we're going to do
5:09
June 23rd, 2024. 8
5:13
minus
5:15
11 and 8 +
5:21
11. Okay. And then we're going to do an
5:23
output here. And we're going to save the
5:26
same name, but we're going to change the
5:28
date. So, it is
5:31
2024
5:34
623. And let's save that. And let's
5:39
click okay to run that. And again, I'll
5:42
pause it while that finishes. That one
5:45
is complete. Let's do our last one.
5:48
Raster calculator. And we'll come down
5:51
here. I just like to set this up first.
5:53
Makes it a little easier uh to know what
5:55
I'm doing.
5:59
Okay. And then we're going to go 8
6:01
a minus 11. And I'm double clicking to
6:06
add these in if I didn't explain that. 8
6:09
a +
6:11
11. And this is
6:14
2024
6:16
9296. 2024
6:18
96. So let's do this here.
6:25
09 06. Okay. And then we'll save that
6:30
and click okay to get it
6:34
saved. All right. So if you want to know
6:36
more about the normalized difference
6:38
moisture index, um just give it a search
6:41
online with uh Sentinel 2 normalized
6:44
difference moisture index. You can find
6:46
out some more of the range of values uh
6:49
and what they mean. I'll talk about her
6:51
here. can set up some
6:53
symbology. Generally, what you're going
6:56
to see is
6:58
values that
7:01
um so this this index all the normalized
7:04
difference indices are going to range
7:06
from negative one to positive
7:10
one
7:11
values ranging from negative around zero
7:16
so
7:17
about.2 to positive.4 4 generally
7:20
correspond to water stress vegetation
7:23
and values greater than 0.4. So 0.4 to
7:27
one generally indicate
7:30
um a canopy without water stress. So
7:33
vegetation that is not water stressed.
7:37
Um and then values closer to negative
7:39
one uh
7:41
below.2 are going to indicate barren
7:43
soil. So using that information, let's
7:46
try to set up some ren uh some symbology
7:49
here just to see what this might look
7:51
like. So let's go to single band pseudo
7:54
color. Let's slide this out. Let's
7:58
change our color ramp to purple is
8:02
probably a pretty good option for
8:04
this.
8:06
And let's invert that selection so that
8:10
we have blue as our upper value.
8:14
invert color ramp. Let's see how many
8:16
classes we have here. We have one, two,
8:18
three, four, five, six. So, what I'm
8:22
going to do is
8:25
um
8:28
let's do this as an equal interval.
8:31
Let's make it six classes so we get all
8:33
of our colors included there. And let's
8:36
click classify.
8:39
You'll notice here that we have
8:42
um a linear interpolation between these
8:45
points which will be just great. And we
8:48
said anything
8:52
um above 04 was going to be in good
8:56
shape. So let's make this
8:58
0.4. Um let's make this
9:02
0.0. Let's make this
9:07
uh negative
9:11
0.2 and let's make this
9:16
oops the value here
9:21
um
9:24
0.25 that may not be our best
9:28
option. Hold on just a sec
9:32
here. Okay, we're going to keep the
9:34
symbology like this. It may not be the
9:36
the clearest representation, but if we
9:39
can keep this consistent, um that's what
9:41
we're looking for. Uh so that we can
9:43
compare this across different layers.
9:46
So, what we're going to do
9:50
here is let's go into our layer
9:53
properties here and let's go to our
9:56
symbology and let's go style. And let's
10:02
go we'll save it as the default. And
10:05
let's save the
10:07
style. And we'll save all of this here.
10:09
And I'm just going to save this to my
10:11
downloads with the other information.
10:15
And I'm just going to call this
10:19
NDMI. And we'll save it there. And we'll
10:22
say okay. Now what we can do is for
10:26
these other layers, we can load this in.
10:28
Double click here. Symbology style. I'm
10:31
going to load the style. And I'm going
10:34
to come here. I'm going to load NDMI. I
10:37
can load it from either one of these. I
10:38
guess we saved that default style. We'll
10:41
load that. We'll open.
10:44
And let's load the
10:45
[Music]
10:47
style. And let's say okay. And then we
10:51
can turn this one off and take a look
10:53
here. And we can see that we have those
10:55
same values.
10:57
Um got our thing here. So we can we can
11:00
see we have those same values. We don't
11:02
have the same values locked in
11:04
place. We should have had those values
11:06
be the
11:08
same. I have to go in and manually
11:10
adjust those. But but that's okay. Okay,
11:13
eliminated to save it
11:15
there. Let's save this here. So, we have
11:18
those values the
11:19
same. And we will save these uh in the
11:25
downloads as NDMI
11:29
uh
11:31
values. Save. And then we can come back
11:34
over here to this guy and we can open
11:39
the classification from here. And now we
11:43
have those values lined up. So
11:44
everything will be the same. And we can
11:46
go to this one here and open up the
11:48
properties for the the legend the
11:51
styles. And we can load a style. And
11:54
we'll browse for the file. We'll load
11:57
our NDMI. Open it. Load style. Okay. And
12:02
then we'll load the values here from
12:04
NDMI values. Okay. And now we have that.
12:07
So we can turn these on and off. And
12:10
you'll notice now as we look at this, we
12:13
have
12:16
um NDM. Let's just zoom on zoom in on an
12:19
area maybe around here. Uh so now we're
12:22
looking at 2023
12:24
uh June
12:25
24th and now we're looking at 2024 June
12:29
24th and our values line up. So we can
12:32
see that in June of
12:35
2023 there was more water stress than in
12:38
June of
12:39
2024. Okay. Now if we go back and we
12:41
take a look at June of 2024 and
12:44
September of 2024, we can see there is
12:47
much more water stress uh here than
12:50
there was previously. There's a lot more
12:52
in that green and in that yellow. So
12:56
look at that. So, we've already been
12:57
able to go through and see uh how the
13:00
climate can be affecting vegetation both
13:02
between years and within the same year.
13:06
I want to show you just a couple other
13:07
ways we can we can look at analyzing
13:10
these.
13:11
Um, and we actually have a lot more
13:14
power to do this when we use a
13:16
programming language like Python. We can
13:18
automate and compare and pull data in a
13:21
little more consistently. Um, and like I
13:24
said on opensource options.com, I'm I
13:27
don't have any courses up yet, but the
13:29
vision is to get those courses up and
13:31
available so you can have really
13:33
in-depth, professionally done courses
13:35
for free on that website. So, just stay
13:38
tuned uh to that website and to this
13:42
YouTube channel to see those. Let's go
13:44
take a look at some histograms. Um,
13:46
let's take a look and we'll start. I'm
13:49
going to put these in order
13:50
chronologically. So, we'll have the
13:52
earliest date at the
13:53
beginning, 2023, and we'll have the
13:56
latest date at the end, September
13:58
2024. Okay? And we can turn these layers
14:01
off just so they're out of our
14:03
way. Now, let's take a look here in 2023
14:08
at our histogram. So, we can come here.
14:11
We can go to our histogram. We need to
14:13
compute this
14:15
histogram. All right. Very well. And now
14:17
we can
14:19
see actually let's we can I can show you
14:21
something here that might make this a
14:23
little easier. So we can see uh the
14:26
frequency of each pixel value in that
14:30
distribution. Now we can save this as an
14:33
image by clicking this here. Um I'm just
14:36
going to go and we'll go just remember
14:37
this. We'll go take a look at 2024 the
14:40
same
14:41
date. Compute the histogram. And you can
14:44
see we're shifted more to the left here,
14:46
right? We don't have as many of those
14:48
higher values indicating that on this
14:50
date in 2023, plants were or in 2024,
14:53
plants were more stressed than they were
14:55
at the same time of year in 2023. And
14:57
now remember this, we'll go take a look
14:59
at how things look later in the year. We
15:01
can go here and we can compute the
15:04
histogram and we can see that our plant
15:06
stress values have shifted even more to
15:09
the left. And I think this spike here is
15:11
representative of the water of that
15:12
lake. uh in that area. Okay, let's try
15:16
something. I do not know if this is
15:18
going to work. Um but we're going to
15:20
give it a try and see what happens.
15:21
Let's try to put these three in a
15:23
virtual raster so they're all uh
15:25
spatially oriented together. We can just
15:27
flip back and forth between the bands
15:29
for um our histograms. So we go to
15:32
raster miscellaneous build virtual
15:34
raster. Let's select these three inputs.
15:38
Let's make sure we get them in order.
15:40
2023 2024. Okay, let's do it this way.
15:43
Just like that. And let's say okay,
15:46
let's place each file into a separate
15:48
band. We can keep the resolution at the
15:52
average. Uh if we resample, let's do
15:55
bilinear.
15:57
And let's run this. We'll keep it as a
15:59
virtual file, a temporary file. So,
16:02
let's run. This shouldn't take very
16:04
long. There it is. It's closed. And
16:06
let's slide this to the top. It's going
16:09
to display it weird. Well, that's kind
16:10
of cool. It's going to display it weird
16:12
because it's displaying it as a true
16:13
color image instead of
16:15
uh and we can turn it off. It's
16:18
displaying it as a true color image
16:19
instead of as a single band. But if we
16:22
double click here and we can compute the
16:25
histogram and now we can see it for all
16:28
three bands where band one is June of
16:33
2024, band two or band one is June of
16:37
2023, band two is June of 2024 and band
16:42
three is September of 2024. And we can
16:44
see this spike in each of those images.
16:46
I think that's like I said the area of
16:47
the lake of Bear Lake that we're looking
16:48
at. And then we can see uh how we get
16:52
stress changes from year to year and
16:55
also changes seasonally. All right. And
16:58
if we were to like I said we can get
17:00
into some of the programming languages
17:01
and we can calculate these histograms in
17:03
there and also calculate quantitative
17:06
differences between them. But this gives
17:07
you a really good idea of of how these
17:10
things can change through time and how
17:12
you can use satellite imagery to capture
17:15
those changes. All right. Thanks for
17:17
watching. I appreciate your time. Um, if
17:21
you have questions, leave them in the
17:23
comments below. And if you want to see
17:24
those courses when they come out, just
17:26
go ahead and make sure you check out
17:28
opensource options.com.
#Biological Sciences
#Earth Sciences
#Ecology & Environment