5

I tried to export the NDVI obtained from the Landsat 8 Surface Reflectance Collection in Google Earth Engine and I keep on getting black lines in my final export. Everything looks fine when displaying it on the map online, it's just the export to google drive that has the problem.

Here is the code I'm using

var region = ee.FeatureCollection(
  'ft:1A9vRY9l-eBNBFBwAV_mLAEeCIPYS2T14vsKhiEQc');
var crop = region.geometry();

function mask_image(image){
  return image.updateMask(image.select('pixel_qa').bitwiseAnd(ee.Image.constant(2)).eq(2));
}

function ndvi(image){
  return image.addBands(image.normalizedDifference(['B5','B4']).rename('NDVI'));
}

var start = ee.Date('2013-01-01');
var end = ee.Date('2017-12-31');
var image = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
              .filterDate(start,end)
              .filterBounds(crop)
              .map(mask_image)
              .map(ndvi);

var to_export = image.mean().select(['NDVI']);

Export.image.toDrive({
  image: to_export,
  description: 'NDVI-test',
  folder:'Landsat8-NDVI',
  scale: 30,
  region: crop,
  maxPixels:1e10,
  crs: 'EPSG: 32718'
  });

Map.centerObject(image,8);
Map.addLayer(to_export.clipToCollection(region));

This is how it looks like when opening the export image in a GIS software.

Black Lines in Landsat8 NDVI image

5
  • Are the lines there when you zoom in? Are multiple tiles exported or just a single image?
    – Jon
    Commented Feb 13, 2018 at 17:39
  • It's a single image export and I zoomed in only a bit to make the lines more notorious. You can see them without zooming in too.
    – DangoMelon
    Commented Feb 16, 2018 at 6:09
  • I downloaded it and the stripes are NaNs. My guess was that it has to do with the resampling method (default is nearest neighbor). If you export it in native CRS, you can reproject it with GIS (takes a second or two). If you really want GEE to do your reprojecting, this thread might help: groups.google.com/forum/#!msg/google-earth-engine-developers/…
    – Jon
    Commented Feb 17, 2018 at 7:25
  • I was hoping to get it done in GEE before trying to use any other GIS software. Unfortunately, I don't have access to the developers group even though I sent a request for it almost a year ago.
    – DangoMelon
    Commented Feb 18, 2018 at 3:36
  • 1
    Here is one suggested way to export to avoid the lines: code.earthengine.google.com/eb5d39c406a00166e9c468c63497c8e8 It seemed to solve the user's question which was similar to yours.
    – Jon
    Commented Feb 19, 2018 at 3:58

1 Answer 1

3

This problem is caused through your reduction on the line with:

var to_export = image.mean().select(['NDVI']); 

Compositions and reductions have no projection and are just reported as being WGS84.

This script exports the map without the vertical lines (https://code.earthengine.google.com/0de29cd6954bada783ef0bacbb5b1ba6):

var region = ee.FeatureCollection('ft:1A9vRY9l-eBNBFBwAV_mLAEeCIPYS2T14vsKhiEQc');
var crop = region.geometry();

function mask_image(image){
  return image.updateMask(image.select('pixel_qa').bitwiseAnd(ee.Image.constant(2)).eq(2));
}

function ndvi(image){
  return image.addBands(image.normalizedDifference(['B5','B4']).rename('NDVI'));
}

var start = ee.Date('2013-01-01');
var end = ee.Date('2017-12-31');
var image = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
              .filterDate(start,end)
              .filterBounds(crop)
              .map(mask_image)
              .map(ndvi);

var original_proj = image.first().projection();

print(original_proj.crs());
print(image.first().projection().nominalScale());

var to_export = image.mean().select(['NDVI']);

print(to_export.projection().crs());
print(to_export.projection().nominalScale());

to_export = to_export.reproject(original_proj);

Export.image.toDrive({
  image: to_export,
  description: 'NDVI-test',
  folder:'Landsat8-NDVI',
  scale: to_export.projection().nominalScale().getInfo(),
  region: crop,
  maxPixels: 1e10,
  crs: 'EPSG: 32718'
  });

It prints the crs and scale of an image in the image-collection called 'image' and does the same from the image called 'to_export' which is created by taking the mean of the images in 'image'.

You can see that initially, the crs is EPSG:32619 with a scale of 30 meters. After the mean-reduction, the crs of 'to_export' is EPSG:4326 with a scale of 111319.49079327357 meters. So we need to add one more line to your code, before proceeding to the export, i.e. 'to_export.reproject(original_proj);'.

Now the projection is correct again and your export doesn't contain the vertical lines.

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.