Link Search Menu Expand Document

Tutorial 12

Spectral mixture analysis

/*Load a Landsat 8 image and select only the panchromatic band.  The panchromatic band includes reflectance in the 0.503–0.676 µm wavelength range with a ground sample distance of 15 m. */

// Load a Landsat 5 image and select the bands we want to unmix.
var bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7'];
var image = ee.Image('LANDSAT/LT05/C01/T1/LT05_015030_20100531')
  .select(bands);
Map.setCenter(-76.1467, 43.0458,12);
Map.addLayer(image, {bands: ['B4', 'B3', 'B2'], min: 0, max: 127}, 'image');

/* Define spectral endmembers. Each number corresponds to the DN values (from 0–127) of the seven Landsat image bands. You can obtain values of endmembers by going to the Inspector tab and clicking on “pure” pixels of a selected land cover type. More endmembers can also be found in the USGS or NASA JPL spectral libraries. */
var urban = [88, 42, 48, 38, 86, 115, 59];
var veg = [64, 30, 20, 118, 74, 138, 22];
var water = [63, 23, 16, 14, 6, 131, 4];

// Unmix the input image based on the provided spectral endmembers.
var fractions = image.unmix([urban, veg, water]);

/*Display unmixed image. In the unmixed image, the red band shows the proportion of urban cover, green shows vegetation and blue shows water based on the spectral endmember you provided earlier.  When viewed as an RGB image, the color shows the proportion of each cover types e.g. cyan pixels are a mixture of water and vegetation, magenta pixels are a mixture of urban and vegetative cover. */
Map.addLayer(fractions, {}, 'unmixed');

/*With only three endmembers, then is clearly some limitation to this 
unmixing e.g. based on the color shown in the RGB image, what type of 
land cover are the bare fields west of Syracuse? */

Image time series analysis

// Construct a FeatureCollection for three different locations near Syracuse
var points = ee.FeatureCollection([
  ee.Feature(    // Syracuse
    ee.Geometry.Point(-76.1505,43.0498), {label: 'City of Syracuse downtown'}),
  ee.Feature(  // Clark Reservation 
    ee.Geometry.Point(-76.0899,42.9983), {label: 'Forest in Clark Reservation'}),
  ee.Feature(  // Oneida Lake
    ee.Geometry.Point(-75.9045,43.2007), {label: 'Water in Oneida Lake'})
]);

Map.addLayer(points);

// Import Landsat 8 brightness temperature data for 3 years. 
var temps = ee.ImageCollection('LANDSAT/LC8_L1T_TOA')
    .filterBounds(points) // Filter image scenes based on the three defined locations above
    .filterDate('2013-01-01', '2016-12-31') // Filter image scenes from 2013 to 2016
    .select('B11') // Select band 11 for the thermal infrared response
    .filterMetadata('CLOUD_COVER', 'less_than', 40); //filter based on image cloud cover 

/* Create a time series chart showing surface temperature change for the three defined locations based on three years of Landsat 8 images. */
var tempTimeSeries = ui.Chart.image.seriesByRegion(
    temps, points, ee.Reducer.mean(), 'B11', 100, 'system:time_start', 'label') 
        .setChartType('ScatterChart') // Set the chart to be a scatter plot
        .setOptions({ //Set options of the plot
          title: 'Temperature over time for locations near City of Syracuse', //Set title 
          vAxis: {title: 'Temperature (Kelvin)'}, //Set x axis label
          lineWidth: 1, // Set the width of the line
          pointSize: 4, // Set the point size for each data point
          series: {
            0: {color: 'FF0000'}, // color for City of Syracuse downtown
            1: {color: '00FF00'}, // color for Forest in Clark Reservation
            2: {color: '0000FF'}  // color for Water in Oneida Lake
}});

// Display time series chart.
print(tempTimeSeries);