TransWikia.com

Running classification on image collection using Google Earth Engine?

Geographic Information Systems Asked by user145039 on December 6, 2020

I have ImageCollection. composed of satellite images which shows Zebras on grasslands. The location of each zebra is stored within a point shapefile, which I uploaded as a “table” into Earth Engine.

I wish to extract the pixel values under each point within the shapefile (i.e. the pixel values for each zebra) and then run a supervised classification to detect the zebras.

When I try to run the code on my ImageCollection, this is the error that is returned:

   table2 = ee.FeatureCollection("users/example/abc..."),
    imageCollection = ee.ImageCollection("users/example/wsx...")

// Load training polygons from a Fusion Table.
        // The 'class' property stores known class labels.
        var polygons = ee.FeatureCollection(table2);


// Get the values for all pixels in each polygon in the training.
var training = imageCollection.sampleRegions({
  // Get the sample from the polygons FeatureCollection.
  collection: polygons,
  // Keep this list of properties from the polygons.
  properties: ['class'],
  // Set the scale to get Landsat pixels in the polygons.
  scale: 30
});

imageCollection.sampleRegions is not a function

One Answer

Classification over Image Collections require usage of the map function. See the small example in the link how I managed to do it.

Firstly you have to create a function which does training and classification.

function classification(image){
  var training = image.select(bands).sampleRegions({ collection: points,
    properties: [label],
    scale: 30
  });
  var trained = ee.Classifier.cart().train(training, label, bands);
  return image.select(bands).classify(trained);
}

Then you have to call the function using

collection.map(classification)

Answered by g07kore on December 6, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP