I'm trying to quantify land use change over time in my region of interest, which is a part of Europe divided into subregions. For this, I'd like to count the pixels of each type of land cover in every subregion and export a table.

//Add MODIS Land Coverage dataset
var dataset = ee.ImageCollection('MODIS/006/MCD12Q1')
  .filterDate('2001-01-01', '2016-12-31');
var LandCover = dataset.select('LC_Type1');

//Mask all values except 12
var LandCoverCrops = LandCover.map(function(img) {
                var lc_type1 = img.select('LC_Type1');
                return lc_type1.neq(12)
                        .set('system:time_start', img.get('system:time_start'));

var LandCoverCropsMasked = LandCoverCrops.map(function(img) {
                   var mask = img.select(['LC_Type1']).neq(1);
                   return img.updateMask(mask)
                        .set('system:time_start', img.get('system:time_start'));

//Nice colors                  
var LandCoverVis = {
  min: 1.0,
  max: 17.0,
  palette: [
    '05450a', '086a10', '54a708', '78d203', '009900', 'c6b044', 'dcd159',
    'dade48', 'fbff13', 'b6ff05', '27ff87', 'c24f44', 'a5a5a5', 'ff6d4c',
    '69fff8', 'f9ffa4', '1c0dff'

//Add fusion table to map
var thesis_fusion = ee.FeatureCollection('ft:1Mn5wAIvtkzHzUMrG2yQryc9U4qSOa0ycJNEbywj6', 'geometry');
Map.addLayer(thesis_fusion, {}, "Region of Interest");

//Clip Crop Coverage raster with region of interest (here: Object_ID XX)
var LandCoverCropsMaskedMosaic = LandCoverCropsMasked.mosaic()
var LandCoverCropsMaskedClip = LandCoverCropsMaskedMosaic.clip(thesis_fusion.filter(ee.Filter.eq("system:index", '39')));

//Visualize Layer
Map.addLayer(LandCoverCropsMaskedClip, LandCoverVis, "Land covered by crops");

//Time series of croplands
print(ui.Chart.image.series(LandCoverCropsMasked, thesis_fusion.filter(ee.Filter.eq("system:index", '39')), ee.Reducer.count(), 500));

In this sample, I just created a chart of the development of crop land area between 2001 and 2016 in one area, Nr. 39 which is in Bulgaria (If this code does what I think it does). My goal would be to have a table with the years as columns and 1 to 186 (for each Region) in the rows, with the pixel areas for each year and Region.

I know the shapefile is a bit of a mess, but I'm very new to this sort of thing so at the moment I'm just trying to get it going. If there is something obvious to do better or differently I would be very thankful for suggestions.

  • 1
    Use ui.Chart.image.seriesByRegion – Kuik Jul 4 '19 at 11:32
  • That worked, thank you. – Oberberg Jul 4 '19 at 12:37

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.