0

I am doing land use/ land cover classification of 2000 and 2018 year . I had completed supervised classification now i wanted to do change detection analysis. Please guide me how to do change detection for 2 years . Link to my code :https://code.earthengine.google.com/7627f681e4d50cb9cd8027d3ff34cf54

var image = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')    .filterBounds(geometry)    .filterDate('2018-01-01', '2019-1-31')    .sort('CLOUD_COVER')    .first());

print( image);

var Trivandrum = ee.Image ('LANDSAT/LC08/C01/T1_SR/LC08_144054_20180206');
var Trivandrum1 = ee.Image ('LANDSAT/LC08/C01/T1_SR/LC08_143054_20180911');

var mosaic = ee.ImageCollection.fromImages([Trivandrum,Trivandrum1]).mosaic();
Map.addLayer(mosaic, {bands: ['B4', 'B3', 'B2'], max: 0.3}, 'mosaic');
Map.addLayer(table);


var newfc = waterbodies.merge(forest).merge(settlements).merge(sandyarea).merge(agriculture_cropland).merge(agriculture_plantation).merge(fallowland);
print(newfc, 'newfc');

// Select the bands to be used in training
var bands = ['B2', 'B3', 'B4', 'B5','B6','B7'];

// Sample the input imagery to get a FeatureCollection of training data.
var training = mosaic.select(bands).sampleRegions({
  collection: newfc,
  properties: ['landcover'],
  scale: 30  // should reflect the scale of your imagery, the scale is 30 meters
});
var trained = ee.Classifier.cart().train(training, 'landcover', bands);

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

var palette = [
  '0000FF', // wb
  '0F8C3A', // f
  'FF0000', // settlements
  'A52A2A',   // sandy area
  'FFFF00', // vegetation
 ' 0B6607',// forest 

 '665A07' // wastland
];

var composite = {
  bands: ['B2','B3','B4'],
  gamma: 1,
  max: 0.80,
  min: 0.04
};

var clipped = classified.clip(table);

Map.setCenter(76.98244, 8.4686, 11); 

Map.addLayer (mosaic, composite); 
Map.addLayer (classified, {min: 0, max: 5, palette: palette}, 'Land Use Classification');


Map.addLayer(clipped, {min: 0, max: 5, palette: palette}, 'Land Use ');

var geometry = ee.Geometry.Polygon(
          [[[76.2593, 8.8932],
          [76.4076, 8.0402],
          [77.314, 8.915],
          [77.4897, 8.2686]]]);


Export.image.toDrive({
  image: clipped,
  description: 'Trivandrum_mosaic_17',
  scale: 30,
  region: table,
  crs: 'EPSG:4326',
  folder: 'GEE',
  maxPixels: 10000000000000
});
var options = {
  lineWidth: 1,
  pointSize: 2,
  hAxis: {title: 'Classes'},
  vAxis: {title: 'Area m^2'},
  title: 'Area by class',
  series: {
    0: { color: 'blue'},
    1: { color: 'green'},
    2: { color: 'red'},
    3: {color : 'brown'},
    4 : {color: 'yellow'},
    5 : {color : 'orange'},

     6 : {color : 'grey'},
    7: {color : 'peach'}
  }
};

var areaChart = ui.Chart.image.byClass({
  image: ee.Image.pixelArea().addBands(clipped),
  classBand: 'classification', 
  region: table,
  scale: 60,
  reducer: ee.Reducer.sum()
}).setOptions(options)
  .setSeriesNames(['wb', 'forest', 'settlements','sandyarea','crop','plantation','fallow']);
print(areaChart);

// Reduce the region. The region parameter is the Feature geometry.
var meanDictionary = clipped.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: table,
  scale: 30,
  maxPixels: 1e9
});

// The result is a Dictionary.  Print it.
print(meanDictionary);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.