TransWikia.com

Doing histogram to compare areas between two years using Google Earth Engine

Geographic Information Systems Asked by juans on September 29, 2020

I want to do a simple visualization to summarize the total burned area in California between 2019 and 2020. Particularly I want to do a histogram or a column chart to show two columns, one for each year, showing the burned area in hectares. I should know how to do this but I have problems to find out.

My code below.

//Map.addLayer(Outline_image,[],'Outline, Image');
var California = ee.FeatureCollection("TIGER/2018/States")
  .filter(ee.Filter.eq("Name","California"));

// Identify datasets
var MCD64A1 = ee.ImageCollection('FIRMS').filterDate('2019-08-01', '2019-09-08');
MCD64A1 = MCD64A1.select('T21');
print("MCD64A1 2019", MCD64A1);
var MCD64A1_ = ee.ImageCollection('FIRMS').filterDate('2020-08-01', '2020-09-08');
MCD64A1_ = MCD64A1_.select('T21');
print("MCD64A1 2020", MCD64A1_);

// Plot preview 
var firesVis = {
  min: 296, max: 500, opacity: 0.6,
  palette: ['red', 'orange', 'yellow'],
};
var firesVis_ = {
  min: 304.29998779296875, max: 504, opacity: 0.6,
  palette: ["002bff","5ae8ff","85ff89"],
};
Map.setCenter(-122.3663, 38.0288,9);
Map.addLayer(MCD64A1.max().clip(California), {}, 'Fires2019');
Map.addLayer(MCD64A1_.max().clip(California), {}, 'Fires2020');


var Outline_image = MCD64A1.count().gt(0); 
//creating an image that has 1 wherever there has been a fire, 0 else
print("Outline_image", Outline_image);

var Outline_image_ = MCD64A1_.count().gt(0); 
//creating an image that has 1 wherever there has been a fire, 0 else
print("Outline_image_", Outline_image_);

var Outline_feature = Outline_image.reduceToVectors({geometry: California, scale: 500});
print("Outline_feature", Outline_feature);
var Outline_feature_ = Outline_image_.reduceToVectors({geometry: California, scale: 500});
print("Outline_feature_", Outline_feature_);

// create a ee.FeatureCollection for all fires within California in a scale of 500 m
var city_outline = ee.Image().byte().paint({
  featureCollection: Outline_feature,
  width: 2
});
var city_outline_ = ee.Image().byte().paint({
  featureCollection: Outline_feature_,
  width: 2
});


Map.addLayer(city_outline,[],'Outline, Feature');
Map.addLayer(city_outline_,[],'Outline, Feature');

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP