Landsat NDVI time-series in Google Earth Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to the next part of our tutorial number two you can find it under teaching tab on the group website teaching lab 2 and this is the environment environmental monitoring and modeling cause 2017 currently being run at Charles Darwin University my name is Sean Levesque and this is a continuation of the lab which we started a few days ago getting deeper into Earth engine so I'd like to acknowledge the Google Earth engine team and they're beginning curriculum documentation which I've modified for this tutorial so a couple of days ago we went through computing some terrain attributes using SRTM data and we got to the point where we were ready to start playing with image bands so what I'd like you to do now is head over to earth engine at code on Earth engine at google.com if you have a script already in place please clear it and we're going to search for the mitchell plateau which is an area in north western australia here it is mature plant so let me just zoom out a bit we're currently up in Darwin and the mitchell plateau is a nice area of the Kimberley up on the north coast it's challenging because it's often a lot of cloud in the area so quite tricky to get cloud free mosaics of satellite imagery in this region let's see what we can do in Earth engine about that for this exercise we're going to be using Landsat 8 top of atmosphere collection so search for Landsat 8 Toa Landsat 8 top of atmosphere reflectance let's import that and rename the collection 208 for Landsat 8 next we're going to filter the collection with a few dates so let's add a comment to ourselves put the collection to date range paste that in so we're creating the variable filtered Landsat 8 filter date and 2013 April 15 to April 20 so quite a dip and quite a narrow date range let's run that and see what happens now we see these dark stripes appearing in our map if we zoom out a little bit can get a slightly better idea what's happening and these strips of data show us the orbital path of Landsat 8 due to the orbit we have to wait a few days approximately 16 days before the satellite revisits the same point in the earth again so just to quickly illustrate that if we were to increase the state range a few extra months getting up to July now it's running that again we'll find that there's a lot more data coming into our home and view for the purpose of this exercise though let's go back to that narrow date range of just five days and let's you mean back to our area of interest right now these look very dark why is that with the default initialization parameters the data looks dark and the colors look wrong better visualization parameters so we just used the standard visualization but if we had in some min and Max criteria and specify which bands should be viewed we'll get a much nicer looking set of results so if we run that now we get a true color composite because I've specified that we must use bands 4 3 & 2 which correspond to the red green and blue channel creating a very lifelike true color representation our next step would be to add a false color composite to this so we're gonna add repeat the step that we've just done except we're also gonna specify a name for the layer I come back here and go to our layers tab you'll see it just as layer 1 and that's because I didn't specify a layer name up in this section in this next bit of code that I'm gonna paste in I'm now specifying that this combination of bands 4 3 & 2 is the RGB composite and this combination 5 4 & 3 making use of near infrared and red channels is the false color let's run that we get out the same true color strips coming back and here comes the false color on top of it remember that the false color is very sensitive to chlorophyll green vegetation now these are visualization parameters that will often be using so we can pull them out into a variable for example RGB this equals max bands 4 3 & 2 and if we do that copy it let's go back over here and just to repeat that we creating a variable for the visualization RGB tha's that's why when we add the map layer later we just need to call the faulted collection we can specify the visualization parameters with one term and give that a name when we run that we'll see how now strips again and hover over layers it'll be named RGB all right now let's have a look at reducing image collections so our first step is that we're gonna expand out the date range let's copy this line middle line paste it over here basically all we're doing is instead of searching for images in a five day window we're gonna search for one year of data basically the whole of 2014 and let's see what that looks like so we see that the gaps between the overpasses had been filled in we had a continuous coverage wall-to-wall coverage across the top end of Australia our layer is called RGB that's what we specified and that's really fantastic to be able to call up so much imagery so quickly but we can see we have quite a bit of problem with cloud cover what can we do about that well let's first have a look at using the median reducer so I want you to copy in this piece of code here the very last product section 8 I'll talk you through it in a moment let's copy that actually instead of pasting it over what we need to do is copy the last line and before hitting run have a look at what we're doing we're gonna map add layer a faulted collection but whereas before we would load the whole collection now we're gonna just load the median value and what that means is for each pixel in this collection we're gonna drill through order all the values all the reflectance values in that stack right and then only map the median value to the whole image so let's run that and see what it looks like here comes our original image that we saw previously lots of clouds in the way and takes a little while to load but we're now running the reducer using this median function and because clouds have high reflectance they have high values and we sort through that one year of data and it's basically a way of finding a good pixel within a year's worth of data it's that it's the median value the the general state of that pixel over the year and as a result we get a much cleaner looking mosaic we can switch off RGB underneath let's zoom in a little bit closer here's Broome to the view and we can see quite a bit of sediment washing out into the ocean but nice very clear image so that's that's great for looking at an average of a whole collection but what if we want to pick out a particular image it's narrow the time range to a seven-day window they start with that now so we're just doing what are we doing here 2015 September first let's run that basically a two month window actually we can see we have quite a few quite a lot of data over our area of interest they have cloud problems again so let's add a region of interest using the point geometry tool in the import section renaming the object ROI this will allow us to filter by bounds in a later step so so far we've used filter date which best which allows us to vary our search according to a date range how we're going to use the teardrop geometry to add a point of interest and we're going to rename that geometry ROI which stands for region of interest and when you look at this next code pasting yeah you'll see that we've added this line number four so filter by date we've done that previously now we add filter bounds ROI that means we're asking Google to search all the available Landsat 8 images within this date range that intersect this region of interest to the point let's run that and we'll see that only a couple of images so that's RGB and we can see that's probably three three different images and intersect at that point now we're going to extract a sample image from the image collection and add it as a layer so let's make a little note on whatever we're doing we're going to extract single image have a look what's different about about this piece of code you'll see that we're filtering by bounds but we're creating a variable image which is the first image within the filtered collection so let's run that and like to just rename that first so that we don't get confused run it again and you'll see we have these two layers this is the first just touching our marker that's the first available image in the collection so that's the way we can pick out a single image we have covered cloud masking in in other sections we'll get to that in more detail later so we might want to fall to the collection by the cloud camera meta data attribute for now though let's move on to computing NDVI normalized difference vegetation index we're gonna do it the hard way first by using the mathematical operators let's copy this piece of code and write a note to ourselves and a compute and let's see what this code is saying create the variable RGB vers when max use bands 4/3 into you great variable faltered but used to the Landsat 8 imagery filter by date to this period filter bounds by the our region of interest and return the first image that's what we've done already that's what's giving us this tile so let's just delete those first few lines so we don't get confused that's where we currently are but a few this is the new section here we're defining the variable read as being a bad for selected from the image year infrared image select and five variable NDVI is gonna be the near-infrared subtract red / near-infrared + red that's the NDVI equation near-infrared - red / year interet + red we can then add the true color visualization to the map and we can add in DVI layer to the map remember that NDVI ranges from minus 1/2 to 1 so if we are researching in an area on ground looking for vegetation we can set that to 0 and 1 let's run that this brother code picks out our scene from the collection and it's quite rocky country we're in up here so there might not be a lot of green vegetation along the coast we are picking up these areas here DDI it's likely higher we can use the inspector to query these locations and you'll see that this will return a value of NDVI it's a point point for not very high but higher than point some sort of a rock with 0.2 okay if I'm if we felt that this wasn't the best location for our just up for our example we could click on our region of interest just drag it over to another point let's say exit and then all we have to do is rerun our code and that will change our area of interest and bring a pinion image for us so extremely versatile as tool really really great capabilities now we found a single image in a collection and we've calculated NDVI for it but if we want to build a time series of NDVI over time we need to be able to map this function over the whole time series so we're going to learn next how to write functions so in order to continue we're going to start by writing a function that adds an extra band to our images with NDVI data in it the code for writing the function is as follows let's copy it and as usual paste it in and then have a look at it believe this is our first function for the course it's paste it in so variable RGB those min/max been through that before the new bits let's okay delete that if we don't want to delete our previous lines of code remember that we can also just use command /to comment out all of the previous code lines so let's focus on writing the function variable RGB those specifies visualization using bands 4 3 & 2 a function we're gonna create is add NDVI to our image and here we define NDVI as the normalized difference this is a earlier we calculated NDVI by subtracting dividing the near infrared and red bands but it is a very common technique so we can just use the normalized difference routine within engine the format for that is just your infrared band red band and we're going to return an image called NDVI which we will add as a band we will then filter the Landsat 8 collection with a certain date range and ensure that it intersects our region of interest well query that for the first image in the collection and we will then say that with variable nd VI equals add in di to the image let's give better run so aside from looking quite dark we have no errors let's see what's happened click on the inspector tab and on the image look in the inspector tab results to see that the code has added a band called indeed let's do that we click we have our GP image and we have an NDVI image with an extra band on the end and this is the band containing our NDVI values however the default visualization hasn't picked up on that yet and one is being displayed by default instead of Hindi add a visualisation parameter to correct this you'll see how to do this now we're going to specify the band nd must be used so we'll copy that and running that okay and now we have a much better looking in DVI image okay now that we have the function we're going to map it's over a collection that means we've developed a function for applying calculating NDVI for one image but now we want to go back through time and compute India NDVI of each image has been collected over this point code to do that yeah copy that and can you see any differences between this part of the code that we just copied in in the previous part the difference is that we've created a variable with NDVI which is adding NDVI to our full to the method so let's give that a run or true color composite and our NDVI bands so we removed the the filter to return only the first image and that's why we now have NDVI for more than one image so we know that our mapping function is working now next it then let's use the inspector tab to click on the map and show that each image now has an indie vent containing the NDVI so we can click here and see that this tile now has an Indian click here see that this tile also has the proves to us that our mapping is working and now we are ready to almost ready to apply it to the whole image collection but first we're gonna get rid of some clouds I mean to do that we can expand out the time range and switch to using median reducer again and that's to remove those cloud effects so let's copy this script and we can paste that let's comment out our previous lines sometimes it's better to just comment them out and delete them so that they're there if you need to come back to them so for example here I commented out too much and I'm mixing spaces and tabs that should work for us let me run that and here we have a nice clean mosaic cloud-free for the whole map window and we've successfully applied the NDVI computation to all of these scenes so this is a really great result it's it's really quite amazing to be able to do this so quickly over such a large area so what we've done here is met the NDVI function spatially across the different Landsat scenes so we have a nice spatial composite but the theme of this of the lab for today was actually it's actually time series so what we're gonna do next is work on an even better way to produce the cloud-free mosaics making use of the earth engine image collection of quality mosaic using this as a method for ordering image pans on a pixel-by-pixel basis so let's give this piece around copy that in it's coming to out this please for now and make a note that this is now called green greenest composite let's have a look at what this car is doing very similar to before creating the function head in DVI and the variable in DVI filtering by date and adding in adding our function to each of these images we're gonna we're gonna map out the median RGB but they're also creating a variable called greenest and basically this is our our best quality pixel or the greenest pixel with in the connection so let's run that we'll see that this is is heavily optimized for poor work on on land a terrestrial environment so it's quite interesting over the ocean it will often always pick us a pixel containing cloud cover but on ground we zoom in let's have a look along highway here the median value the state of the land through most of the year this is sort of the average condition of a spot on the reflectance of that pixel over the year is the RGB median and this is dry country but this greenness pixel function is using the greenest possible pixel without clouds so it's two very useful techniques for looking at and producing cloud free mosaics one is the average over the year and the other is the greenest possible pixel very useful technique last second last function for today is really getting to the crux of it now is to be able to chart in DVI over time so we're gonna use just these extra it's just why I'm actually just one extra line here print chart image Theory series with NDVI select the handy band and intersected at the ROI so let's copy this or just make a little light yeah that this is the line for producing time series chart we've already done all the calculations needed all that's left is to actually print the chart so we're gonna print that and that's gonna pop up in our console section and here we have it from February 2015 1200 2015 it's a little bit jagged we're using a single single point in some of our further work who will use a polygon to average over a region and that'll involve a few more steps but this is a great way to quickly drill down through a time series and plot in DDI at a time what we can do quickly is just alter that date range of it let's do it from 20 beginning of 2014 up until present time see what that looks like and that's really the beauty of programming and using a platform like Google Earth engine is we're able to quickly adjust these date ranges and explore these these patterns as we extend this out over a longer time period we can see the starts to make more sense we have these high values and in the wet season remember we're close to the tropics here two very distinct seasons waiting dry as we start coming into the dry season NDVI drops off slow through the dry and starts picking up again when the rains come very useful for looking looking at these trends over time now the last the last thing I wanna show you today is how to export these images that we've created so that you can use them in another GIS program or just download the high-quality two images so the first thing to do is create a 8 bit RGB image object using the earth image visualize command add it to the interactive map and then we simply export that using the export image command and by default that will go into our Google Drive account so let's copy this piece we'll call us create RGB object that and then we're gonna export it to our Google Drive based in this bit of code so the important part here is the last line export image RGB I'm gonna call the file greenest pixel I'm gonna run that first you might think that nothing's happened but have a look over here the tasks tab we can see that this is a other job running but we can see tasks and a waiting for us greenness pixel that that builds up when we're finished with a project we can decide which ones we really want to run when we want to export this we can click on run we'll have a few options here we can give the file a name we can choose the resolution that we want to export it as and we could either add this as an asset pass it over to cloud storage or simply save it to our drive we run that it'll take a little while to generate and save to the drive but will then have that image available for use in other GIS programs if you want to use it in another program it's quite hard to imagine any functionality that's not possible within Google Earth engine thanks very much and see you in the next lab
Info
Channel: GEARS - Geospatial Ecology and Remote Sensing
Views: 27,357
Rating: 5 out of 5
Keywords: remote sensing, big data, ecology, Australia, Landsat, NDVI, monitoring
Id: Wik07UyjnDs
Channel Id: undefined
Length: 36min 26sec (2186 seconds)
Published: Thu Nov 02 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.