0

I used the LANDSAT 8 TOA data to create an NDVI image. I want to export the image to my Drive. I have most of the code and it works, but I can't get the whole image in the export. It should cover the state of North Carolina, but I only see about 2/3 in the exported TIF. Also, the colors are apparently missing. In Earth Engine, it draws with green, but the exported image is greyscale or similar.

var center_pt = /* color: #98ff00 */ee.Geometry.Point([-78.833013671875, 35.0]);

var cloudMNDVI = function(image) {
    var q = image.select('BQA');
    var c1 = q.eq(61440);
    var c2 = q.eq(53248);
    var c3 = q.eq(28672);
    var mask = c1.or(c2).or(c3).not();
    var imag_mask = image.updateMask(mask);
    var ndvi = imag_mask.normalizedDifference(['B5','B4']);
    return ndvi.set('system:time_start', image.get('system:time_start'));
};

var nc = ee.FeatureCollection('TIGER/2016/States').filter(ee.Filter.eq('STATEFP', '37')).geometry();
//var ncBase = ee.FeatureCollection('TIGER/2016/States').filter(ee.Filter.eq('STATEFP', '37'));
//print(ncBase)

var nc_l8toa = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA").filterBounds(nc);

var nc_NDVI = nc_l8toa.map(cloudMNDVI);
var nc_NDmax = nc_NDVI.reduce(ee.Reducer.max());
var landMask = ee.Image('CGIAR/SRTM90_V4').mask();
var nc_best_landmk = nc_NDmax.updateMask(landMask);

var ndviVisParam = {min: -0.8, max: 0.8, palette: ['65eaaf', 'c2f1ce', 'daf7e5', 'a6f79d', '44f35e']};

print(nc_best_landmk)
Map.centerObject(center_pt, 6);
Map.addLayer(nc_best_landmk.clip(nc), ndviVisParam);

Export.image.toDrive({
  image: nc_best_landmk,
  description: 'imageToDriveExample',
  scale: 30,
  region: nc
});

This is what the export looks like: enter image description here

In the export script of the Tasks section, where it prompts for some export parameters, I've tried 30m, 300m, and 1000m. It wouldn't even start with 30m, but with 300m and 1000m, it's made the same image for export, one shown above, each time.

How do I get the image that covers all of N.C. and has the same colors as this into the export?

enter image description here

EDIT - I saw the answer from Madeleine and ran the process again. I made a screenshot of the Task and even though it's hard to see, you can see the image is completely drawn as I was completing the settings for Task. The exported image from this last process is also only partial, like the one I already included when I first wrote this question. enter image description here

1

Concerning the first point, you have to wait until the image is completely loaded on the GEE map before you export it, and from testing the code above I can see that it takes a couple of minutes. It's a weird GEE glitch or feature that causes images to be exported only as far as they've loaded. Concerning the second point, it is completely normal. Any image, even RGB images, are simply numbers to which a color ramp is attributed (that's why you specify a color palette when adding a layer to the map). Without visualizing it in the proper software it is going to show a grayscale by default. If you want it to be green you'll have to open it on QGIS or ArcMap (there may be others but I'm not sure) and tell it to use green.

3
  • 1
    Thanks for your answer. Unfortunately, I wasn't able to get GEE to export a complete image still. But the part about getting the colors right in QGIS or other software is helpful. I should have realized that. – John Polo Nov 19 '20 at 3:01
  • 1
    Try adding nc_best_landmk = nc_best_landmk.clip(nc); before exporting, I tried it and it seems to have worked. – Madeleine Nov 20 '20 at 15:24
  • That did it! Thank you! – John Polo Nov 20 '20 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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