This tutorial accompanies the Small Town Big Data blog post Smoke Plume Summer. Read it here.


Getting started in Google Earth Engine

Google Earth Engine offers petabytes and petabytes of satellite imagery and geospatial data, accessible through an APIs where the cloud-based processing enables global-scale analysis. Processing that used to take days now takes seconds.

This tutorial offers a brief introduction on working with Landsat 8 imagery in GEE. We’ll cover:

GEE is free for research, education and nonprofit use. Sign up here to get started.

Note: it may take up to 24 hours to receive your confirmation.

When you’re cleared with credentials, go to the code editor. This is the cockpit for our GEE journey. You can do this tutorial without knowing an iota of JavaScript! I’ve provided all the code here for you to cute and paste to your heart’s desire.

You’ll see several panes:

  1. Code editor - The center pane is where you’ll paste and/or write your code.
  2. Map pane - this is where you can display your results to explore on an interactive map.
  3. Console - the right hand pane also includes the Inspector and Tasks tabs, where results from your code will appear.

Selecting Landsat imagery

We only want to select the Landsat tiles we need. Since we’re looking for imagery of a specific wildfire, we can constrain the search by area and date to narrow it down. The first step is creating a box that will constrain the search by geometry. GEE will only pull tiles that intersect with this box.

I drew it where it would capture the Middle Fork Fire. You can draw yours anywhere you want if you’re interested in another fire. It’s easiest to do this with the interactive tool. In the upper left corner of the map pane, you’ll see a toolbar with shapes on it. Click on the rectangle shape and draw it anywhere on the map you’d like. Click “import” to generate a code snippet like this one:

var geometry = 
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[-106.84100977511082, 40.70707934282725],
          [-106.84100977511082, 40.55074205549539],
          [-106.62677637667332, 40.55074205549539],
          [-106.62677637667332, 40.70707934282725]]], null, false);

The following command creates a collection of images (scientific name: Image Collection) of Landsat tiles, filtered by date and by the box we made in the previous step. I constrained the time frame to that of the Middle Fork Fire - From just before ignition on September 5 to December 3, when the land update was made on Inciweb.

And in the same step, we’ll sort the images by date so we’re sure they’re in chronological order.

//Get landsat TOA  L8 surface reflectance image(s) 
//including the polygon

var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")
    .filterBounds(geometry)
  .filterDate('2020-09-05', '2020-12-03')
  .sort('DATE_ACQUIRED');
  
  
//Print the image collection to the console. 
//In the console, look through the object 
//and each element to see what dates were captured.
//Explore cloud cover and other quality metrics.
  
print(l8)

The print command will generate a description of what’s in the list in the console in the upper right pane. Scroll through the object and click the arrows to explore it’s various elements and properties. You’ll see under the “features” heading how many tiles were found in the search. Unfold each one to examine the dates and other attributes.

To extract individual dates and visualize them on the map below, we need to turn our Image Collection into a list. We’ll then add one of the extracted elements to the map.

//Turn image collection into a list and extract each date. 
var l8l = l8.toList(10)
var sept11 = ee.Image(l8l.get(0))
var sept20 = ee.Image(l8l.get(1))
var sept27 = ee.Image(l8l.get(2))
var oct6 = ee.Image(l8l.get(3))
var oct13 = ee.Image(l8l.get(4))
var oct22 = ee.Image(l8l.get(5))
var oct29 = ee.Image(l8l.get(6))
var nov14 = ee.Image(l8l.get(7))
var nov23 = ee.Image(l8l.get(8))
var nov30 = ee.Image(l8l.get(9))

//Add individual images to map to visualize.
Map.addLayer(sept11)

You should now see the September 11 image in the map pane at the bottom. But wait, why is it all grey?


Making the false color composite: Changing visualization parameters

Once you have the imagery on display in the map pane, you can use the settings button in the map pane to adjust the visualization parameters. When you click the settings wheel, you’ll see 3 drop down menus. One each for the red, green and blue channels typical of images. To capture the fire burn area, we’ll use Band 7 (R), Band 5 (G), and Band 2 (B).

Try playing with different band combinations: how do they change what’s visible in the image? For more information on why that is, check out this explanation of false color composites

Click “import” to create a code snippet like we did with the geometry in the first step. If you don’t want to tinker yourself, cut-and-paste the image visualization parameters I used into your code editor.

var imageVisParam = {"opacity":1,"bands":["B7","B5","B2"],"min":0.05913848951458931,"max":0.4439639993011951,"gamma":1.1320000000000001}

Exporting to a .TIF image file

Now we have our Landsat scenes displayed the way we want them. But they’re not quite ready to download yet. Currently, each tile is a Google Earth Engine element - from when we turned the image collection into a list. It’s not the RGB format we want. So we’ll need to use the visualize() command and our imageVisParam object to turn it into one. Notice I left out a few of the images. If you displayed each one, you’ll know why!

//Turn into an RGB image for export wih visualize() 
var sept20 = sept20.visualize(imageVisParam)
var oct6 = oct6.visualize(imageVisParam)
var oct13 = oct13.visualize(imageVisParam)
var oct22 = oct22.visualize(imageVisParam)
var nov30 = nov30.visualize(imageVisParam)

You can export from GEE directly into your Google Drive, because of course you can, it’s Google. Paste the following command, and repeat it for as many dates as you want by changing the image parameter.

//Export image
//Create a task that you can launch from the Tasks tab. 
Export.image.toDrive({
  image: sept20,
  description: 'mfsept20',
  scale: 30,
 region: geometry
});

And that’s it for this month! Can you feel the power of GEE yet? It’s an absolutely game-changing tool (“game-changer”, ugh, SO overused but I think it’s warranted here) and opens up world of new opportunity for exploring open geospatial data. For the full list of what’s available in GEE, go here.

Tune into Small Town Big Data on February 2 for the next post.