3

Problem:
I have a mosaic of a Landsat 7 collection in Google Earth Engine that looks alright on display (pre-export-version) in the map window of the web app. However, when I export it, some pixels get narrower and some wider. Basically there are north-south columns with pixels that are 22 m wide instead of 30m. (see attached screenshot)

Question: Why does this happen? Is there any way to avoid it?

enter image description here

Investigation:
I investigated the output in QGIS, but if I upload the exported image back into Earth Engine this difference remains, so it does not appear to be a platform dependent problem.

If I use the inspector function, the pre-export and the export-imported file have different pixel values where the overlap is distorted, so it is not just a display error.

If I do the same thing with an image from the same collection (just the raw image, no mosaic), the exported file looks identical to the original.

I have tried to export using different coordinate references such as WGS84 and different UTM-zones. None of this affects the result.

Thoughts:
First I thought that difference between the mosaic and the raw image could imply that the irregularities are a result from the mosaic operation trying to fit pixels with slightly different spatial location into the same raster. But if so, I do not really get why that is not showing in the pre-export render of the raster.

Reproducible example: (or see link: https://code.earthengine.google.com/3ecceca28e81cc3d0c304281f08b4619)

// Define study site geometry:
var box = ee.Geometry.Rectangle(14.91081234991633, 68.28371077192794, 14.965572329164377, 68.30250393637535);
Map.centerObject(box);

// Filter image collection by time and area.
var landsat_7 = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR") // 
  .filterBounds(box)
  .filterDate('2000-07-01','2000-08-31');

// Make median mosaic from collection:  
var landsat_7_mosaic = landsat_7.median()
  .select('B.+'); // Keep only bands containing B

var visuals = {bands: ["B1","B2","B3"],
    gamma: 1,
    max: 2737.5867438745377,
    min: 2040.6889200176545,
    opacity: 1};

// Add the image to the map window
Map.addLayer(landsat_7_mosaic, visuals, 'Landsat 7 mosaic');
             
Export.image.toDrive({image: landsat_7_mosaic,
                       description:'imageToDriveExample',
                       scale:30,
                       region: box,
                       maxPixels:1e13});

// Import the export and add to map to compare with the pre-export

1 Answer 1

2

By default GEE exports images in EPSG:4326 which leads to the rectangle looking pixels at this latitude. It is always best to reproject the image at export to the native projection - in your case EPSG:32633. This should solve the issue: https://code.earthengine.google.com/d93bebc73ffda84bb0a390982c725b34

// Define study site geometry:
var box = ee.Geometry.Rectangle(14.91081234991633, 68.28371077192794, 14.965572329164377, 68.30250393637535);
Map.centerObject(box);
Map.addLayer(box)

// Filter image collection
var landsat_7 = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR") // Use var to make an object containing the landsat 5 catalogue.
  .filterBounds(box)
  .filterDate('2000-07-01','2000-08-31');

// Make median mosaic from collection:  
var landsat_7_mosaic = landsat_7.median()
  .select('B.+'); // Keep only bands containing B
print(landsat_7)
var visuals = {bands: ["B1","B2","B3"],
    gamma: 1,
    max: 2737.5867438745377,
    min: 2040.6889200176545,
    opacity: 1};

// Add the image to the map window
Map.addLayer(landsat_7_mosaic, visuals, 'Landsat 7 mosaic');

             
Export.image.toDrive({image: landsat_7_mosaic.select(["B1","B2","B3"]),
                       description:'mosaic_epsg4326',
                       scale:30,
                       region: box,
                       maxPixels:1e13});
                       
var proj = landsat_7.first().select(0).projection();
print(proj)
Export.image.toDrive({image: landsat_7_mosaic.select(["B1","B2","B3"]).reproject(proj),
                       description:'mosaic_reproj_epsg32633',
                       scale:30,
                       region: box,
                       maxPixels:1e13});
                   

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.