3

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

0

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)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.