I am a beginner in GEE. I am trying to do the random forest classification for the GEDI datasets (rh13 and rh99) in Google Earth Engine. I want to do the classification of each point of the GEDI datasets and then interpolate for all the images (because the GEDI datasets are data points).
I'm getting this error and do not how to fix it:
Classified: Layer error: Property 'Relative Height' of feature '0_0'
is missing
var Paracou =
/* color: #d63000 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[-52.992228448173776, 5.3639624330339855],
[-52.992228448173776, 5.216962579558439],
[-52.898158013603464, 5.216962579558439],
[-52.898158013603464, 5.3639624330339855]]], null, false);
var qualityMask = function(im) {
return im.updateMask(im.select('quality_flag').eq(1))
.updateMask(im.select('degrade_flag').eq(0));
};
var img = ee.ImageCollection('LARSE/GEDI/GEDI02_A_002_MONTHLY')
.filterBounds(Paracou)
.map(qualityMask)
.select('rh13','rh99')
.median();
var gediVis = {
min: 1,
max: 60,
};
var img = img.clip(Paracou);
Map.centerObject(Paracou,12);
Map.addLayer(img, gediVis, 'rh13-99');
print(img.getInfo());
var points = img.sample({
'region': Paracou,
'scale' : 30,
'numPixels' : 200000,
'seed' : 0,
'geometries': true
});
Map.addLayer(points,{},'training',true);
print(points.size().getInfo());
print(points.first().getInfo());
//SPLIT AND TRAINING
// Use these bands for prediction
var bands = ['rh13','rh99'];
var label = 'Relative Height';
var sample = img.select(bands).sampleRegions({
collection: points,
properties : [label],
scale : 30
});
var sample = sample.randomColumn();
var split = 0.7;
var training = sample.filter(ee.Filter.lt('random',split));
var validation = sample.filter(ee.Filter.gte('random',split));
print(training.first().getInfo());
print(validation.first().getInfo());
var classifier = ee.Classifier.smileRandomForest(10).train(training,label,bands);
// Classification
var result = img.select(bands).classify(classifier);
Map.addLayer(result.randomVisualizer(),{},'classified');
https://code.earthengine.google.com/37d6104d659f4dc63f36baccde372a16
Best Answer
I don't follow how you want this to work. What are the classes you want in your classification? Nevertheless, the reason for your error is this:
The
points
collection doesn't contain anyRelative Height
property. Even if it did, I don't think this quite makes sense.You could maybe try something like the below. Note that I've never used the GEDI data, and have very limited knowledge of it. So take this approach with a grain of salt. I'd very much appreciate someone with more knowledge on this to jump in and comment.
I'm extracting reference data from the GEDI collection, create Landsat 8/Sentinel 1 composites for the corresponding month, and sample it for training data. A classifier is trained, then finally applied to a composite for a date range of your choosing.
https://code.earthengine.google.com/52f8f4ee6d2ab759e4f0fd1acb1ea2a9