仅使用一个 class 和 Google Earth Engine 监督 class 化

Supervised classification with only one class with Google Earth Engine

我是地理空间分析和 Google Earth Engine 的初学者。我正在尝试 class 只验证 Landsat 5 图像(游泳池)中的一个 class。我得到了几个培训网站并应用了 classifier。结果,我的 classified 图像完全变红了(所以 classified 没有给我预期的结果)。那是因为我应该 class 验证多个 class 而不是一个?以及如何要求 class 通过我的训练站点验证我定义的 class 并创建另一个 class 来收集不属于先前定义的 class 的所有像素?在我使用的代码下方:

var bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7']

var image= ee.Image('LANDSAT/LT05/C01/T1_TOA/LT05_015036_20111025')
      .select(bands)

// Train is the feature collection containing my training sites (points)
var training = image.sampleRegions({
               collection: train,
               properties: ['class'],
               scale: 30
               });

var trained = ee.Classifier.cart().train(training, 'class', bands);

// Classify the image with the same bands used for training.
var classified = image.select(bands).classify(trained);

正如@Val 所说,您至少需要两个 classes。这意味着您要么必须携带一个 "everything else" class 的数据集,要么您可以在 Earth Engine 中创建一个伪偶发数据集。伪非发生采样假设您有第一个 class 的完美发生样本,因为它将 select 不靠近第一个样本的区域创建另一个样本(如果这完全有意义的话) ...)。它在代码中可能看起来像这样:

var bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7']

var image= ee.Image('LANDSAT/LT05/C01/T1_TOA/LT05_015036_20111025')
  .select(bands)

// Train is the feature collection containing my training sites (points)
var occurrence = image.sampleRegions({
           collection: train,
           properties: ['class'],
           scale: 30
           }).map(function(feature){
               return feature.set('class',ee.Number(1))
           });

// Create geometry where there is no occurrence data
var nonarea = image.geometry().difference(train.buffer(100))

// Sample from region where there is no occurrence data
var nonoccurrence = image.sample({
           region: nonarea,
           scale: 30
           }).map(function(feature){
               return feature.set('class',ee.Number(0))
           });

// Merge the occurrence and non-occurrence feature collections
var training = ee.FeatureCollection(occurrence.merge(nonoccurrence))

var trained = ee.Classifier.cart().train(training, 'class', bands);

// Classify the image with the same bands used for training.
var classified = image.select(bands).classify(trained);

(您可能需要修复上面代码中的一些数据类型,没有示例数据很难测试...)。这是物种分布和灾害风险建模中常用的方法,希望对您的用例有所帮助!

我可能遇到过类似的问题,一张 class 化后的图像只显示一个 class。 就我而言,这不是 class 化或算法的问题,而只是输出视图的设置问题。

这就像:

Map.addLayer(classified, {},'classified',true);

返回的地图只有一种颜色 (class),但是

Map.addLayer(classified, {palette: igbpPalette, min: 0, max: 17},'classified',true);

返回了具有所需颜色的地图(classes)。 "Classified" 是输出 class 化图像,"ihbpPalette" 是包含颜色信息的列表。

我希望这能为您的调试提供新的方向。