Image Regions Charts

To get image data by region, use ui.Chart.image.regions(). The following example illustrates this method by getting image spectra from three land cover types at locations in Mexico:

// Load and display a Landsat 8 image's reflective bands.
var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC80260472014047LGN00').select(['B[1-7]']);
Map.addLayer(image, {bands: ['B5', 'B4', 'B3'], min: 0, max: 0.5});

// Define and display a FeatureCollection of three known locations.
var points = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point(-99.25260, 19.32235), {'label': 'park'}),
  ee.Feature(ee.Geometry.Point(-99.08992, 19.27868), {'label': 'farm'}),
  ee.Feature(ee.Geometry.Point(-99.21135, 19.31860), {'label': 'urban'})

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

// 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)

// Display the chart.

In this example, note that an array of wavelengths defines the X-axis. (See this site for information about Landsat bands). Also note that the lineWidth and pointSize parameters control the display of the lines and data points in the chart. The result should look something like Figure 1.

Figure 1. Plot of spectra from three locations in Mexico.

Enviar comentarios sobre…

Google Earth Engine API