Skip to content

LST Anomalies in Regions

Introduction

This tutorial introduces a general workflow to map land surface temperature (LST) anomalies for locations in a region.

We use Baltimore, MD as a case to develop the model. We then test and adapt the model by changing our area of interest to Houston, Texas.

As you work through the tutorial, you may find it helpful to refer to the land surface temperature and anomalies pages in the Glossary.

The app below shows what your final result should look like for the Test Case (Houston) by the end of the tutorial.

Link to app


Start a new script

//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  Name:         wk08_tutorial_lst_spatial_anomalies.js 
//  Problem:      LST anomalies within urban areas
//  Date:         10/29/2023  
//  Author:       Jeff Howarth  
//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Define area of interest

// ------------------------------------------------------------------------
//  Define area of interest
// ------------------------------------------------------------------------

// Import feature collection of Census 2020 Urban Areas from "projects/ee-primer/assets/regions_usa/uac20" 
// Filter for Baltimore, MD.

var aoi 
;

print(
  'Urban Area'
)
;

2020 Tiger/Line Shapefiles


Define AOI extent rectangle

// ------------------------------------------------------------------------
//  Define area of interest extent rectangle.
// ------------------------------------------------------------------------

var aoi_extent 
;

// Map.centerObject(aoi_extent, 10);
// Map.setOptions('hybrid');


print(
  "AOI",
  "EXTENT"
  )
;

Calculate LST from Landsat

// ------------------------------------------------------------------------
//  Calculate LST from Landsat Collection.
// ------------------------------------------------------------------------

// Import module for LST computation from 'users/sofiaermida/landsat_smw_lst:modules/Landsat_LST.js'

var LandsatLST = require('users/sofiaermida/landsat_smw_lst:modules/Landsat_LST.js');

// Apply module to produce image collection.
// Use the 'L8' collection.
// Start: '2020-07-01'. End: '2022-09-01'.

var dataset = LandsatLST
  .collection
    (
                      // landsat collection
                      // start date  
                      // end date
                      // filter by aoi extent rectangle
    )
;

// Print first image in collection and size of collection.

print(
  'LST collection'
  )
;

Filter collection

// ------------------------------------------------------------------------
//  Filter Landsat image collection.
// ------------------------------------------------------------------------

// Filter the dataset for images collected in summer months (July and August)
// with cloud cover less that 10 percent.
// Also select only the 'LST' band from the images.

var output
;

// Print first image and size of collection.  

print(
  'Filtered Output'
  )
;

Reduce collection to image

// --------------------------------------------------------------------------------
//  Reduce image collection to image.  
// --------------------------------------------------------------------------------

// Process image collection as follows:  
//  (1) calculate the average (mean) temperature of summer month for each pixel; 
//  (2) convert units of reduced image from Kelvin to Fahrenheit;
//  (3) clip to the aoi bounding geometry
//  (4) rename the band "AVG_LST_F" in the output image.
//
// K to F conversion involves three steps:  
//  (1) Subtract 273.15 from Kelvin temperature
//  (2) Multiply by 1.8 
//  (3) Add 32

var output_image 
;

// Print your result. 

print(
  'Output image'
  )
;

Display as map layer

// ---------------------------------------------------------------------
//  Display image as a map layer.  
// ---------------------------------------------------------------------

// Import modules.   

var tools = require('users/jhowarth/eePrimer:modules/image_tools.js');
var palettes = require('users/gena/packages:palettes');


// Define viz parameters.

var output_viz = {
  // bands: [],
  min: [0],
  max: [150],
  palette: palettes.colorbrewer.YlOrRd[9]
};

// Make a histogram to see data distribution.  

// var histogram = tools.makeHistogram(
//         // Must be an image (not an image collection)
//         // Select one band at a time.
//         // Pixel resolution of image.
//         // Minimum value of x-axis
//         // Maximum value of x-axis.
//   )
// ;

// Print, print, print...

print(
  "Histogram"
  )
;

Calculate median of AOI

// ---------------------------------------------------------------------
//  Calculate median LST value for the urban area. 
// ---------------------------------------------------------------------

var median_LST = 
;

print(
  "Median LST"
  )
;

Convert feature collection to image

// ---------------------------------------------------------------------
//  Convert to image. 
// ---------------------------------------------------------------------

var median_LST_image 
;

Calculate anomalies

// ---------------------------------------------------------------------
//  Calculate anomalies as percent difference from regional median 
// ---------------------------------------------------------------------

var anomaly 
;

var anomaly_viz 
;

// Make a histogram to see data distribution.  

// var histogram = tools.makeHistogram(
//     // Must be an image (not an image collection)
//     // Select one band at a time.
//     // Pixel resolution of image.
//     // Minimum value of x-axis
//     // Maximum value of x-axis.
//   )
// ;

// Print, print, print...

print(
  "Histogram"
  )
;

// Display as layer.

Add legend

// ---------------------------------------------------------------------
//  Add legend 
// ---------------------------------------------------------------------

//  Load cart module.

var cart = require('users/jhowarth/eePrimer:modules/cart.js');

// Call makeGradientLegend function and pass three parameters.

// var legend = cart                                                     // module
//   .makeGradientLegend(                                                // function
//       // viz parameters
//       // a title for legend
//       // position on map
//   )
// ;

// Map.add(legend);

Test model on another region


Tutorial Checks

// --------------------------------------------------------------------------------
//  Tutorial Checks  
// --------------------------------------------------------------------------------

var check = require('users/jhowarth/eePrimer:modules/checks.js');

// Please be sure to modify the model to fit the Test Case (Houston).
// Please be prepared to report the following checks on the tutorial quiz.
// These checks assume that you followed the names used in the tutorial. 


print(
  "CHECK 01:", aoi.first().geometry().area(1).divide(1000000),
  "CHECK 02:", aoi_extent.area(1).divide(1000000),
  "CHECK 03:", dataset.size(),
  "CHECK 04:", output.size(),
  "CHECK 05:", check.t08(output_image, aoi),
  "CHECK 06:", median_LST.first().get("median"),
  "CHECK 07:", check.t08(anomaly, aoi)
);

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International License.