Object-based methods

For treating landscape elements as objects, Earth Engine contains several methods. Specifically, when an image has distinct patches identified by unique pixel values, use image.connectedPixelCount() to compute the number of pixels in each patch and image.connectedComponents() to label each patch with a unique identifier. The unique identifiers can then be used to enumerate the patches and analyze the distribution of size or some other quality of interest. The following computes the size and unique identifiers of hot patches in a surface temperature image:

// Load a Landsat 8 image and display the thermal band.
var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC80440342014077LGN00');
Map.setCenter(-122.1899, 37.5010, 13); // SF Bay
Map.addLayer(image, {bands: ['B10'], min: 270, max: 310}, 'LST');

// Threshold the thermal band to find "hot" objects.
var hotspots = image.select('B10').gt(303);

// Mask "cold" pixels.
hotspots = hotspots.updateMask(hotspots);
Map.addLayer(hotspots, {palette: 'FF0000'}, 'hotspots');

// Compute the number of pixels in each patch.
var patchsize = hotspots.connectedPixelCount(256, false);
Map.addLayer(patchsize, {}, 'patch size');

// Uniquely label the patches and visualize.
var patchid = hotspots.connectedComponents(ee.Kernel.plus(1), 256);
Map.addLayer(patchid.randomVisualizer(), {}, 'patches');
    

In the previous example, note that the maximum patch size is set to 256 pixels by the arguments to the connectedPixelCount() and connectedComponents() methods. The connectivity is also specified by the arguments, in the former method by a boolean and in the latter method by an ee.Kernel. In this example, only four neighbors are considered for each pixel.

Enviar comentarios sobre…

Google Earth Engine API