Using 2001 MODIS Land Cover Type Yearly Global 500m Data to Determine the Land-Cover Analysis (Study Area: Mexico)

About Data

The MODIS Land Cover Type Yearly Global 500m product provides global land cover types at yearly intervals (2001-2016) derived from six different classification schemes. For this tutorial we will be using 2001 MODIS data. The data was prepared using the supervised classifications of MODIS Terra and Aqua reflectance data followed by additional post-processing that incorporate prior knowledge and ancillary information to further refine specific classes. These data are produced by NASA LP DAAC at the USGS EROS Center . .

In this tutorial, we will use the spatial smoothing (neighborhood mode) followed by dilation, erosion and dilation again. Following steps are adopted to determine the Land-Cover:

  1. Load a 2001 MODIS Land Cover Type Yearly Global 500m
  2. Select the classification band of interest.
  3. Reproject to WGS84 to force the image to be reprojected on load. This is just for display purposes, to visualize the input to the following operations. The next reproject is sufficient to force the computation to occur at native scale.
  4. Smooth with a mode filter.For this use erosion and dilation to get rid of small islands.
  5. Reproject to force the operations to be performed at SCALE.
  6. Define display parameters with appropriate colors for the MODIS land cover classification image.
  7. Display the final output
  8. Add Legends and Title

Let’s jump into code:

// Using MODIS data to determine the LandCover Analysis 

// Select your country
var countries = ee.FeatureCollection("ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw")
//var country_name = ['Cuba']
var country_name = ['Mexico']
//var country_name = ['Ethiopia']
//var country_name = ['Brazil']
var roi = countries.filter(ee.Filter.inList('Country', country_name));
//var projection = "EPSG:5070"; //" "EPSG:4269";  
Map.addLayer(roi,{},"Study Area"+country_name);
Map.centerObject(roi,5);  //Zoom to Study area

// Force projection of 500 meters/pixel, which is the native MODIS resolution.
var SCALE = 500;

// 1. Load a 2001 MODIS land cover image.
var image1 = ee.Image('MODIS/051/MCD12Q1/2001_01_01');
// 2. Select the classification band of interest.
var image2 = image1.select(['Land_Cover_Type_1']);
// 3. Reproject to WGS84 to force the image to be reprojected on load.
var image3 = image2.reproject('EPSG:4326', null, SCALE);
// 4. Smooth with a mode filter.
var image4 = image3.focal_mode();
// Use erosion and dilation to get rid of small islands.
var image5 = image4.focal_max(3).focal_min(5).focal_max(3);
// 5. Reproject to force the operations to be performed at SCALE.
var image6 = image5.reproject('EPSG:4326', null, SCALE);

// 6. Define display paramaters with appropriate colors for the MODIS land cover classification image.
var PALETTE = [
    'aec3d4', // water
    '152106', '225129', '369b47', '30eb5b', '387242', // forest
    '6a2325', 'c3aa69', 'b76031', 'd9903d', '91af40', // shrub, grass, savannah
    '111149', // wetlands
    'cdb33b', // croplands
    'cc0013', // urban
    '33280d', // crop mosaic
    'd7cdcc', // snow and ice
    'f7e084', // barren
    '6f6f6f'  // tundra
].join(',');

var vis_params = {min: 0, max: 17, palette: PALETTE};

// 7. Display each step of the computation.

Map.addLayer(image2.clip(roi), vis_params, 'LandCover classification');
Map.addLayer(image3.clip(roi), vis_params, 'Reprojected');
Map.addLayer(image4.clip(roi), vis_params, 'Mode');
Map.addLayer(image5.clip(roi), vis_params, 'Smooth');
Map.addLayer(image6.clip(roi), vis_params, 'Smooth Reprojected');

MODIS Land-Cover Map of Mexico
// 8. Add Legends and Title

 /************************ Title ****************************/
Map.add(ui.Label(
    'MODIS Land-Cover Map of '+country_name,
    {
      fontWeight: 'bold', 
      //fontColors: 'red',
      BackgroundColor: '09B3EC',
      //.paint(roi, 'fill')
      fontSize: '14px'}));
/************************ legend ****************************/
    
var names = ['Water', 'Forest','Shrub, Grass, Savannah','Wetlands', 'Croplands', 'Urban', 'Crop', 'Snow, Ice', 'Barren','Tundra' ];
var values = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ];
    
var PALETTE = [
    'aec3d4', // water
    '152106', '225129', '369b47', '30eb5b', '387242', // forest
    '6a2325', 'c3aa69', 'b76031', 'd9903d', '91af40', // shrub, grass, savannah
    '111149', // wetlands
    'cdb33b', // croplands
    'cc0013', // urban
    '33280d', // crop mosaic
    'd7cdcc', // snow and ice
    'f7e084', // barren
    '6f6f6f'  // tundra
];

// set position of panel
var legend = ui.Panel({
  style: {
    position: 'bottom-left',
    padding: '8px 15px'
  }
});
 
// Create legend title
var legendTitle = ui.Label({
  value: 'Legends',
  style: {
    fontWeight: 'bold',
    fontSize: '18px',
    margin: '0 0 4px 0',
    padding: '0'
    }
});
 
// Add the title to the panel
legend.add(legendTitle);
 
var makeRow = function(color, name) {

  // Create the label that is actually the colored box.
  var colorBox = ui.Label({
    style: {
      backgroundColor: '#' + color,
      // Use padding to give the box height and width.
      padding: '8px',
      margin: '0 0 4px 0'
    }
  });

  // Create the label filled with the description text.
  var description = ui.Label({
    value: name,
    style: {margin: '0 0 4px 6px'}
  });

  // return the panel
  return ui.Panel({
    widgets: [colorBox, description],
    layout: ui.Panel.Layout.Flow('horizontal')
  });
};
 
// Add color and and names
for (var i = 0; i < 10; i++) {
  legend.add(makeRow(PALETTE[i], names[i]));
  }  

// Add the legend to the map.
Map.add(legend);

More Images:


Leave a Reply

%d bloggers like this: