要素“1_1_1_1_1_0”的属性“landcover”缺失

问题描述

我正在尝试在地球引擎代码上实现算法来预测耕地面积。 这是我的代码

var landsatCollection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
    .filterDate('2017-01-01','2017-12-31');

// Make a cloud-free composite.
var composite = ee.Algorithms.Landsat.simpleComposite({
  collection: landsatCollection,asFloat: true
});

// Merge the three geometry layers into a single FeatureCollection.
var newfc = urban.merge(vegetation).merge(water).merge(urban).merge(fields);

// Use these bands for classification.
var bands = ['B2','B3','B4','B5','B6','B7'];
// The name of the property on the points storing the class label.
var classproperty = 'landcover';

// Sample the composite to generate training data.  Note that the
// class label is stored in the 'landcover' property.
var training = composite.select(bands).sampleRegions({
  collection: newfc,properties: [classproperty],scale: 30
});

// Train a CART classifier.
var classifier = ee.Classifier.smileCart().train({
  features: training,classproperty: [classproperty],});
// Print some info about the classifier (specific to CART).
print('CART,explained',classifier.explain());

// Classify the composite.
var classified = composite.classify(classifier);
Map.centerObject(newfc);
Map.addLayer(classified,{min: 0,max: 3,palette: ['red','blue','green','yellow']});

// Optionally,do some accuracy assessment.  Fist,add a column of
// random uniforms to the training dataset.
var withRandom = training.randomColumn('random');

// We want to reserve some of the data for testing,to avoid overfitting the model.
var split = 0.7;  // Roughly 70% training,30% testing.
var trainingPartition = withRandom.filter(ee.Filter.lt('random',split));
var testingPartition = withRandom.filter(ee.Filter.gte('random',split));

// Trained with 70% of our data.
var trainedClassifier = ee.Classifier.smileCart().train({
  features: trainingPartition,classproperty: classproperty,inputProperties: bands
});

// Classify the test FeatureCollection.
var test = testingPartition.classify(trainedClassifier);

// Print the confusion matrix.
var confusionMatrix = test.errorMatrix(classproperty,'classification');
print('Confusion Matrix',confusionMatrix);

我收到这些错误

  • 购物车,解释 字典(错误) 缺少要素“1_1_1_1_0_0”的属性“landcover”。
  • 混淆矩阵 混淆矩阵(错误) 缺少要素“1_1_1_1_1_0”的属性“landcover”。
  • 第 1 层:图层错误:缺少要素“1_1_1_1_0_0”的属性“landcover”。

给我一​​些解决这些错误的建议。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...