0

Based on the mentioned code please suggest me how can I export single band image (either brightness band or greenness band) in google earth engine.

var sanfrancisco = ee.Feature(
    ee.Geometry.Polygon(
        [[[-122.5150959435926, 37.78159122861445],
          [-122.5150959435926, 37.715353209066016],
          [-122.39012646117072, 37.715353209066016],
          [-122.39012646117072, 37.78159122861445]]], null, false),
    {
    "id": "San Francisco",
    "system:index": "0"
  });
var sacremento = ee.Feature(
    ee.Geometry.Polygon(
        [[[-121.57931330173767, 38.66249153917632],
          [-121.57931330173767, 38.449857622479634],
          [-121.29641535251892, 38.449857622479634],
          [-121.29641535251892, 38.66249153917632]]], null, false),
    {
      "id": "Sacramento",
      "system:index": "0"
    });

var boxes = ee.FeatureCollection([sanfrancisco,sacremento]);
  var calculateTasseledCap = function (image){
  var b = image.select("B2", "B3", "B4", "B5", "B6", "B7");
  //Coefficients are only for Landsat 8 TOA
    var brightness_coefficents= ee.Image([0.3029, 0.2786, 0.4733, 0.5599, 0.508, 0.1872])
  var greenness_coefficents= ee.Image([-0.2941, -0.243, -0.5424, 0.7276, 0.0713, -0.1608]);
  var wetness_coefficents= ee.Image([0.1511, 0.1973, 0.3283, 0.3407, -0.7117, -0.4559]);
  var fourth_coefficents= ee.Image([-0.8239, 0.0849, 0.4396, -0.058, 0.2013, -0.2773]);
  var fifth_coefficents= ee.Image([-0.3294, 0.0557, 0.1056, 0.1855, -0.4349, 0.8085]);
  var sixth_coefficents= ee.Image([0.1079, -0.9023, 0.4119, 0.0575, -0.0259, 0.0252]);

    var brightness = image.expression(
            '(B * BRIGHTNESS)',
            {
                'B':b,
                'BRIGHTNESS': brightness_coefficents
                }
            );
  var greenness = image.expression(
    '(B * GREENNESS)',
            {
                'B':b,
                'GREENNESS': greenness_coefficents
                }
            );
  var wetness = image.expression(
    '(B * WETNESS)',
            {
                'B':b,
                'WETNESS': wetness_coefficents
                }
            );
  var fourth = image.expression(
      '(B * FOURTH)',
        {
          'B':b,
          'FOURTH': fourth_coefficents
          }
        );
  var fifth = image.expression(
      '(B * FIFTH)',
        {
          'B':b,
          'FIFTH': fifth_coefficents
          }
        );
  var sixth = image.expression(
    '(B * SIXTH)',
    {
      'B':b,
      'SIXTH': sixth_coefficents
      }
    );
  brightness = brightness.reduce(ee.call("Reducer.sum"));
    greenness = greenness.reduce(ee.call("Reducer.sum"));
    wetness = wetness.reduce(ee.call("Reducer.sum"));
    fourth = fourth.reduce(ee.call("Reducer.sum"));
    fifth = fifth.reduce(ee.call("Reducer.sum"));
  sixth = sixth.reduce(ee.call("Reducer.sum"));
  var tasseled_cap = ee.Image(brightness).addBands(greenness).addBands(wetness)
                             .addBands(fourth)
                             .addBands(fifth)
                             .addBands(sixth).rename('brightness','greenness','wetness','fourth','fifth','sixth')
  return tasseled_cap;
};

var start_date = "2018-12-30"
var end_date = "2018-12-31"
var cloud_cover = 10

var select_2018 = ee.Image("LANDSAT/LC08/C01/T1_RT_TOA/LC08_217073_20180613");
var BRD = boxes.geometry();
Map.centerObject(BRD);

var landsat8_collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
        .filterDate('2013-09-01', '2013-12-31')
        .filterMetadata('CLOUD_COVER', 'less_than', cloud_cover)
        .filterBounds(BRD)


var landsat8_tasseled_cap = landsat8_collection.map(calculateTasseledCap);

// reduce tasseled cap collection to an image so we can use .reduceRegion()
var tasseledcapImg = landsat8_tasseled_cap.mosaic()

var reducer = ee.Reducer.mean() // change to whichever reducer you would like to use

// map over each feature in the city collection
var city_stats = boxes.map(function(feature){
  // reduce the feature to get band statistics
  var zonalStats = tasseledcapImg.reduceRegion({
    reducer: reducer,
    geometry:feature.geometry(),
    scale:30
  })
  // return same feature but with the zonal stat results
  return feature.set(zonalStats)
})

print(city_stats)

Map.addLayer(landsat8_tasseled_cap,{},'Landsat 8 Tasseled Cap');
Map.addLayer(landsat8_tasseled_cap,{min: 0, max:1, bands:['brightness']},'brightness');
Map.addLayer(landsat8_tasseled_cap,{min: 0, max:1, bands:['greenness']},'greenness');
Map.addLayer(landsat8_tasseled_cap,{min: 0, max:1, bands:['wetness']},'wetness');
Map.addLayer(boxes,{color:'yellow'},'Cities');

1 Answer 1

0

Use .select() to extract a band then export it.

// To extract brightness band from the Image Collection
var brightness = landsat8_tasseled_cap.select('brightness')

// Image collection to Image (Extract the latest data, as displayed on your code)
var brightness_Image = brightness.reduce(ee.Reducer.last());

// Export the image
Export.image.toDrive({
   image: brightness_Image,
   description: 'brightness',
   scale: 30
 });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.