Home Remote Sensing Unsupervised classification in GEE

Unsupervised classification in GEE

0
1845
Unsupervised Classification

This blog covers unsupervised classification in the Google earth engine.

Source: Google Earth Engine

The process of unsupervised classification in GEE is carried out using  the ee.Clusterer package. The package has been adopted from Weka

  1. Loading of the image

The image used in classification is from the landsat program. A landsat 7 image is used for the year 2001.

// Load a pre-computed Landsat composite for input.var input = ee.Image(‘LANDSAT/LE7_TOA_1YEAR/2001’);
  1. Creating and display of the region of interest.

The region of interest is created using the geometry tool, centered to the map and displayed.

Figure 1: Geometry tool




Figure 2: Importing the image

// Display the sample region.Map.setCenter(34.75, 0.282);

Map.addLayer(ee.Image().paint(region, 0, 2), {}, ‘region’);

  1. Features with numeric properties in which to find clusters are assembled, while setting the necessary parameters including scale.
// Make the training dataset.var training = input.sample({

region: region,

scale: 30,

numPixels: 5000

});

  1. Training of the classifier
// Instantiate the clusterer and train it.var clusterer = ee.Clusterer.wekaKMeans(15).train(training);
// Cluster the input using the trained clusterer.var result = input.cluster(clusterer);
  1. Display of the results

The result is displayed using different colors, adopted from Visualization in the Google Earth Engine.

// Display the clusters Map.addLayer(result.randomVisualizer(), {}, ‘clusters’);

Figure 3: Classification result

Full code:

// Load a pre-computed Landsat composite for input.var input = ee.Image(‘LANDSAT/LE7_TOA_1YEAR/2001’);

// Display the sample region.

Map.setCenter(34.75, 0.282);

Map.addLayer(ee.Image().paint(region, 0, 2), {}, ‘region’);

// Make the training dataset.

var training = input.sample({

region: region,

scale: 30,

numPixels: 5000

});

// Instantiate the clusterer and train it.

var clusterer = ee.Clusterer.wekaKMeans(15).train(training);

// Cluster the input using the trained clusterer.

var result = input.cluster(clusterer);

// Display the clusters with random colors.

Map.addLayer(result.randomVisualizer(), {}, ‘clusters’);

close

Join Our Mailing List

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.