1

I want to make a time series analysis of landcover change with Landsat 7 images. After I classified them using MODIS land cover classification, I want to export the change in land use. For this, I already created lists with the sum of the area per land cover type. However, I have a list for each year and do not know how to compile those together and export them. Since by hand, this would be very time consuming.

So, how do I combine those lists for a time series analysis?

My code for this is:

// Use the MCD12 land-cover as training data.
var modisLandcover = ee.Image('MODIS/051/MCD12Q1/2011_01_01')
  .select('Land_Cover_Type_1');

// A pallete to use for visualizing landcover images.
var landcoverPalette = [
    'aec3d4', // water
    '152106', '225129', '369b47', '30eb5b', '387242', // forest
    '6a2325', 'c3aa69', 'b76031', 'd9903d', '91af40',  // shrub, grass, savanah
    '111149', // wetlands
    '8dc33b', // croplands
    'cc0013', // urban
    '6ca80d', // crop mosaic
    'd7cdcc', // snow and ice
    'f7e084', // barren
    '6f6f6f'  // tundra
];

// A set of visualization parameters using the landcover palette.
var landcoverVisualization = {palette: landcoverPalette, min: 0, max: 17, format: 'png'};
// Center over our region of interest.
Map.centerObject(geometry, 9);
// Draw the MODIS landcover image.
Map.addLayer(modisLandcover, landcoverVisualization, 'MODIS landcover');

// Load and filter Landsat data.
var l7 = ee.ImageCollection('LANDSAT/LE07/C01/T1')
    .filterBounds(geometry)
    .filterDate('2011-01-01', '2011-12-31')
    .sort('CLOUD_COVER', false);            //sort by cloud cover ('false' indivcates descending )

// Draw the Landsat composite, visualizing true color bands.
var landsatComposite = ee.Algorithms.Landsat.simpleComposite({
  collection: l7,
  asFloat: true
});
Map.addLayer(landsatComposite, {min: 0, max: 0.3, bands: ['B3','B2','B1']}, 'Landsat composite');

// Make a training dataset by sampling the stacked images.
var training = modisLandcover.addBands(landsatComposite).sample({
  region: geometry,
  scale: 30,
  numPixels: 5000,
  seed: 0
});


// Train a classifier using the training data. USING CART() classifier
//var classifier = ee.Classifier.cart().train({
var classifier = ee.Classifier.randomForest(100).train({
  features: training,
  classProperty: 'Land_Cover_Type_1',
});

var list = ee.List
var x = 2011;

while (x < 2020) {
var l7 = ee.ImageCollection('LANDSAT/LE07/C01/T1')
    .filterBounds(geometry)
    .filterDate(x+'-01-01', x+'-12-31')
    .sort('CLOUD_COVER', false);            //sort by cloud cover ('false' indivcates descending )

// Draw the Landsat composite, visualizing true color bands.
var landsatComposite = ee.Algorithms.Landsat.simpleComposite({
  collection: l7,
  asFloat: true
});


// Apply the classifier to the original composite.
var upsampled = landsatComposite.classify(classifier);

/////////////////////////////////
// SURFC AREA CALCULATON

// get the surface covered by each classified tree
var area_classified = ee.Image.pixelArea().divide(1e6).addBands(upsampled).reduceRegion({
  reducer: ee.Reducer.sum().group(1, 'group'),
  geometry: geometry,
  scale: 30,
  maxPixels: 10e10
});
var outputReducers = ee.List(area_classified.get('groups'));
print('area of each class'+ x,outputReducers);


 x= x+1; 

}

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.