0

I'm attempting to create a spectral profile chart for 4 features in my feature collection that represent vegetation. I'm not really sure how to move forward, this is one of my first few times coding for a class and am having difficulty creating my code for Landsat 5 C1 T1 TOA. I've been mostly crafting based on code given to me by my professor, but it is designed to be used for Landsat 8. I've looked for answers online, but I'm not particularly skilled in deciphering long code language and most questions are regarding Landsat 8.

https://code.earthengine.google.com/d6fbedd85ee315948e322b1d64e302ca

var landsat = ee.ImageCollection("LANDSAT/LT05/C01/T1_TOA")
var town = ee.Image(landsat.filterDate('1984-07-01', '1984-07-31').filterBounds(town).sort('CLOUD_COVER').first());
//What we did there was declare a variable, called park. We then called Image from our ‘landsat’ import and filtered by date, then cloud cover and took the first image.
var trueColor = {
  bands: ['B3', 'B2', 'B1'],
  min: 0,
  max: 0.45
};
//Add Image
Map.addLayer(town, trueColor, 'True-color image');
var falseColor = {
  bands: ['B4', 'B3', 'B2'],
  min: 0,
  max: 0.45
};
Map.addLayer(town, falseColor, 'False-color image');
//TOA
var toaImage = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_220015_20170802').select('B([1-7])');
print('TOA', toaImage);
Map.addLayer(toaImage, {bands: ['B4', 'B3', 'B2'], min: 0, max: 0.45}, 'toa');
var points = ee.FeatureCollection([
 ee.Feature(greenpea, {'label': 'Green Pea'}),
 ee.Feature(potato, {'label': 'Potato'}),
 ee.Feature(sorghum, {'label': 'Sorghum'}),
 ee.Feature(marsh, {'label': 'Marsh'}),
]);
Map.addLayer(points);
var wavelengths = [0.44, 0.48, 0.56, 0.65, 0.86, 1.61, 2.2];
var options = {
 title: 'Landsat 5 TOA spectrum of crops in Hajdůbőszőrmėny, Hungary',
 hAxis: {title: 'Wavelength (micrometers)'},
 vAxis: {title: 'Reflectance'},
 lineWidth: 1,
 pointSize: 4,
 series: {
 0: {color: '00FF00'}, //Marsh
 1: {color: '0000FF'}, //Green Pea
 2: {color: 'FF0000'}, //Potato
 3: {color: 'f0af07'}, //Sorghum
}};
var chart = ui.Chart.image.regions(
 toaImage, points, ee.Reducer.mean(), 30, 'label', wavelengths)
 .setChartType('ScatterChart')
 .setOptions(options);
print(chart);
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.