0

I am using the dynamic world v1 dataset for creating a LULC map for the Florida Panhandle area. Whenever I take a small time period, I get an incomplete, kind of broken image.

I am trying to find the effect of hurricanes on forests and vegetation.

LULC map prepared using Dynamic World: My code is given below: `

var image = DW.filterBounds(roi)
.filterDate('2018-10-16','2018-11-16')
.mode()
.clip(roi);

var classification = image.select('label')

Map.addLayer(classification,VIS_PARAMS, 'Classified Image' )

var legend = ui.Panel({
  style: {
    position: 'bottom-left',
    padding: '8px 15px'
  }
});

var legendTitle = ui.Label({
  value: 'Legend',
  style: {
    fontWeight: 'bold',
    fontSize: '18px',
    margin: '0 0 4px 0',
    padding: '0'
    }
});

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')
      });
};  

var palette =['419BDF','397D49','88B053','7A87C6','E49635','DFC35A','C4281B','A59B8F','B39FE1'];

var names = ['Water','Trees','Grass', 'Flooded Vegetation','Crops','Shrub and Scrub','Built','Bare Land','Snow and Ice'];
 
// Add color and and names
for (var i = 0; i < 9; i++) {
  legend.add(makeRow(palette[i], names[i]));
  }  
 
// add legend to map (alternatively you can also print the legend to the console)
Map.add(legend);

var title = ui.Label('Land Use and Land Cover Classification Map of Florida Panhandle for the year 2016');
title.style().set('position', 'top-center');
Map.add(title);

var title = ui.Label('Prepared by: Abdul Mobin Ibna Hafiz');
title.style().set('position', 'bottom-right');
Map.add(title);


var chart = ui.Chart.image.byClass({
  image: ee.Image.pixelArea().multiply(1e-6)
  .addBands(classification.rename('classification')), 
  classBand: 'classification', 
  region:roi, 
  reducer: ee.Reducer.sum(), 
  scale:1000, 
  classLabels:['Water','Trees','Grass', 'Flooded Vegetation','Crops','Shrub and Scrub','Built','Bare Land','Snow and Ice']}).setOptions({
    title:'FLorida Panhandle area of the LULC classes Chart for 2016',
    hAxis:{title:'Classification'},
    vAxis:{title:'Area (sq.km)'},
    colors:['419BDF','397D49','88B053','7A87C6','E49635','DFC35A','C4281B','A59B8F','B39FE1']
  })

print(chart)

var areaImage_2016 = ee.Image.pixelArea().addBands(classification)


var areas = areaImage_2016.reduceRegion({
  reducer: ee.Reducer.sum().group({
    groupField:1, 
    groupName:'class'}), 
    geometry:roi.geometry(), 
    scale:1000, 
    maxPixels:1e13}) 
    
    print(areas)
    
var classAreas = ee.List(areas.get('groups'))

var classAreaList = classAreas.map(function(item){
  var areaDict = ee.Dictionary(item)
  var classNumber = ee.Number(areaDict.get('class')).format()
  var area = ee.Number(areaDict.get('sum')).divide(1e6).round()
  
  return ee.List([classNumber, area])
})

var result = ee.Dictionary(classAreaList.flatten())

print('Calculated Classified Area unit sq.km Year of 2016' ,result)

`

I expect to get a clear complete image showing all the classes `

var image = DW.filterBounds(roi)
.filterDate('2018-10-16','2018-11-16')
.mode()
.clip(roi);

var classification = image.select('label')

Map.addLayer(classification,VIS_PARAMS, 'Classified Image' )

var legend = ui.Panel({
  style: {
    position: 'bottom-left',
    padding: '8px 15px'
  }
});

var legendTitle = ui.Label({
  value: 'Legend',
  style: {
    fontWeight: 'bold',
    fontSize: '18px',
    margin: '0 0 4px 0',
    padding: '0'
    }
});

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')
      });
};  

var palette =['419BDF','397D49','88B053','7A87C6','E49635','DFC35A','C4281B','A59B8F','B39FE1'];

var names = ['Water','Trees','Grass', 'Flooded Vegetation','Crops','Shrub and Scrub','Built','Bare Land','Snow and Ice'];
 
// Add color and and names
for (var i = 0; i < 9; i++) {
  legend.add(makeRow(palette[i], names[i]));
  }  
 
// add legend to map (alternatively you can also print the legend to the console)
Map.add(legend);

var title = ui.Label('Land Use and Land Cover Classification Map of Florida Panhandle for the year 2016');
title.style().set('position', 'top-center');
Map.add(title);

var title = ui.Label('Prepared by: Abdul Mobin Ibna Hafiz');
title.style().set('position', 'bottom-right');
Map.add(title);


var chart = ui.Chart.image.byClass({
  image: ee.Image.pixelArea().multiply(1e-6)
  .addBands(classification.rename('classification')), 
  classBand: 'classification', 
  region:roi, 
  reducer: ee.Reducer.sum(), 
  scale:1000, 
  classLabels:['Water','Trees','Grass', 'Flooded Vegetation','Crops','Shrub and Scrub','Built','Bare Land','Snow and Ice']}).setOptions({
    title:'FLorida Panhandle area of the LULC classes Chart for 2016',
    hAxis:{title:'Classification'},
    vAxis:{title:'Area (sq.km)'},
    colors:['419BDF','397D49','88B053','7A87C6','E49635','DFC35A','C4281B','A59B8F','B39FE1']
  })

print(chart)

var areaImage_2016 = ee.Image.pixelArea().addBands(classification)


var areas = areaImage_2016.reduceRegion({
  reducer: ee.Reducer.sum().group({
    groupField:1, 
    groupName:'class'}), 
    geometry:roi.geometry(), 
    scale:1000, 
    maxPixels:1e13}) 
    
    print(areas)
    
var classAreas = ee.List(areas.get('groups'))

var classAreaList = classAreas.map(function(item){
  var areaDict = ee.Dictionary(item)
  var classNumber = ee.Number(areaDict.get('class')).format()
  var area = ee.Number(areaDict.get('sum')).divide(1e6).round()
  
  return ee.List([classNumber, area])
})

var result = ee.Dictionary(classAreaList.flatten())

print('Calculated Classified Area unit sq.km Year of 2016' ,result)  

`

0

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.