Google Earth Engine – Understand the Geometries Parameter in ee.Image.sampleRegions

geemapgoogle-earth-enginepythonsamplepoints

I am reading the geemap tutorial and I have question about the sampleRegions function. As I understand, this function "cross" between vector data (feature collection) and a given raster, and generates new feature collection with the pixel value for each point.
However, I don't understand what is the geometries parameter is for:

"

isn't it suppose by deafult to include point geometry per pixel? why wouldn't it? which geometries will be omitted? not sure I understand how to use this parameter and how it works.

Best Answer

When false, the features in the resulting feature collection will not include the geometry of their corresponding region, only the sampled band values.

A very common use-case where you don't need to include the geometry is when you are creating a training data-set for a classifier. The classifier only cares about the band values and the class:

var trainingData = image.sampleRegions({
  collection: referenceData, 
  scale: 10, 
  geometries: false // We don't need the geometries here
})

var classifier = ee.Classifier.smileRandomForest(5)
  .train(trainingData, 'value')
var classification = image.classify(classifier)

https://code.earthengine.google.com/846e1fc668ec69677c03b172e5603d83