Create a Chart to show Landsat 8 TOA Spectra at three points near Mumbai City

Let’s learn something fun today. We will try to create a chart that shows Landsat 8 TOA Spectra at three points near Mumbai City. In addition, we will do some exciting stuffs. We will do the following things today:

  1. Load and display a Landsat 8 image’s reflective bands.
  2. Create an NDWI image, define visualization parameters and display.
  3. Mask the non-watery parts of the image, where NDWI < 0.2.
  4. Create visualization layers
  5. Mosaic to combine the masked NDWI and the false color composite and obtain a new visualization:
  6. Create a circle by drawing a 25000 meter buffer around a point in Mumbai City.
  7. Define and display a Feature Collection of three known locations.
  8. Display the chart.

Learn about Data

USGS Landsat 8 Collection 1 Tier 1 and Real-Time data TOA Reflectance

Landsat 8 Collection 1 Tier 1 and Real-Time data calibrated top-of-atmosphere (TOA) reflectance. Calibration coefficients are extracted from the image metadata. See Chander et al. (2009) for details on the TOA computation. The Landsat 8 images are of 30 m and 16 days spatial and temporal resolutions respectively.

Here is the code:

// Load and display a Landsat 8 image's reflective bands.
var image = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")
    .select(['B[1-7]'])
    .filterDate('2017-01-01','2017-12-31')
    //.filterBounds(roi)
    .median();
    
// Create an NDWI image, define visualization parameters and display.
var ndwi = image.normalizedDifference(['B3', 'B5']);
var ndwiViz = {min: 0.5, max: 1, palette: ['00FFFF', '0000FF']};
Map.addLayer(ndwi, ndwiViz, 'NDWI', false);

// Mask the non-watery parts of the image, where NDWI < 0.2.
var ndwiMasked = ndwi.updateMask(ndwi.gte(0.2));
Map.addLayer(ndwiMasked, ndwiViz, 'NDWI masked', false);

// Create visualization layers.
var imageRGB = image.visualize({bands: ['B5', 'B4', 'B3'], max: 0.5});
var ndwiRGB = ndwiMasked.visualize({
  min: 0.5,
  max: 1,
  palette: ['00FFFF', '0000FF']
});

// Mosaic the visualization layers and display (or export).
var mosaic = ee.ImageCollection([imageRGB, ndwiRGB]).mosaic();
Map.addLayer(mosaic, {}, 'mosaic', false);

// Create a circle by drawing a 25000 meter buffer around a point.
var roi = ee.Geometry.Point([72.87315, 19.05859]).buffer(25000);
Map.addLayer(mosaic.clip(roi), {}, 'Mumbai');
Map.centerObject(roi,10);
Mumabai (Buffered)

Create a Chart to show Landsat 8 TOA Spectra at three points near Mumbai City

// Define and display a FeatureCollection of three known locations.
var points = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point(72.87315, 19.05859), {'label': 'park'}),
  ee.Feature(ee.Geometry.Point(72.84812, 19.06100), {'label': 'urban'}),
  ee.Feature(ee.Geometry.Point(72.92736, 19.07151), {'label': 'openspace'})
]);
Map.addLayer(points);


// Define customization options.
var options = {
  title: 'Landsat 8 TOA spectra at three points near Mumbai City',
  hAxis: {title: 'Wavelength (micrometers)'},
  vAxis: {title: 'Reflectance'},
  lineWidth: 1,
  pointSize: 4,
  series: {
    0: {color: '00FF00'}, // park
    1: {color: '0000FF'}, // urban
    2: {color: 'FF0000'}, // openspace
}};

// Define a list of Landsat 8 wavelengths for X-axis labels.
var wavelengths = [0.44, 0.48, 0.56, 0.65, 0.86, 1.61, 2.2];

// Create the chart and set options.
var spectraChart = ui.Chart.image.regions(
    image, points, ee.Reducer.mean(), 30, 'label', wavelengths)
        .setChartType('ScatterChart')
        .setOptions(options);

// Display the chart.
print(spectraChart);

Leave a Reply

%d bloggers like this: