I'd do something like this:
// Landsat 5 TM Raw Image Collection
var lt5 = ee.ImageCollection("LANDSAT/LT5_L1T");
// Filter by date and location (Landsat Path and Row Designation)
var lakeTiticaca_Early = lt5.filterDate('1985-01-01', '1986-01-01')
.filter(ee.Filter.eq('WRS_PATH', 2))
.filter(ee.Filter.eq('WRS_ROW', 71));
// Selecting Images with least cloud cover
var leastCloud = ee.Image(lakeTiticaca_Early.sort('CLOUD_COVER').first());
// Filter by date and location (Landsat Path and Row Designation)
var lakeTiticaca_Later = lt5.filterDate('2011-01-01', '2012-01-01')
.filter(ee.Filter.eq('WRS_PATH', 2))
.filter(ee.Filter.eq('WRS_ROW', 71));
// Selecting Images with least cloud cover
var leastCloud2 = ee.Image(lakeTiticaca_Later.sort('CLOUD_COVER').first());
// Applying MNDWI Function to Least Cloudy Images
var mNDWI_Early = leastCloud.expression(
'(Green - MIR) / (Green + MIR)', {
'Green': leastCloud.select('B2'),
'MIR': leastCloud.select('B5')
});
var mNDWI_Later = leastCloud2.expression(
'(Green - MIR) / (Green + MIR)', {
'Green': leastCloud2.select('B2'),
'MIR': leastCloud2.select('B5')
});
// Creating an image collection from the MNDWI calculated Images
var constant1 = ee.Image(mNDWI_Early).select([0],["mNDWI"]);
Map.addLayer(leastCloud,{bands:["B4","B5","B3"]},"before")
var constant2 = ee.Image(mNDWI_Later).select([0],["mNDWI"]);
Map.addLayer(leastCloud2,{bands:["B4","B5","B3"]},"after")
var dif = constant2.subtract(constant1)
Map.addLayer(dif,{},"dif")
var img1 = leastCloud.addBands(constant1)
var img2 = leastCloud2.addBands(constant2)
var final = ee.Image.cat(img1,img2)
Map.addLayer(final,{},"final")
//* Supervised Image Classification *//
var training = ee.FeatureCollection([water_nochange, water_gain, water_loss, land_nochange]).flatten()
var sample = final.sampleRegions(training, ["class"], 30)
var trained = ee.Classifier.cart().train(sample, "class")
var classified = final.classify(trained)
Map.addLayer(classified,{min:1, max:4, palette:["#b3b3ff","#0000e6", "#ff0000", "#009900"]},"classified")
You can access the feature collections in the following link:
https://code.earthengine.google.com/3f4c2908fcf7c469357b80783f3ef26f
You should mask clouds, use another path/row to include the missing part of the lake, and make more training points. You can also try another classifier like svm, randomForest, etc.
Comparing field to field, you use the leftField, rightField arguments in ee.Filter.equals. (Also, you should basically never use filterMetadata)
data.filter(ee.Filter.equals({leftField: 'Field1date', rightField: 'Field2date'})
Best Answer
To remove all the properties, use
select()
with an empty list of property names. Then you can add the class property and merge it with other collections, for classification or export: