Introduction to Image Classification

Classification transforms continuous spectral data into meaningful categories—water, vegetation, urban, bare soil. This is where remote sensing becomes actionable information.

Learning objectives

  • Explain what image classification does and why it matters.
  • Distinguish supervised from unsupervised approaches.
  • Understand the classification workflow in Earth Engine.
  • Run a simple classification and visualize results.

Why it matters

Raw satellite images are just pixels. Classification creates land cover maps, change detection, and thematic products that inform decisions about conservation, urban planning, disaster response, and resource management.

Key vocabulary

Classification
Assigning each pixel to a discrete category based on its spectral values.
Training data
Labeled examples that teach the classifier what each class looks like.
Classifier
An algorithm that learns patterns from training data and applies them to new pixels.

Quick win: Your first classification

This example classifies an image into 3 land cover types using Random Forest:

// Load and prepare image
var image = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20210623')
  .multiply(0.0000275).add(-0.2)
  .select(['SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6', 'SR_B7']);

// Define training points (in practice, draw these on the map)
var water = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([-122.42, 37.78]), {class: 0}),
  ee.Feature(ee.Geometry.Point([-122.45, 37.80]), {class: 0})
]);
var vegetation = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([-122.20, 37.85]), {class: 1}),
  ee.Feature(ee.Geometry.Point([-122.18, 37.82]), {class: 1})
]);
var urban = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([-122.40, 37.75]), {class: 2}),
  ee.Feature(ee.Geometry.Point([-122.38, 37.77]), {class: 2})
]);

// Merge training points
var trainingPoints = water.merge(vegetation).merge(urban);

// Sample the image at training point locations
var training = image.sampleRegions({
  collection: trainingPoints,
  properties: ['class'],
  scale: 30
});

// Train a Random Forest classifier
var classifier = ee.Classifier.smileRandomForest(50).train({
  features: training,
  classProperty: 'class',
  inputProperties: image.bandNames()
});

// Classify the image
var classified = image.classify(classifier);

// Visualize
Map.centerObject(image, 10);
Map.addLayer(image, {bands: ['SR_B4','SR_B3','SR_B2'], min: 0, max: 0.3}, 'True Color');
Map.addLayer(classified, {min: 0, max: 2, palette: ['blue', 'green', 'gray']}, 'Classification');

print('Classes: 0=Water, 1=Vegetation, 2=Urban');

What you should see

A classified map showing water (blue), vegetation (green), and urban (gray) areas. The accuracy depends on training point quality and quantity.

indices (NDVI, NDWI) as additional features.

Step 2: Collect training samples

Create points or polygons for each class using the geometry tools. More samples = better classification. Aim for 50+ points per class, distributed across the scene.

Step 3: Train the classifier

Choose an algorithm and feed it your training data. The classifier learns the spectral patterns that define each class.

Step 4: Apply and evaluate

Classify the entire image and assess accuracy using independent validation data.

Supervised vs. unsupervised

Supervised Unsupervised
Training data Required (labeled examples) Not required
Classes You define them Algorithm discovers them
Output Your specific classes Spectral clusters (you label after)
Best for Known classes, ground truth available Exploration, no reference data

Classifiers in Earth Engine

Classifier Type Best For
smileRandomForest() Supervised General purpose, handles many features well
smileCart() Supervised Simple, interpretable decision tree
libsvm() Supervised High accuracy with proper tuning
wekaKMeans() Unsupervised Finding natural spectral clusters

Try it: Add more training points

  1. Use the geometry tools to draw polygons for each class.
  2. Import them as FeatureCollections with a 'class' property.
  3. Re-run the classification and compare results.

Common mistakes

  • Too few training points (need 50+ per class).
  • Training points only in one part of the image.
  • Including cloudy pixels in training data.
  • Testing on training data (use a separate validation set).
  • Forgetting to scale/offset surface reflectance bands.

Quick self-check

  1. What is the purpose of training data?
  2. Name two supervised classifiers in Earth Engine.
  3. When would you choose unsupervised over supervised classification?

This module builds on

Next steps